#hw13.txt. March 9, 2014. Katie McKeon. read(`ExpMath/C13a.txt`): read(`ExpMath/C13.txt`): Help13:=proc(): print(`OtherJesusPi(n), OtherJesusPi1(n)`): print(`RK41(f,x,y,x0,y0,h), RK4(f,x,y,x0,y0,x1,h)`): print(`EulerH(f,x,y,x0,y0,x1,Di), impEulerH(f,x,y,x0,y0,x1,Di), RK4H(f,x,y,x0,y0,x1,Di)`): end: #OtherJesusPi1(n) computes the nth partial sum in Jesus Guillera's approximation #of 128*sqrt(5)/pi^2 OtherJesusPi1:=proc(n) local c,d,s,i: c:=1: d:=1: s:=29: for i from 1 to n do c:=c*(6*i)*(6*i-1)*(6*i-2)*(6*i-3)*(6*i-4)*(6*i-5)/(i^6): d:=(-1)*d/(2880^3): s:=s+c*d*(5418*i^2+693*i+29): od: s: end: #OtherJesusPi(n) computes the approximation of pi using the partial sum #OtherJesusPi1(n) - accurate to ~ 5n digits OtherJesusPi:=proc(n) evalf(sqrt(128*sqrt(5)/OtherJesusPi1(n))): end: #RK41(f,x,y,x0,y0,h) performs one iteration of the #Runge-Kutta method approximating y(x0) for the differential equation #y'(x) = f(x,y(x)) with y(0)=y0 and interval length h RK41:=proc(f,x,y,x0,y0,h) local k1, k2, k3, k4: k1:=subs({x=x0,y=y0},f): k2:=subs({x=x0+h/2,y=y0+h/2*k1},f): k3:=subs({x=x0+h/2,y=y0+h/2*k2},f): k4:=subs({x=x0+h,y=y0+h*k3},f): y0+h/6*(k1+2*k2+2*k3+k4): end: #RK4(f,x,y,x0,y0,x1,h) performs the Runge-Kutta method approximating #y(x1) for the differential equation y'(x) = f(x,y(x)) with y(0)=y0 #and interval length h RK4:=proc(f,x,y,x0,y0,x1,h) local L,xc,yc: L:=[y0]: xc:=x0: yc:=y0: while xc