Previous Up Next

4.3.1  Approximate solution of an equation : newton

newton takes as arguments : an expression ex, the variable name of this expression (by default x), and three values a (by default a=0), eps (by default eps=1e-8) and nbiter (by default nbiter=12).
newton(ex,x,a,eps,nbiter) computes an approximate solution x of the equation ex=0 using the Newton algorithm with starting point x=a. The maximum number of iterations is nbiter and the precision is eps.
Input :

newton(x^2-2,x,1)

Output :

1.41421356237

Input :

newton(x^2-2,x,-1)

Output :

-1.41421356237

Input :

newton(cos(x)-x,x,0)

Output :

0.739085133215

Previous Up Next