I got the following error:
File "C:\Users\Admin\.spyder-py3\temp.py", line 22, in <module>
a = newton(p, p_prime,-10, 0)
File "C:\Users\Admin\.spyder-py3\temp.py", line 15, in newton
delta = p(x)/p_prime(x)
TypeError: 'Add' object is not callable
While running the following code:
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
acc = 1E-10
x = sym.Symbol('x')
def p(x): #define the function
return 924*x**6 - 2772*x**5 + 3150*x**4 - 1680*x**3 + 420*x**2 - 42*x +
1
p_prime = sym.diff(p(x))
print(p_prime)
def newton(p,p_prime, acc, start_val):
x= start_val
delta = p(x)/p_prime(x)
while abs(delta) > acc:
delta = p(x)/p_prime(x)
print(abs(delta))
x =x- delta;
return round(x, acc);
a = newton(p, p_prime,-10, 0)
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/6fdc90f7-7013-4dc5-a96a-5a9db8b5a122n%40googlegroups.com.