Jeremy Knight Math 639 4/13/11 11.3 Linear Finite-Difference restart;
<Text-field style="Heading 1" layout="Heading 1">LinearFiniteDiff</Text-field> To approximate the solution of the boundary-value problem LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYxLUkjbWlHRiQ2JVEjeSJGJy8lJ2l0YWxpY0dRJXRydWVGJy8lLG1hdGh2YXJpYW50R1EnaXRhbGljRictSSNtb0dGJDYtUSI9RicvRjNRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW1tZXRyaWNHRj0vJShsYXJnZW9wR0Y9LyUubW92YWJsZWxpbWl0c0dGPS8lJ2FjY2VudEdGPS8lJ2xzcGFjZUdRLDAuMjc3Nzc3OGVtRicvJSdyc3BhY2VHRkwtRiw2JVEicEYnRi9GMi1JKG1mZW5jZWRHRiQ2JC1GIzYlLUYsNiVRInhGJ0YvRjIvJStleGVjdXRhYmxlR0Y9RjlGOS1GLDYlUSJ5RidGL0YyLUY2Ni1RIidGJ0Y5RjtGPkZARkJGREZGRkgvRktRLDAuMTExMTExMWVtRicvRk5RJjAuMGVtRictRjY2LVEiK0YnRjlGO0Y+RkBGQkZERkZGSC9GS1EsMC4yMjIyMjIyZW1GJy9GTkZkby1GLDYlUSJxRidGL0YyRlJGZm5GYG8tRiw2JVEickYnRi9GMkZSRlpGOQ== , for LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEiYUYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RJiZsZXE7RicvRjNRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y9LyUpc3RyZXRjaHlHRj0vJSpzeW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3Nzc3NzhlbUYnLyUncnNwYWNlR0ZULUYsNiVRJyYjOTQ2O0YnL0YwRkVGPUY9 . LinearFiniteDiff:=proc(p,q,r,a,b,alpha,beta,N) #{p,q,r}={p(x),q(x),r(x)} #a,b=endpoints #alpha,beta=boundary conditions #N= number of subintervals local h,i,j,u,x,z,w,A,B,C,D,L: #option trace; A:=Array(1..N): B:=Array(1..N): C:=Array(1..N): D:=Array(1..N): L:=Array(1..N): u:=Array(1..N): z:=Array(1..N): w:=Array(1..N+2): h:=(b-a)/(N+1): x:=a+h: A[1]:=2.0+h^2*q(x): B[1]:=-1+(h/2.0)*p(x): D[1]:=-h^2*r(x)+(1+(h/2.0)*p(x))*(alpha): for i from 2 to (N-1) do x:=a+i*h: A[i]:=2+h^2*q(x): B[i]:=-1+(h/2.0)*p(x): C[i]:=-1-(h/2.0)*p(x): D[i]:=-h^2*r(x): end do: x:=b-h: A[N]:=2+h^2*q(x): C[N]:=-1-(h/2.0)*p(x): D[N]:=-h^2*r(x)+(1-(h/2.0)*p(x))*beta: #solve a tridiagonal linear system using Algorithm 6.7 L[1]:=A[1]: u[1]:=B[1]/A[1]: z[1]:=D[1]/L[1]: for i from 2 to (N-1) do L[i]:=A[i]-C[i]*u[i-1]: u[i]:=B[i]/L[i]: z[i]:=(D[i]-C[i]*z[i-1])/L[i]: end do: L[N]:=A[N]-C[N]*u[N-1]: z[N]:=(D[N]-C[N]*z[N-1])/L[N]: w[1]:=alpha: w[N+2]:=beta: w[N+1]:=z[N]: for i from N to 2 by -1 do print(i,w[i+1]); w[i]:=z[i-1]-u[i-1]*w[i+1]: end do; for i from 1 to N+2 do x:=a+(i-1)*h: print(x, w[i]): end do: end proc:
LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic= p:=x->-2.0/x; q:=x->2/(x^2); r:=x->sin(ln(x))/x^2; Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLCQqJiQiIz8hIiIiIiI5JEYtRi1GJUYlRiU= Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLCQqJDkkISIjIiIjRiVGJUYl Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlKiYtSSRzaW5HNiQlKnByb3RlY3RlZEdJKF9zeXNsaWJHRiU2Iy1JI2xuR0YsNiM5JCIiIkYzISIjRiVGJUYl LinearFiniteDiff(p,q,r,1.0,2.0,1.0,2.0,9); NiQiIiokIispNEBSKj0hIio= NiQiIikkIitWPCkpKXkiISIq NiQiIigkIis6ISopXG8iISIq NiQiIickIiskKilmQmUiISIq NiQiIiYkIitnLTciWyIhIio= NiQiIiUkIitWP1MiUSIhIio= NiQiIiQkIittb0wkRyIhIio= NiQiIiMkIitESi8oPSIhIio= NiQkIiM1ISIiRiM= NiQkIisrKysrNiEiKiQiKz0wZyM0IkYl NiQkIisrKysrNyEiKiQiK0RKLyg9IkYl NiQkIisrKysrOCEiKiQiK21vTCRHIkYl NiQkIisrKysrOSEiKiQiK1Y/UyJRIkYl NiQkIisrKysrOiEiKiQiK2ctNyJbIkYl NiQkIisrKysrOyEiKiQiKyQqKWZCZSJGJQ== NiQkIisrKysrPCEiKiQiKzohKilcbyJGJQ== NiQkIisrKysrPSEiKiQiK1Y8KSkpeSJGJQ== NiQkIisrKysrPiEiKiQiKyk0QFIqPUYl NiQkIisrKysrPyEiKiQiIz8hIiI= for i from 10 to 3 do i; end do; JSFH