Thanks a lot, my mistake. You're right. I'm coming from a pure not object-oriented language (C) so sometimes I forget that even functions are objects. Again, thanks a lot.
On Wednesday, December 23, 2015 at 10:44:00 PM UTC-6, Nathan Goldbaum wrote: > > 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] <javascript:>> 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] <javascript:>. >> To post to this group, send email to [email protected] <javascript:> >> . >> 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/79254cd1-fd07-454b-92b4-72b14822e1e7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
