# Newton method for one variable

I try to use 'solve' for nonlinear eauqtions in one variable, but the answer is tautological or "cannot evaluate symbolic expression numerically" if I add "explicit_solutions=True". Is Newton method (or any other, like secant method) implemented in Sage?

Ex: sage: x=var('x') sage: (x-cos(x)).solve(x)

[x == cos(x)]

while I would expect x= 0.739085

edit retag close merge delete

1

You can find it with find_root(x-cos(x),0,1)

( 2016-08-22 03:19:11 -0500 )edit

thank you!

( 2016-08-22 04:10:40 -0500 )edit

It appears that find_root doesn't allow arbitrary precision. Is there another way?

( 2016-08-28 12:52:22 -0500 )edit

You might try mpmath, see using mpmath.findroot.

( 2016-08-28 16:47:03 -0500 )edit

Ok,thank you.

( 2016-08-31 13:26:50 -0500 )edit

Sort by » oldest newest most voted

solve is for symbolic or algebraic solutions. Use that

sage: find_root(x-cos(x),0,1)
0.7390851332151559

more

Oh, thank you!

( 2016-08-22 04:09:10 -0500 )edit

It appears that find_root doesn't allow arbitrary precision. Is there another way?

( 2016-08-28 12:52:42 -0500 )edit