I think you want to say:

r5 = newton_method(0, w)

Or you could make it so line 1 of your newton_method function doesn't use w
as a callable.

On Wed, Dec 23, 2015 at 9:00 PM, Lain Cortés González <
[email protected]> wrote:

> Traceback (most recent call last):
>   File "./H.py", line 130, in <module>
>     r5 = newton_method(0, w())
>   File "./H.py", line 123, in newton_method
>     fprime = lambdify(t,diff(w(), t), 'numpy')
> TypeError: 'Add' object is not callable
>
> I got the error before this, after I run these functions:
>
>
> from sympy.utilities import lambdify
> from sympy.abc import b, c, d, f as F, g, h, t , z, q
> from sympy import diff
> import numpy as np
>
>
>
> def w(x=t):
>     return b*(x) + c*(x**2) + d*(x**3) + F*(x**4) + g*(x**5) + h*(x**6) -
> z
>
> def m(x=t):
>     return b*x - z
>
> def newton_method(x, w, n=5):
>     fprime = lambdify(t,diff(w(), t), 'numpy')
>     for i in range(n):
>         if fprime(x) == 0:
>             return x
>         x -= np.divide(lambdify(x, w(x), 'numpy'), fprime(x))
>     return x
>
> r5 = newton_method(0, w())
>
> r6 = newton_method(0, m(), 12)
>
>
> What am I missing?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/94c5dd34-38c6-4a60-bba6-6bbf1500005e%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/94c5dd34-38c6-4a60-bba6-6bbf1500005e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAJXewOnByX7%3DOUnjbiYqO5jeX%2Bu%2BMLeHD5gptYYagrh4rjxzDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to