MCPcopy Create free account
hub / github.com/ActiveState/code / SolveEq

Function SolveEq

recipes/Python/578048_IFS_fractal/recipe-578048.py:125–143  ·  view source on GitHub ↗
(fun, a, b)

Source from the content-addressed store, hash-verified

123# http://en.wikipedia.org/wiki/Bisection_method
124# function values must have opposite signs for f(a) and f(b)
125def SolveEq(fun, a, b):
126 eps = 1e-7
127 ya = fun(a)
128 yb = fun(b)
129 y0 = ya
130 yc = yb
131 while abs(yc - y0) > eps:
132 y0 = yc
133 c = (a + b) / 2.0
134 yc = fun(c)
135 if ya * yc < 0:
136 b = c
137 yb = yc
138 elif yb * yc < 0:
139 a = c
140 ya = yc
141 else:
142 break
143 return c
144
145print "Fractal Name: " + fractalName
146print "Scaling Coefficients:"

Callers 1

recipe-578048.pyFile · 0.85

Calls 1

funFunction · 0.50

Tested by

no test coverage detected