Repository navigation
Initial Estimate
SimpleArt edited this page Nov 11, 2020
·
13 revisions
In many instances, known brackets for a root are not tight, but an initial estimate for the root may be known. For example, if many similar equations must be solved in sequence, it may be possible to estimate each solution by the previous solution.
solver.root_in(f, x1, x2, x = initial_estimate)The super square root of a is given by the solution to the equation
xx = a, where a ≥ e-1/e and x ≥ 1/e
It is simple enough to bound the solution by 1/e and a. An estimate of the solution may be given by log( 1 + a ).
>>> ssqrt = lambda a: solver.root_in(lambda x: x**x-a, 1/e, a, x = math.log(1+a))
>>>
>>> ssqrt(100)
f(4.629158318133363) = 1104.2434044621323
f(1.4392821583129523) = -98.31105062367506
f(3.0342202382231576) = -70.9840316454184
f(3.83168927817826) = 71.93737627642392
f(3.432954758200709) = -30.988052354067847
f(3.581496955878789) = -3.5325875855902495
f(3.596676871375278) = -0.13856836824705
f(3.597294260686355) = 0.0021062583561501924
f(3.597285025082755) = 3.5168058332146757e-07
f(3.597285023540406) = -2.6432189770275727e-12
f(3.597285023540429) = 2.6290081223123707e-12
11th iteration:
f(3.5972850235404175) = -1.4210854715202004e-14
3.5972850235404175