Newton Raphson interactive demo
Last updated at 8:45 pm UTC on 1 July 2018
To develop
A solution which answers in a dynamic way (i.e. in something like a Dynabook page) the question
'Can someone please tell me the conditions under which the Newton Raphson method will not converge? '
https://math.stackexchange.com/questions/726369/when-does-the-newton-raphson-method-fail/1766666#1766666
Tools
Active Essay of the Newton-Raphson algorithm
The Newton-Raphson algorithm does X and Y by using Z ....... (TODO put in the EXPLANATION)
| sketch f df pointA pointB|
sketch := DrGeoCanvas new axesOn.
f := [ :x | x cos + x ].
df := [ :x | (f value: x + 1e-8) - (f value: x) * 1e8]. "Derivate number"
sketch plot: f from: -20 to: 20.
pointA := (sketch point: 2@0) large.
pointB name: 'Drag me'.
5 timesRepeat: [
pointB := sketch
point: [ :pt | pt x @ (f value: pt x)]
parent: pointA.
pointB hide.
(sketch segment: pointA to: pointB) dotted forwardArrow .
pointA := sketch point: [:pt | | x |
x := pt x.
x - ( (f value: x) / (df value: x) ) @ 0
]
parent: pointB.
pointA hide.
(sketch segment: pointB to: pointA) dotted forwardArrow
].
Explanation of the first statement in the repeat block:
pointB := sketch point: [ :pt | pt point x @ (f value: pt point x)] parent: pointA.
The idea is to have a point object in the Dr. Geo model which coordinates are updated by an arbitrary block of code.
The block can receive one or several arguments as parents.
It is very handy to compute point position in cascade as in this example or in a recursive sequence for example.
The French doc explains it a bit further, but still might need more elaboration.
https://www.gnu.org/software/dr-geo/doc/fr/Figure-Smalltalk.html#index-point_003aparent_003a-on-DrGeoCanvas