There is a multidimensional Newtonian solver in sympy which does
exactly this (only for the multidimensional case). Try msolve() to use
it. The code for the numerical solver is at sympy/solvers/numeric.py,
the interface (which calculates the Jacobian matrix symbolically) at
sympy/solvers/solvers.py.

However, usually it's better to do it numerically. For the
onedimensional case the secant method is more efficient than Newton's
method (it converges actually slower but needs only 1 functions
evaluation instead of 2 per iteration). For the multidimensional case
the symbolical derivative (aka Jacobian matrix) can be *very* complex
and slower to evaluate than the numerical derivative.

But feel free to implement it the way Sebastian suggested, it's a nice
exercise. :)

Vinzent

On Nov 23, 4:52 am, Matt <[EMAIL PROTECTED]> wrote:
> Hi all,
> I am just starting to use Sympy and I have a couple of questions. My
> need for sympy arose out of working on a simple Newton's method python
> script which is intended to use Newton's method (a *numerical*) method
> on somewhat arbitrary - but well-behaved - input functions. Since
> Newton's method relies on the derivative of the function as well, I'd
> like to be able to symbolically take the derivative rather than have
> to use a numerical approximation. After all, these are well-behaved
> functions, primarily algebraic and transcendental ones.
> So, what I would like to be able to do is write some code in my script
> which prompts the user for the function that will Newton's method will
> be used on. I know on a basic level how to use python's built-in input
> () and raw_input() functions. Is there a similar function in sympy, or
> a way to use one of those to functions to do what I'm trying to do? I
> couldn't find anything documenting this, and I really don't see why it
> should be impossible to do. Basically, I just want to associate a
> function "identifier" (e.g. f(x)) with some function (e.g. tanh(x) +
> x), since it seems like trying to implement Newton's method here with
> an anonymous function will be a pain.
> Again, I'm working on doing this in a script, not just in an
> interpreter like ipython or isympy.
>
> Thanks!
> Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to