Jeremy Knight Math 639 Runge-Kutta
<Text-field style="Heading 1" layout="Heading 1">RungeKuttaDiffEQ</Text-field> RungeKuttaDiffEQ:=proc(a,b,m,f,N,alpha) #a,b=endpoints #m=number of equations #f=Array of function of m+1 independant variables with w(m+1)=t #N=number of intervals #alpha=initial conditions local i,j,k,h,t,w,temp,p: h:=(b-a)/N: k:=Array(1..4,1..m): t:=a: w:=Array(1..m): #initialize w vector with initial conditions for j from 1 to m do w[j]:=alpha[j]: end do: print(t,w): for i from 1 to N do ###k[1,j] for j from 1 to m do k[1,j]:=h*f[j](w): end do: ###k[2,j] temp:=Array(1..m): for p from 1 to m do temp[p]:=w[p]+0.5*k[1,p]: end do: for j from 1 to m do k[2,j]:=h*f[j](temp): end do: ###k[3,j] temp:=Array(1..m): for p from 1 to m do temp[p]:=w[p]+0.5*k[2,p]: end do: for j from 1 to m do k[3,j]:=h*f[j](temp): end do: ###k[4,j] temp:=Array(1..m): for p from 1 to m do temp[p]:=w[p]+k[3,p]: end do: for j from 1 to m do k[4,j]:=h*f[j](temp): end do: ### for j from 1 to m do w[j]:=w[j]+(k[1,j]+2*k[2,j]+2*k[3,j]+k[4,j])/6.0: end do: t:=a+i*h: if t=10 or t=20 or t=30 or t=40 or t=50 then print(t,w): end if: end do: end proc:
LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=
<Text-field style="Heading 1" layout="Heading 1"></Text-field> JSFH f1:=(x::Array)->-0.013*x[1]-1000.0*x[1]*x[3]; f2:=(x::Array)->-2500.0*x[2]*x[3]; f3:=(x::Array)->-0.013*x[1]-1000.0*x[1]*x[3]-2500.0*x[2]*x[3]; F:=Array([f1,f2,f3]); alpha:=Array([1.0,1.0,0.0]); Zio2IydJInhHNiJJJkFycmF5RyUqcHJvdGVjdGVkR0YmNiRJKW9wZXJhdG9yR0YmSSZhcnJvd0dGJkYmLCYqJiQiIzghIi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