Jeremy Knight Math 639 Algorithm 11.5: Piecewise Linear Rayleigh-Ritz
<Text-field style="Heading 1" layout="Heading 1">LinearRayleighRitz(f,p,q,n,x0)</Text-field> To approximate the solution to the boundary-value problem LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYtLUkjbW9HRiQ2LVEqJnVtaW51czA7RicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y0LyUpc3RyZXRjaHlHRjQvJSpzeW1tZXRyaWNHRjQvJShsYXJnZW9wR0Y0LyUubW92YWJsZWxpbWl0c0dGNC8lJ2FjY2VudEdGNC8lJ2xzcGFjZUdRLDAuMjIyMjIyMmVtRicvJSdyc3BhY2VHRkMtSSZtZnJhY0dGJDYoLUkjbWlHRiQ2JVEiZEYnLyUnaXRhbGljR1EldHJ1ZUYnL0YwUSdpdGFsaWNGJy1GIzYlLUZKNiVRI2R4RidGTUZQRk1GUC8lLmxpbmV0aGlja25lc3NHUSIxRicvJStkZW5vbWFsaWduR1EnY2VudGVyRicvJSludW1hbGlnbkdGZm4vJSliZXZlbGxlZEdGNC1JKG1mZW5jZWRHRiQ2JC1GIzYmLUZKNiVRInBGJ0ZNRlAtRlxvNiQtRiM2JC1GSjYlUSJ4RidGTUZQRi9GLy1GRzYoLUZKNiVRI2R5RidGTUZQRlJGV0ZaRmduRmluRi9GLy1GLDYtUSIrRidGL0YyRjVGN0Y5RjtGPUY/RkFGRC1GSjYlUSJxRidGTUZQRmNvLUZKNiVRInlGJ0ZNRlAtRiw2LVEiPUYnRi9GMkY1RjdGOUY7Rj1GPy9GQlEsMC4yNzc3Nzc4ZW1GJy9GRUZccS1GSjYlUSJmRidGTUZQRmNvRi8= , for LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYpLUkjbW5HRiQ2JF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kNiUtRiw2JVEiY0YnRj1GPy1GIzYlRmZvRj1GPy8lL3N1YnNjcmlwdHNoaWZ0R1EiMEYnRitGNUYy LinearRayleighRitz:=proc(f,p,q,n,x0) #f(x),p(x),q(x) are functions defined by the problem #n = number of of interval points between 0 and 1 #x0 = 1 x n Array([0,x1,x2,x3,...,xn]) local i,a,b,c,h,x,j,alpha,beta,zeta,PHI,phi,Q,z,approx: #option trace: #########Initialize########## x:=Array(0..n+1): h:=Array(0..n); Q:=Array(1..6,1..n+1): alpha:=Array(1..n): beta:=Array(1..n): zeta:=Array(1..n): a:=Array(1..n): b:=Array(1..n): #########End Initialize########## x[0]:=0.0: x[n+1]:=1.0: for i from 1 to n do x[i]:=x0[i]: end do: for i from 0 to n do h[i]:=x[i+1]-x[i]: end do: PHI:=proc(t,i) local temp: if t>=0 and t<=x[i-1] then temp:=0: elif t>x[i-1] and t<=x[i] then temp:=(t-x[i-1])/h[i-1]: elif t>x[i] and t<=x[i+1] then temp:=(x[i+1]-t)/h[i]: else temp:=0: end if: return temp: end proc: for i from 1 to n-1 do Q[1,i]:=(h[i]/12.0)*(q(x[i])+q(x[i+1])): Q[2,i]:=(h[i-1]/12.0)*(3.0*q(x[i])+q(x[i-1])): Q[3,i]:=(h[i]/12.0)*(3.0*q(x[i])+q(x[i+1])): Q[4,i]:=(1.0/(2.0*h[i-1]))*(p(x[i])+p(x[i-1])): Q[5,i]:=(h[i-1]/6.0)*(2.0*f(x[i])+f(x[i-1])): Q[6,i]:=(h[i]/6.0)*(2.0*f(x[i])+f(x[i+1])): end do: i=n: Q[2,i]:=(h[i-1]/12.0)*(3.0*q(x[i])+q(x[i-1])): Q[3,i]:=(h[i]/12.0)*(3.0*q(x[i])+q(x[i+1])): Q[4,i]:=(1.0/(2.0*h[i-1]))*(p(x[i])+p(x[i-1])): Q[5,i]:=(h[i-1]/6.0)*(2.0*f(x[i])+f(x[i-1])): Q[6,i]:=(h[i]/6.0)*(2.0*f(x[i])+f(x[i+1])): i:=n+1: Q[4,i]:=(1.0/(2.0*h[i-1]))*(p(x[i])+p(x[i-1])): for i from 1 to n-1 do alpha[i]:=Q[4,i]+Q[4,i+1]+Q[2,i]+Q[3,i]: beta[i]:=Q[1,i]-Q[4,i+1]: b[i]:=Q[5,i]+Q[6,i]: end do: alpha[n]:=Q[4,n]+Q[4,n+1]+Q[2,n]+Q[3,n]: b[n]:=Q[5,n]+Q[6,n]: #solve a symmetric tridiagonal linear system using algorithm 6.7 a[1]:=alpha[1]: zeta[1]:=beta[1]/alpha[1]: z[1]:=b[1]/a[1]: for i from 2 to n-1 do a[i]:=alpha[i]-(beta[i-1]*zeta[i-1]): zeta[i]:=beta[i]/a[i]: z[i]:=(b[i]-(beta[i-1]*z[i-1]))/a[i]: end do: a[n]:=alpha[n]-(beta[n-1]*zeta[n-1]): z[n]:=(b[n]-beta[n-1]*z[n-1])/a[n]: print("***** i,c[i] *****"): c[n]:=z[n]: print(n,c[n]): for i from n-1 to 1 by -1 do #calculate c[i] c[i]:=z[i]-(zeta[i]*c[i+1]): print(i,c[i]): end do: print("***** i, phi(x[i]) *****"): #calculate phi(x[i]) for i from 1 to n do phi:=0: for j from 1 to n do phi:=phi+c[j]*PHI(x[i],j): end do: print(i, x[i],phi): end do: end proc:
JSFHLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic= JSFH
<Text-field style="Heading 1" layout="Heading 1">Illustration pg. 703</Text-field> LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic= Digits:=20; p:=x->1.0; pi:=evalf(Pi); q:=x->evalf(Pi^2); f:=x->evalf(2.0*Pi^2*sin(Pi*x)); x0:=Array(1..9); for i from 1 to 9 do x0[i]:=0.1*i: end do: x0; LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJL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yYXlHJSpwcm90ZWN0ZWRHNiMvSSQlaWRHNiIiKiVRJVJbIw== LinearRayleighRitz(f,p,q,9,x0); interface(rtablesize=20): UTMqKioqKn5pLGNbaV1+KioqKio2Ig== NiQiIiokIjVbNCtVTkpKWnhJISM/ NiQiIikkIjVSPUVgZl08cWBlISM/ NiQiIigkIjU5Y2wpXHRESHAwKSEjPw== NiQiIickIjVdeSgqelkjUilbciUqISM/ NiQiIiYkIjVLJDRMIio+RDcqZSoqISM/ NiQiIiUkIjVceSgqelkjUilbciUqISM/ NiQiIiQkIjU3Y2wpXHRESHAwKSEjPw== NiQiIiMkIjVRPUVgZl08cWBlISM/ NiQiIiIkIjVbNCtVTkpKWnhJISM/ UTkqKioqKn5pLH5waGkoeFtpXSl+KioqKio2Ig== NiUiIiIkRiMhIiIkIjVbNCtVTkpKWnhJISM/ NiUiIiMkRiMhIiIkIjVRPUVgZl08cWBlISM/ NiUiIiQkRiMhIiIkIjU3Y2wpXHRESHAwKSEjPw== NiUiIiUkRiMhIiIkIjVceSgqelkjUilbciUqISM/ NiUiIiYkRiMhIiIkIjVLJDRMIio+RDcqZSoqISM/ NiUiIickRiMhIiIkIjVdeSgqelkjUilbciUqISM/ NiUiIigkRiMhIiIkIjU5Y2wpXHRESHAwKSEjPw== NiUiIikkRiMhIiIkIjVSPUVgZl08cWBlISM/ NiUiIiokRiMhIiIkIjVbNCtVTkpKWnhJISM/
<Text-field style="Heading 1" layout="Heading 1">Exercises: 1, 2, 3, 6, 7, 9 </Text-field> 1. p:=x->-1; q:=x->evalf(Pi^2/4); f:=x->evalf((Pi^2/16)*cos(Pi/4*x)); x0:=Array([0.3,0.7]); LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEicEYnLyUnaXRhbGljR1EldHJ1ZUYnLyUsbWF0aHZhcmlhbnRHUSdpdGFsaWNGJy1JI21vR0YkNi1RIzo9RicvRj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IkIiIkISIiJCE1WDMkUUR6Qkc+bSghI0A= NiUiIiMkIiIoISIiJCE1YyRbdWNNMD9EUighI0A= JSFH 2. p:=x->x; q:=x->4; f:=x->4*x^2-8*x+1; x0:=Array([0.4,0.8]): Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlRiRGJUYlRiU= Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlIiIlRiVGJUYl Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLCgqJiIiJSIiIilGJCIiI0YsRiwqJiIiKUYsRiRGLCEiIkYsRixGJUYlRiU= LinearRayleighRitz(f,p,q,2,x0); UTMqKioqKn5pLGNbaV1+KioqKio2Ig== NiQiIiMkITV3XGV5dFFTRm86ISM/ NiQiIiIkITVQdVFULFkxQyhRIyEjPw== UTkqKioqKn5pLH5waGkoeFtpXSl+KioqKio2Ig== NiUiIiIkIiIlISIiJCE1UHVRVCxZMUMoUSMhIz8= NiUiIiMkIiIpISIiJCE1d1xleXRRU0ZvOiEjPw== for i from 1 to 2 do print(x0[i]^2-x0[i]); end do: JCEjQyEiIw== JCEjOyEiIw== 3a. p:=x->x^2; q:=x->2; f:=x->-4*x^2; Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlKiQpRiQiIiMiIiJGJUYlRiU= Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlIiIjRiVGJUYl Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLCQqJiIiJSIiIilGJCIiI0YsISIiRiVGJUYl x0:=Array(1..9); for i from 1 to 9 do x0[i]:=0.1*i: end do: x0; LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYoLUkjbWlHRiQ2JVEjeDBGJy8lJ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W9wZW5HUSJbRicvJSZjbG9zZUdRIl1GJ0Zjci8lK2FjdGlvbnR5cGVHUS5ydGFibGVhZGRyZXNzRicvJSlydGFibGVpZEdRKjI0ODczNjcxMkYnLyUrZm9yZWdyb3VuZEdRKFswLDAsMF1GJy8lKXJlYWRvbmx5R0Y9Rjk= LUkmQXJyYXlHJSpwcm90ZWN0ZWRHNiMvSSQlaWRHNiIiKjdudFsj interface(prettyprint=1); LinearRayleighRitz(f,p,q,9,x0); 2 "***** i,c[i] *****" 9, -0.29185288363677972331 8, -0.27561646252088091646 7, -0.25469628903887379922 6, -0.22938395934692900910 5, -0.19995725132178503372 4, -0.16668119696818048768 3, -0.12980916911872257608 2, -0.089584000353309643772 1, -0.046239157209442660116 "***** i, phi(x[i]) *****" 1, 0.05, -0.046239157209442660116 2, 0.10, -0.089584000353309643772 3, 0.15, -0.12980916911872257608 4, 0.20, -0.16668119696818048768 5, 0.25, -0.19995725132178503372 6, 0.30, -0.22938395934692900910 7, 0.35, -0.25469628903887379922 8, 0.40, -0.27561646252088091646 9, 0.45, -0.29185288363677972331 3b. p:=x->evalf(exp(x)); q:=x->evalf(exp(x)); f:=x->evalf(x+(2-x)*exp(x)); Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLUkmZXZhbGZHJSpwcm90ZWN0ZWRHNiMtSSRleHBHNiRGK0koX3N5c2xpYkdGJUYjRiVGJUYl Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLUkmZXZhbGZHJSpwcm90ZWN0ZWRHNiMtSSRleHBHNiRGK0koX3N5c2xpYkdGJUYjRiVGJUYl Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLUkmZXZhbGZHJSpwcm90ZWN0ZWRHNiMsJkYkIiIiKiYsJiIiI0YuRiQhIiJGLi1JJGV4cEc2JEYrSShfc3lzbGliR0YlRiNGLkYuRiVGJUYl x0:=Array(1..9): for i from 1 to 9 do x0[i]:=0.1*i: end do: x0; LUkmQXJyYXlHJSpwcm90ZWN0ZWRHNiMvSSQlaWRHNiIiKiFbVChbIw== LinearRayleighRitz(f,p,q,9,x0); UTMqKioqKn5pLGNbaV1+KioqKio2Ig== NiQiIiokIjVgWSNIKD5JZl9IZiEjQA== NiQiIikkIjUoXE9xL0VnKlwrNiEjPw== NiQiIigkIjU/JHByKjRFJFwiNDohIz8= NiQiIickIjUiXElTKkg6d14uPSEjPw== NiQiIiYkIjUoZSZbYjZBKXlnJz4hIz8= NiQiIiUkIjVdZCxEIj5GJilvKD4hIz8= NiQiIiQkIjVGakJ2KVtSXksiPSEjPw== NiQiIiMkIjUlb15eUSR6IilSXDkhIz8= NiQiIiIkIjUxbiFmKG8nKTNgZyYpISNA UTkqKioqKn5pLH5waGkoeFtpXSl+KioqKio2Ig== NiUiIiIkRiMhIiIkIjUxbiFmKG8nKTNgZyYpISNA NiUiIiMkRiMhIiIkIjUlb15eUSR6IilSXDkhIz8= NiUiIiQkRiMhIiIkIjVGakJ2KVtSXksiPSEjPw== NiUiIiUkRiMhIiIkIjVdZCxEIj5GJilvKD4hIz8= NiUiIiYkRiMhIiIkIjUoZSZbYjZBKXlnJz4hIz8= NiUiIickRiMhIiIkIjUiXElTKkg6d14uPSEjPw== NiUiIigkRiMhIiIkIjU/JHByKjRFJFwiNDohIz8= NiUiIikkRiMhIiIkIjUoXE9xL0VnKlwrNiEjPw== NiUiIiokRiMhIiIkIjVgWSNIKD5JZl9IZiEjQA== 3c. p:=x->evalf(exp(-1*x)); q:=x->evalf(exp(-1*x)); f:=x->evalf((x-1)-(x+1)*exp(-1*(x-1))); Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLUkmZXZhbGZHJSpwcm90ZWN0ZWRHNiMtSSRleHBHNiRGK0koX3N5c2xpYkdGJTYjLCRGJCEiIkYlRiVGJQ== Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLUkmZXZhbGZHJSpwcm90ZWN0ZWRHNiMtSSRleHBHNiRGK0koX3N5c2xpYkdGJTYjLCRGJCEiIkYlRiVGJQ== Zio2I0kieEc2IkYlNiRJKW9wZXJhdG9yR0YlSSZhcnJvd0dGJUYlLUkmZXZhbGZHJSpwcm90ZWN0ZWRHNiMsKEYkIiIiRi4hIiIqJiwmRiRGLkYuRi5GLi1JJGV4cEc2JEYrSShfc3lzbGliR0YlNiMsJkYkRi9GLkYuRi5GL0YlRiVGJQ== x0:=Array(1..19): for i from 1 to 19 do x0[i]:=0.05*i: end do: x0; LUkmQXJyYXlHJSpwcm90ZWN0ZWRHNiMvSSQlaWRHNiIiKm9mdVsj LinearRayleighRitz(f,p,q,19,x0); UTMqKioqKn5pLGNbaV1+KioqKio2Ig== NiQiIz4kITUmZmVbMFJpIkhmNyEjPw== NiQiIz0kITV5KHB4WHciKUh5SyMhIz8= NiQiIzwkITVxXXdBVj5dKnpAJCEjPw== NiQiIzskITVTQylSdmB0ODklUiEjPw== NiQiIzokITU3NT9yKCpRRSs0WCEjPw== NiQiIzkkITVFKSk+TiE+OzU1JFwhIz8= NiQiIzgkITVaWFkmKSllcmJxQCYhIz8= NiQiIzckITUiPW0zVnpubWhQJiEjPw== NiQiIzYkITVRa09FeWpLIm9UJiEjPw== NiQiIzUkITUsOio+P3ZTVHBNJiEjPw== NiQiIiokITVhOztzPGZQK3VeISM/ NiQiIikkITUsaWpWVTAqKSlcIVwhIz8= NiQiIigkITUiUXUpbzo4KltrYSUhIz8= NiQiIickITVhcScpeSwhSERYNSUhIz8= NiQiIiYkITU7IltgIXpdTShcZSQhIz8= NiQiIiUkITV1ZnQwbnRkPSQqSCEjPw== NiQiIiQkITVhYngjKXlETEBNQiEjPw== NiQiIiMkITUjNCJSKydITCd5NzshIz8= NiQiIiIkITUxJWY8LF1rTUxMKSEjQA== UTkqKioqKn5pLH5waGkoeFtpXSl+KioqKio2Ig== NiUiIiIkI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iooLCYiIiMiIiIqJCksJkYkRjEkIiM1ISIiRjFGMEYxRjdGMS1JJGV4cEc2JEYrSShfc3lzbGliR0YlNiNGNUYxLUkjbG5HRjo2IyQiIz9GN0YxRjEqJkYwRjEtRjlGI0YxRjdGJUYlRiU= x0:=Array(1..19): for i from 1 to 19 do x0[i]:=0.05*i: end do: x0; LUkmQXJyYXlHJSpwcm90ZWN0ZWRHNiMvSSQlaWRHNiIiKiNmWihbIw== LinearRayleighRitz(f,p,q,19,x0); UTMqKioqKn5pLGNbaV1+KioqKio2Ig== NiQiIz4kITVgTC9XcilRYyM+aiEjQA== NiQiIz0kITUpKjNwRiIqW1RJcjYhIz8= NiQiIzwkITVOJ0ckPWEhKSlbTWkiISM/ NiQiIzskITVHYUA9VWN1UiQqPiEjPw== NiQiIzokITVTeWV6KGZaRmZHIyEjPw== NiQiIzkkITVxRTwsJlFkcmJdIyEjPw== NiQiIzgkITVATGo9biYqPWpjRSEjPw== NiQiIzckITVFbD4nPnkwJT5WRiEjPw== NiQiIzYkITU0WkYkM0RtUyJwRiEjPw== NiQiIzUkITVWJipRQUJZVztRRiEjPw== NiQiIiokITVZbScqW2hbNnlgRSEjPw== NiQiIikkITVjPS9WKjQ/VSQ+RCEjPw== NiQiIigkITU8JHl6aDBOWiFRQiEjPw== NiQiIickITVVZVUhSCFldCZINiMhIz8= NiQiIiYkITUsQGNIaU9wK1o9ISM/ NiQiIiUkITV0TWlMYVMiPUlhIiEjPw== NiQiIiQkITVBVD1GJGZZOVA/IiEjPw== NiQiIiMkITVzXDlINUcrTzwkKSEjQA== NiQiIiIkITUoNGNkZCwiM2MnSCUhI0A= UTkqKioqKn5pLH5waGkoeFtpXSl+KioqKio2Ig== NiUiIiIkIiImISIjJCE1KDRjZGQsIjNjJ0glISNA NiUiIiMkIiM1ISIjJCE1c1w5SDVHK088JCkhI0A= NiUiIiQkIiM6ISIjJCE1QVQ9RiRmWTlQPyIhIz8= NiUiIiUkIiM/ISIjJCE1dE1pTGFTIj1JYSIhIz8= NiUiIiYkIiNEISIjJCE1LEBjSGlPcCtaPSEjPw== NiUiIickIiNJISIjJCE1VWVVIUghZXQmSDYjISM/ NiUiIigkIiNOISIjJCE1PCR5emgwTlohUUIhIz8= NiUiIikkIiNTISIjJCE1Yz0vVio0P1UkPkQhIz8= NiUiIiokIiNYISIjJCE1WW0nKltoWzZ5YEUhIz8= NiUiIzUkIiNdISIjJCE1ViYqUUFCWVc7UUYhIz8= NiUiIzYkIiNiISIjJCE1NFpGJDNEbVMicEYhIz8= NiUiIzckIiNnISIjJCE1RWw+Jz55MCU+VkYhIz8= NiUiIzgkIiNsISIjJCE1QExqPW4mKj1qY0UhIz8= NiUiIzkkIiNxISIjJCE1cUU8LCZRZHJiXSMhIz8= NiUiIzokIiN2ISIjJCE1U3lleihmWkZmRyMhIz8= NiUiIzskIiMhKSEiIyQhNUdhQD1VY3VSJCo+ISM/ NiUiIzwkIiMmKSEiIyQhNU4nRyQ9YSEpKVtNaSIhIz8= NiUiIz0kIiMhKiEiIyQhNSkqM3BGIipbVElyNiEjPw== NiUiIz4kIiMmKiEiIyQhNWBML1dyKVFjIz5qISNA
LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=
<Text-field style="Heading 1" layout="Heading 1">LinearRayleighRitz2(f,p,q,n,x0)</Text-field> To approximate the solution to the boundary-value problem LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYtLUkjbW9HRiQ2LVEqJnVtaW51czA7RicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYnLyUmZmVuY2VHUSZmYWxzZUYnLyUqc2VwYXJhdG9yR0Y0LyUpc3RyZXRjaHlHRjQvJSpzeW1tZXRyaWNHRjQvJShsYXJnZW9wR0Y0LyUubW92YWJsZWxpbWl0c0dGNC8lJ2FjY2VudEdGNC8lJ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RmduRmluLUYsNiVRInFGJ0YvRjJGNUY6Rj1GPS8lJW9wZW5HUSJbRicvJSZjbG9zZUdRIl1GJy1GNjYmLUYjNiYtRiw2JVEnJiM5NDY7RicvRjBGRUY9RmhvLUYsNiVRJyYjOTQ1O0YnRltxRj1GPUY9Rl5wRmFwLUZANi1RKiZ1bWludXMwO0YnRj1GQ0ZGRkhGSkZMRk5GUEZnbkZpbkZbcEY1RlxxRj0= LinearRayleighRitz2:=proc(f,p,dpdx,q,ALPHA,BETA,n,x0) #f(x),p(x),q(x) are functions defined by the problem #n = number of of interval points between 0 and 1 #x0 = 1 x n Array([0,x1,x2,x3,...,xn]) local i,a,b,c,F,h,x,y,j,alpha,beta,zeta,PHI,phi,Q,z,approx: #option trace: #########Initialize########## x:=Array(0..n+1): h:=Array(0..n); Q:=Array(1..6,1..n+1): alpha:=Array(1..n): beta:=Array(1..n): zeta:=Array(1..n): a:=Array(1..n): b:=Array(1..n): #########End Initialize########## F:=proc(x): return(f(x)+(dpdx(x)-q(x)*x)*(BETA-ALPHA)-q(x)*ALPHA) end proc: x[0]:=0.0: x[n+1]:=1.0: for i from 1 to n do x[i]:=x0[i]: end do: for i from 0 to n do h[i]:=x[i+1]-x[i]: end do: PHI:=proc(t,i) local temp: if t>=0 and t<=x[i-1] then temp:=0: elif t>x[i-1] and t<=x[i] then temp:=(t-x[i-1])/h[i-1]: elif t>x[i] and t<=x[i+1] then temp:=(x[i+1]-t)/h[i]: else temp:=0: end if: return temp: end proc: for i from 1 to n-1 do Q[1,i]:=(h[i]/12.0)*(q(x[i])+q(x[i+1])): Q[2,i]:=(h[i-1]/12.0)*(3.0*q(x[i])+q(x[i-1])): Q[3,i]:=(h[i]/12.0)*(3.0*q(x[i])+q(x[i+1])): Q[4,i]:=(1.0/(2.0*h[i-1]))*(p(x[i])+p(x[i-1])): Q[5,i]:=(h[i-1]/6.0)*(2.0*F(x[i])+F(x[i-1])): Q[6,i]:=(h[i]/6.0)*(2.0*F(x[i])+F(x[i+1])): end do: i=n: Q[2,i]:=(h[i-1]/12.0)*(3.0*q(x[i])+q(x[i-1])): Q[3,i]:=(h[i]/12.0)*(3.0*q(x[i])+q(x[i+1])): Q[4,i]:=(1.0/(2.0*h[i-1]))*(p(x[i])+p(x[i-1])): Q[5,i]:=(h[i-1]/6.0)*(2.0*F(x[i])+F(x[i-1])): Q[6,i]:=(h[i]/6.0)*(2.0*F(x[i])+F(x[i+1])): i:=n+1: Q[4,i]:=(1.0/(2.0*h[i-1]))*(p(x[i])+p(x[i-1])): for i from 1 to n-1 do alpha[i]:=Q[4,i]+Q[4,i+1]+Q[2,i]+Q[3,i]: beta[i]:=Q[1,i]-Q[4,i+1]: b[i]:=Q[5,i]+Q[6,i]: end do: alpha[n]:=Q[4,n]+Q[4,n+1]+Q[2,n]+Q[3,n]: b[n]:=Q[5,n]+Q[6,n]: #solve a symmetric tridiagonal linear system using algorithm 6.7 a[1]:=alpha[1]: zeta[1]:=beta[1]/alpha[1]: z[1]:=b[1]/a[1]: for i from 2 to n-1 do a[i]:=alpha[i]-(beta[i-1]*zeta[i-1]): zeta[i]:=beta[i]/a[i]: z[i]:=(b[i]-(beta[i-1]*z[i-1]))/a[i]: end do: a[n]:=alpha[n]-(beta[n-1]*zeta[n-1]): z[n]:=(b[n]-beta[n-1]*z[n-1])/a[n]: print("***** i,c[i] *****"): c[n]:=z[n]: print(n,c[n]): for i from n-1 to 1 by -1 do #calculate c[i] c[i]:=z[i]-(zeta[i]*c[i+1]): print(i,c[i]): end do: print("***** i, phi(x[i]) *****"): #calculate phi(x[i]) for i from 1 to n do phi:=0: for j from 1 to n do phi:=phi+c[j]*PHI(x[i],j): end do: y:=phi+BETA*x[i]+(1-x[i])*ALPHA: print(i, x[i],y): end do: end proc:
LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=
<Text-field style="Heading 1" layout="Heading 1">Exercise 7</Text-field> Digits:=14: interface(displayprecision=-1); p:=x->1.0; dpdx:=x->0.0; q:=x->1.0; f:=x->x; ALPHA:=1.0; BETA:=evalf(1.0+exp(-1.0)); x0:=Array(1..9): for i from 1 to 9 do x0[i]:=0.1*i: end do: -1 p := x -> 1.0 dpdx := x -> 0. q := x -> 1.0 f := x -> x ALPHA := 1.0 BETA := 1.3678794411714 interface(prettyprint=1); LinearRayleighRitz2(f,p,dpdx,q,ALPHA,BETA,9,x0): 1 "***** i,c[i] *****" 9, -0.024540434341475 8, -0.045008570892836 7, -0.060976256872801 6, -0.071970259861642 5, -0.077467527576608 4, -0.076889948617020 3, -0.069598561698980 2, -0.054887155375404 1, -0.031975194131704 "***** i, phi(x[i]) *****" 1, 0.1, 1.0048127499854 2, 0.2, 1.0186887328589 3, 0.3, 1.0407652706524 4, 0.4, 1.0702618278515 5, 0.5, 1.1064721930091 6, 0.6, 1.1487574048412 7, 0.7, 1.1965393519472 8, 0.8, 1.2492949820443 9, 0.9, 1.3065510627128
JSFH TTdSMApJNlJUQUJMRV9TQVZFLzI0ODM5NDM4NFgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIioiKiQiIiIhIiIkIiIjRikkIiIkRikkIiIlRikkIiImRikkIiInRikkIiIoRikkIiIpRikkIiIqRik2Ig==TTdSMApJNlJUQUJMRV9TQVZFLzI0ODM5NDM4NFgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIioiKiQiIiIhIiIkIiIjRikkIiIkRikkIiIlRikkIiImRikkIiInRikkIiIoRikkIiIpRikkIiIqRik2Ig==TTdSMApJNlJUQUJMRV9TQVZFLzI0ODczMjQ3NlgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIiMiIyQiIiQhIiIkIiIoRik2Ig==TTdSMApJNlJUQUJMRV9TQVZFLzI0ODczNjcxMlgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIioiKiQiIiIhIiIkIiIjRikkIiIkRikkIiIlRikkIiImRikkIiInRikkIiIoRikkIiIpRikkIiIqRik2Ig==TTdSMApJNlJUQUJMRV9TQVZFLzI0ODczNjcxMlgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIioiKiQiIiIhIiIkIiIjRikkIiIkRikkIiIlRikkIiImRikkIiInRikkIiIoRikkIiIpRikkIiIqRik2Ig==TTdSMApJNlJUQUJMRV9TQVZFLzI0ODc0MTQ4MFgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIioiKiQiIiIhIiIkIiIjRikkIiIkRikkIiIlRikkIiImRikkIiInRikkIiIoRikkIiIpRikkIiIqRik2Ig==TTdSMApJNlJUQUJMRV9TQVZFLzI0ODc0NTk2OFgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIjQiNCQiIiYhIiMkIiM1RikkIiM6RikkIiM/RikkIiNERikkIiNJRikkIiNORikkIiNTRikkIiNYRikkIiNdRikkIiNiRikkIiNnRikkIiNsRikkIiNxRikkIiN2RikkIiMhKUYpJCIjJilGKSQiIyEqRikkIiMmKkYpNiI=TTdSMApJNlJUQUJMRV9TQVZFLzI0ODc0NzU5MlgqJSlhbnl0aGluZ0c2IjYiW2dsISElISEhIjQiNCQiIiYhIiMkIiM1RikkIiM6RikkIiM/RikkIiNERikkIiNJRikkIiNORikkIiNTRikkIiNYRikkIiNdRikkIiNiRikkIiNnRikkIiNsRikkIiNxRikkIiN2RikkIiMhKUYpJCIjJilGKSQiIyEqRikkIiMmKkYpNiI=