User:Eml5526.s11.team3.hylon/Homework 2

=Problem2.9=

Problem Statement
Given $$\left\{ {{b}_{i}}(x)=\cos (ix+\phi ),i=0,1,2,\cdots ,n \right\}$$. $$1).$$ Find two equations that enforce boundary conditions for $${{u}^{h}}(x)=\sum\limits_{j=0}^{n}{{{d}_{j}}{{b}_{j}}(x)}$$. Natural boundary condition: $$-\frac{d{{u}^{h}}(x=0)}{dx}=4$$; essential boundary condition: $${{u}^{h}}(x=1)=0$$ . $$2).$$ Find one more equation to solve for $$\underline{d}=\left\{ {{d}_{j}} \right\} (j=0,1,2)$$by project the residue $$P({{u}^{h}})$$ on a basis function $${{b}_{k}}(x)$$ with $$k=0,1,2 $$, such that the additional equation is linear independent from the above two equations in $$(1)$$. $$3).$$ Display three equations in matrix form $$\underline{K}\underline{d}=\underline{F}$$, observe symmetric property of $$\underline{K}$$. $$4).$$ Solve for $$\underline{d}$$. $$5).$$ Construct $$u_{2}^{h}(x)$$ and plot $$u_{2}^{h}(x)$$ vs. $$u_{2}^ – (x)$$. $$6).$$Compute $$u_{2}^{h}(x=0.5)$$ and Error $${{e}_{2}}(x=0.5)=u(x=0.5)-{{u}^{h}}(x=0.5)$$. $$7).$$ Repeat $$1)-6)$$ for $$n=4,n=6$$. $$8).$$ Plot $${{e}_{2}}(x=0.5)$$ vs. $$n$$ Refer to lecture slide [[media:fe1.s11.mtg12.djvu|12-1]] for more information.

Solution
For $$n=2$$ : $$1).$$ Since $$\left\{ {{b}_{i}}(x)=\cos (ix+\phi ),i=0,1,2,\cdots ,n \right\}$$, then $${{b}_{0}}(x)=\cos (\phi ),{{b}_{1}}(x)=\cos (x+\phi ),{{b}_{2}}(x)=\cos (2x+\phi )$$. In order to make sure that $$b_{i}^{'}(x=0)\ne 0$$,we choose $$\phi =\frac{\pi }{4}$$. Hence we have From natural boundary condition: $$-\frac{d{{u}^{h}}(x=0)}{dx}=4$$, we can obtain Hence we have

From essential boundary condition: $${{u}^{h}}(x=1)=0$$, we can have We also have Hence we can get the second equation, that

$$2).$$ Projecting the residue $$P({{u}^{h}})$$ on the $${{b}_{i}}(x)$$,$$i=0,1,2$$, we have For static form, we know that $$P({{u}^{h}})=\frac{\partial }{\partial x}[{{a}_{2}}(x)\frac{\partial {{u}^{h}}}{\partial x}]+f(x)$$. And it’s already given that $${{a}_{2}}(x)=2, f(x)=3$$. Thus, So we can get one more equation

$$3).$$ Till now, we obtain three equations as follow: Display them in matrix form, yields

Hence,

non-symmetric. $$4).$$ Using Matlab, we can easily get

$$5).$$

Since $$2\frac{{{\partial }^{2}}u}{\partial {{x}^{2}}}+3=0$$, $$u(x=1)=0$$ and $${{u}^{'}}(x=0)=-4$$, we can obtain

Plot

Matlab Code: $$6).$$ We have already got $$u_{2}^{h}(x)=3.803\cos (\frac{\pi }{4})-0.1495\cos (x+\frac{\pi }{4})+2.9032\cos (2x+\frac{\pi }{4})$$ and $$u(x)=-\frac{3}{4}{{x}^{2}}-4x+\frac{19}{4}$$. Hence

For $$n=4$$ : $$1).$$ We also choose $$\phi =\frac{\pi }{4}$$ here. Since $$\left\{ {{b}_{i}}(x)=\cos (ix+\phi ),i=0,1,2,\cdots ,n \right\}$$, then Hence we have

From natural boundary condition:$$ -\frac{d{{u}^{h}}(x=0)}{dx}=4$$, we can obtain

Hence, we have

From essential boundary condition: $${{u}^{h}}(x=1)=0$$, we can have We get that Hence we can get the second equation, that

$$2).$$ Projecting the residue $$P({{u}^{h}})$$ on the $${{b}_{i}}(x)$$,$$i=0,1,2,3,4$$, we have $$\int\limits_{0}^{1}{{{b}_{i}}(x)P({{u}^{h}})}dx=0$$. For static form, we know that $$P({{u}^{h}})=\frac{\partial }{\partial x}[{{a}_{2}}(x)\frac{\partial {{u}^{h}}}{\partial x}]+f(x)$$. And it’s already given that $${{a}_{2}}(x)=2,f(x)=3$$. Thus, $$\int\limits_{0}^{1}{{{b}_{i}}(x)\{\frac{\partial }{\partial x}[{{a}_{2}}(x)\frac{\partial {{u}^{h}}}{\partial x}]+f(x)}\}dx=\int\limits_{0}^{1}{{{b}_{i}}(x)[2{{d}_{j}}{{b}_{j}}^{(2)}(x)+3}]dx=0$$. We can have three more equations here,

$$3).$$ Till now, we obtain five equations as follow: Display them in matrix form, yields

Hence,

non-symmetric. $$4).$$ Using Matlab, we can easily get

$$5).$$

We have already obtained

Plot

Matlab Code: $$6).$$ We have already got $$u_{4}^{h}(x)=14.1214\cos (\frac{\pi }{4})-22.8534\cos (x+\frac{\pi }{4})+26.5637\cos (2x+\frac{\pi }{4})-12.2778\cos (3x+\frac{\pi }{4})+3.0541\cos (4x+\frac{\pi }{4})$$ and $$u(x)=-\frac{3}{4}{{x}^{2}}-4x+\frac{19}{4}$$. Hence

For $$n=6$$ : $$1).$$ We also choose $$\phi =\frac{\pi }{4}$$ here. Since $$\left\{ {{b}_{i}}(x)=\cos (ix+\phi ),i=0,1,2,\cdots ,n \right\}$$, then

Hence we have From natural boundary condition: $$-\frac{d{{u}^{h}}(x=0)}{dx}=4$$, we can obtain

Hence, we have

From essential boundary condition: $${{u}^{h}}(x=1)=0$$, we can have

We get that

Hence we can get the second equation, that

$$2).$$ Projecting the residue $$P({{u}^{h}})$$ on the $${{b}_{i}}(x)$$,$$i=0,1,2,3,4,5,6$$, we have For static form, we know that $$P({{u}^{h}})=\frac{\partial }{\partial x}[{{a}_{2}}(x)\frac{\partial {{u}^{h}}}{\partial x}]+f(x)$$. And it’s already given that $${{a}_{2}}(x)=2,f(x)=3$$. Thus,

We can have five more equations here,

$$3).$$ Till now, we obtain seven equations as follow:

Display them in matrix form, yields

Hence,

is non-symmetric. $$4).$$ Using Matlab, we can easily get

$$5).$$

We have already obtained

Plot

Matlab Code: $$6).$$ We have already got $$u_{6}^{h}(x)=0.6678\cos (\frac{\pi }{4})+5.2048\cos (x+\frac{\pi }{4})+6.9757\cos (2x+\frac{\pi }{4})-10.7753\cos (3x+\frac{\pi }{4})+7.5430\cos (4x+\frac{\pi }{4})-2.2711\cos (5x+\frac{\pi }{4})+0.0017\cos (6x+\frac{\pi }{4}) $$ and $$u(x)=-\frac{3}{4}{{x}^{2}}-4x+\frac{19}{4}$$. Hence

Plot $${{e}_{n}}(x=0.5)$$ vs. $$n$$:

Problem solved by Hailong Chen.

Reference
All matrix operations and integrations are solved by Matlab.