Thank you both for your answers. But I entered the function module in my first message but somehow that disappeared. I will enter it again
findRoot [expr,{ var,init}, eps ] :=
Module[{ xi=init, fun=Function[fvar, expr ] },
While[ Abs[fun[xi] ] > eps,
xi=N[ xi - fun[xi] / fun'[xi] ];
{var -> xi} ]x^
f[x_ ] : = x^2 -2
findroot [ x^2 - 2, {x,2},0.0001]
out {x -> 1.4..}
I do not completely understand the pure function 'fun' From what I learned in previous chapters I translate this (with above example)
fun=Function[fvar, x^2-2] . But that is not the correct interpretation.
Why not fun=Function[x,x^2-2]. or something like fun=Function[fvar, fvar^2 -2] ? I really would like to understand how it works
A.Geeraert