Oct-08-2021, 09:38 AM
I am writing a simple program to calculate the zero point for a function. However it will never find it because of rounding. Any suggestions of how this can be done? Thanks.
1 2 3 4 5 6 7 8 9 10 11 12 |
def function_g(x): return (( 2 * x) - 1 ) counter = - 10 while counter< 10 : functionvalue = funksjon_g(counter) if functionvalue = = 0 : print ( "Zero point is ----------------> " + str (counter)) print ( "counter is " + str (counter) + " " + str (function_g(counter))) counter = counter + 0.1 |