1
answer
0
watching
7
views
26 Nov 2019

This is my first time using python and I am having troubleprogramming error. We are asked to use newton's method ony(t)=(ln(cosh(t*sqrt(g*k))/k, where g=9.8065 , k=.00341,tolarance=.00001 this is what I did

def f(t):
return(math.log10(math.cosh(t*0.1828665)))/.00341

def deriv(t):
return (0.1828665 * math.sinh(0.1828665 *t))/math.cosh(0.1828665 * t)

for x in a:
ti=20
t= ti - f(ti)/deriv(ti)
print 't',x, '=',t
print 'f(t',x,')','=',f(t)
print 'abs(f(t',x,'))=',abs(f(t))
ti=t
if abs(t)<= .00001:
print "solutionconverges"
break

but I keep getting the same results 20 times as if ti is notupdated with the new value of t that has been calculated . can anyone tell me what's wrong?? help me fix this error please. I knowthe way i'm printing is stupid but as i said it's my first timeusing python and i just want to print the values then care aboutthe layout.

thanks

For unlimited access to Homework Help, a Homework+ subscription is required.

Unlock all answers

Get 1 free homework help answer.
Get unlimited access
Already have an account? Log in
Start filling in the gaps now
Log in