Hi!
I'm trying to make a code that solves my equations with newtons method, but python prints "TypeError: 'float' object is not callable". I have tried different numbers of parentheses and to use Decimal insted, but nothing works.
I would appreciate it if someone could help me. Thanks! :-)
I'm trying to make a code that solves my equations with newtons method, but python prints "TypeError: 'float' object is not callable". I have tried different numbers of parentheses and to use Decimal insted, but nothing works.
I would appreciate it if someone could help me. Thanks! :-)
from math import pi, sin, cos from decimal import Decimal m = 3 g = 9.8 R = 2 I = 12 x = 3*pi/4 eps = 0.000000001 def dadx(x): return (-m*g*R/(I))*cos(x) def d2adx2(x): return (m*g*R/(I)*sin(x)) def newtonsb(dadx,d2adx2,x,eps): while abs(dadx(x))>eps: x - float(dadx(x))/d2adx2(x) return x print "Maximum angular acceleration for releasing point x is at angle", newtonsb(dadx,d2adx2(x),x,eps)