Post Reply 
Solve example on various calculators
12-10-2023, 04:05 PM
Post: #11
RE: Solve example on various calculators
(12-09-2023 06:19 PM)C.Ret Wrote:  I have no idea what methods each of the listed calculators use. But I don't know of any numerical roots finding method that works without the function being defined, continuous and differentiable on either side of each root.

We may be able to get root with 1-sided convergence.

OP problem (root 1-√2), plain Newton's method won't work.
With shape like "╮", it will overshoot to bad region, inside 1±√2.

But, if we do 3-points quadratic fit for root, it may work.

lua> S = require'solver'
lua> f = fn'x: (x+1) * sqrt(x*x-2*x-1)'
lua> x = S.secant2(f, -0.4145, -0.4144, 1e-12, true, -0.4143)
-0.4145
-0.4144
-0.4143
-0.41421382517725713
-0.4142135670509061
-0.41421356238295287
-0.41421356237309526
-0.41421356237309503
lua> f(x)
0

Another way is what I called signed sqrt trick, as long as it does not change the roots.
Bad region now not only is defined, but also with sign reversal.
This allowed iterations to spiral to true roots, without using complex numbers.

For OP example, this is silly, but the trick may be useful elsewhere.

10 DEF FNS(X)=SGN(X)*SQRT(ABS(X))
20 DEF FNF(X)=(X+1)*FNS(X*X-2*X-1)
30 INPUT "A,B=";A,B
40 DISP FNROOT(A,B,FNF(FVAR)) @ GOTO 30

>run
A,B=-3,-.5
-1
A,B=-.5,.5
-.414213562375
A,B=.5,3
2.41421356238
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Solve example on various calculators - Albert Chan - 12-10-2023 04:05 PM



User(s) browsing this thread: 1 Guest(s)