Jeremy Knight Math 639 4/7/11 Algorithm 11.1 Linear Shooting
<Text-field style="Heading 1" layout="Heading 1">LinearShooting(a,b,alpha,beta,p,q,r,N)</Text-field> To approximate the solution of the boundary-value problem LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYzLUkjbW9HRiQ2LVEqJnVtaW51czA7RicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y0LyUpc3RyZXRjaHlHRjQvJSpzeW1tZXRyaWNHRjQvJShsYXJnZW9wR0Y0LyUubW92YWJsZWxpbWl0c0dGNC8lJ2FjY2VudEdGNC8lJ2xzcGFjZUdRLDAuMjIyMjIyMmVtRicvJSdyc3BhY2VHRkMtSSNtaUdGJDYlUSN5IkYnLyUnaXRhbGljR1EldHJ1ZUYnL0YwUSdpdGFsaWNGJy1GLDYtUSIrRidGL0YyRjVGN0Y5RjtGPUY/RkFGRC1GRzYlUSJwRidGSkZNLUkobWZlbmNlZEdGJDYkLUYjNiQtRkc2JVEieEYnRkpGTUYvRi8tRkc2JVEieUYnRkpGTS1GLDYtUSInRidGL0YyRjVGN0Y5RjtGPUY/L0ZCUSwwLjExMTExMTFlbUYnL0ZFUSYwLjBlbUYnRk8tRkc2JVEicUYnRkpGTUZVRmduRk8tRkc2JVEickYnRkpGTUZVLUYsNi1RIj1GJ0YvRjJGNUY3RjlGO0Y9Rj8vRkJRLDAuMjc3Nzc3OGVtRicvRkVGW3AtSSNtbkdGJDYkUSIwRidGL0Yv, for LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEiYUYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RJiZsZXE7RicvRjNRJ25vcm1hbEYnLyU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JjAuMGVtRictSShtZmVuY2VkR0YkNiQtRiM2JC1GLDYlUSJhRidGL0YyRjlGOS1GNjYtUSI9RidGOUY7Rj5GQEZCRkRGRkZIL0ZLUSwwLjI3Nzc3NzhlbUYnL0ZORmZuLUkjbW5HRiQ2JFEiMUYnRjlGOQ==, LinearShooting:=proc(a,b,alpha,beta,p,q,r,N) #endpoints = a,b ; boundary conditions = alpha,beta #p,q,r = functions defined in differential equation #number of subintervals = N local i,j,h,k,kp,u,v,w,W1,W2,x: #option trace; ####Initialize#### u:=Array(1..2,1..N+1): v:=Array(1..2,1..N+1): w:=Array(1..2): k:=Array(1..4,1..2): kp:=Array(1..4,1..2): h:=(b-a)/N: u[1,1]:=alpha: u[2,1]:=0.0: v[1,1]:=0.0: v[2,1]:=1.0: #This loop will use the Runge-Kutta method for systems for i from 1 to N do print("u[1,i],v[1,i]",u[1,i],v[1,i]): x:=a+(i-1)*h: k[1,1]:=h*u[2,i]: k[1,2]:=h*(p(x)*u[2,i]+q(x)*u[1,i]+r(x)): k[2,1]:=h*(u[2,i]+0.5*k[1,2]): k[2,2]:=h*(p(x+h/2.0)*(u[2,i]+0.5*k[1,2]) + q(x+h/2.0)*(u[1,i]+0.5*k[1,1]) + r(x+h/2.0)): k[3,1]:=h*(u[2,i]+0.5*k[2,2]): k[3,2]:=h*(p(x+h/2.0)*(u[2,i]+0.5*k[2,2])+q(x+h/2.0)*(u[1,i]+0.5*k[2,1])+r(x+h/2.0)): k[4,1]:=h*(u[2,i]+k[3,2]): k[4,2]:=h*(p(x+h)*(u[2,i]+k[3,2])+q(x+h)*(u[1,i]+k[3,1])+r(x+h)): u[1,i+1]:=u[1,i]+(1.0/6.0)*(k[1,1]+2*k[2,1]+2*k[3,1]+k[4,1]): u[2,i+1]:=u[2,i]+(1.0/6.0)*(k[1,2]+2*k[2,2]+2*k[3,2]+k[4,2]): kp[1,1]:=h*v[2,i]: kp[1,2]:=h*(p(x)*v[2,i]+q(x)*v[1,i]): kp[2,1]:=h*(v[2,i]+0.5*kp[1,2]): kp[2,2]:=h*(p(x+h/2.0)*(v[2,i]+0.5*kp[1,2])+q(x+h/2.0)*(v[1,i]+0.5*kp[1,1])): kp[3,1]:=h*(v[2,i]+0.5*kp[2,2]): kp[3,2]:=h*(p(x+h/2.0)*(v[2,i]+0.5*kp[2,2])+q(x+h/2.0)*(v[1,i]+0.5*kp[2,1])): kp[4,1]:=h*(v[2,i]+kp[3,2]): kp[4,2]:=h*(p(x+h)*(v[2,i]+kp[3,2])+q(x+h)*(v[1,i]+kp[3,1])): v[1,i+1]:=v[1,i]+(1.0/6.0)*(kp[1,1]+2*kp[2,1]+2*kp[3,1]+kp[4,1]): v[2,i+1]:=v[2,i]+(1.0/6.0)*(kp[1,2]+2*kp[2,2]+2*kp[3,2]+kp[4,2]): end do: w[1]:=alpha: w[2]:=(beta-u[1,N+1])/v[1,N+1]: print(a,w[1],w[2]): for i from 2 to N+1 do W1:=u[1,i]+w[2]*v[1,i]: W2:=u[2,i]+w[2]*v[2,i]: x:=a+(i-1)*h: print(x,W1,W2): end do: end proc:
LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=
<Text-field style="Heading 1" layout="Heading 1">Example pg 676</Text-field> LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic= Digits:=14; p:=x->-2.0/x; q:=x->2.0/x^2.0; r:=x->evalf(sin(ln(x)))/x^2.0; a:=1.0; b:=2.0; alpha:=1.0; beta:=2.0; IiM5 Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLCQqJiQiIz8hIiIiIiI5JEYtRi1GJUYlRiU= Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlKiYkIiM/ISIiIiIiKTk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