0

i need to solve following equation:

0 = -1 / x**0.5) - 2 * log((alpha * x**0.5) + beta)

alpha and beta are given, i just need to iterate x until a certain extent.

I'm not a great python programmer, but like to implement this one. How might this be possible?

Best regards

ventavox
  • 23
  • 5

1 Answers1

0

The smartest to do would be to implement a solve function like Stanislav recommended. You can't just iterate over values of x until the equation reaches 0 due to Floating Point Arithmetic. You would have to .floor or .ceil your value to avoid an infinity loop. An example of this would be something like:

x = 0

while True:
    x += 0.1
    print(x)
    if x == 10:
        break

Here you'd think that x eventually reaches 10 when it adds 0.1 to 9.9, but this will continue forever. Now, I don't know if your values are integers or floats, but what I'm getting at is: Don't iterate. Use already built solve libraries.

MSJ
  • 154
  • 1
  • 3
  • 10