Ask Your Question
1

Newton method for one variable

asked 2016-08-22 09:53:18 +0200

logomath gravatar image

updated 2016-08-28 20:07:57 +0200

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 flag offensive close merge delete

Comments

1

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

mforets gravatar imagemforets ( 2016-08-22 10:19:11 +0200 )edit

thank you!

logomath gravatar imagelogomath ( 2016-08-22 11:10:40 +0200 )edit

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

logomath gravatar imagelogomath ( 2016-08-28 19:52:22 +0200 )edit

You might try mpmath, see using mpmath.findroot.

mforets gravatar imagemforets ( 2016-08-28 23:47:03 +0200 )edit

Ok,thank you.

logomath gravatar imagelogomath ( 2016-08-31 20:26:50 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2016-08-22 10:17:36 +0200

FrédéricC gravatar image

solve is for symbolic or algebraic solutions. Use that

sage: find_root(x-cos(x),0,1)
0.7390851332151559
edit flag offensive delete link more

Comments

Oh, thank you!

logomath gravatar imagelogomath ( 2016-08-22 11:09:10 +0200 )edit

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

logomath gravatar imagelogomath ( 2016-08-28 19:52:42 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-22 09:53:18 +0200

Seen: 542 times

Last updated: Aug 22 '16