University of Florida/Egm4313/s12.team11.imponenti/R4.4

Part 3
Solved by Luca Imponenti

Find $$y_n(x)\!$$, for $$n=4,7,11\!$$ such that:
 * $$y_n''-3y_n'+2y_n=r_n(x)\!$$

for $$x\!$$ in $$[0.9,3]\!$$ with the initial conditions found.

Plot $$y_n(x)\!$$ for $$n=4,7,11\!$$ for $$x\!$$ in $$[0.9,3]\!$$.

Homogeneous Solution
The homogeneous case is shown below:
 * $$y''_h-3y'_h+2y_h=0\!$$

This equation has the following roots:

$$\lambda_1=1, \lambda_2=2\!$$

Which gives yields the homogeneous solution
 * $$y_h=c_1e^x+c_2e^{2x}\!$$

General Solution, n=4
Using the taylor series approximation from earlier with $$n=4\!$$ we have

$$r_4(x)=log(2)+\frac{(x-1)}{2ln(10)}-\frac{(x-1)^2}{8ln(10)}+\frac{(x-1)^3}{24ln(10)}-\frac{(x-1)^4}{64ln(10)}\!$$

We know the particular solution, $$y_{p4}(x)\!$$, ve will have this form:

$$y_{p4}(x)=a_4(x-1)^4+a_3(x-1)^3+a_2(x-1)^2+a_1(x-1)+a_0\!$$

taking the derivatives of this solution

$$y'_{p4}(x)=\frac{d}{dx}y_{p4}(x)=4a_4(x-1)^3+3a_3(x-1)^2+2a_2(x-1)+a_1\!$$

and

$$y''_{p4}(x)=\frac{d}{dx}y'_{p4}(x)=12a_4(x-1)^3+6a_3(x-1)^2+2a_2\!$$

Plugging the above equations into the original ODE yields the following matrix equation:


 * $$ \begin{bmatrix}

2 & 0 & 0 & 0 & 0\\ -12 & 2 & 0 & 0 & 0\\ 12 & -9 & 2 & 0 & 0\\ 0 & 6 & -6 & 2 & 0\\ 0 & 0 & 2 & -3 & 2\end{bmatrix}* \begin{bmatrix} a_4 \\ a_3\\ a_2\\ a_1\\ a_0\end{bmatrix}= \begin{bmatrix} -\frac{1}{64ln(10)}\\ \frac{1}{24ln(10)}\\ -\frac{1}{8ln(10)}\\ \frac{1}{2ln(10)}\\ log(2)\end{bmatrix}\!$$

The unknown vector $$a\!$$ can be easily solved by forward substitution,the following values were calculated in matlab:

$$a_4=-.0034, a_3=-.0113, a_2=-.0577, a_1=-.1624, a_0=.1624\!$$

So the particular solution $$y_{p4}\!$$ is

$$y_{p4}=0.1624-0.1624*(x-1)-.0577*(x-1)^2-.0113*(x-1)^3-.0034*(x-1)^4\!$$

We can now find the general solution for n=4, $$y_4(x)\!$$.

$$y_4(x)=y_h(x)+y_{p4}(x)\!$$

$$y_4(x)=c_1e^x+c_2e^{2x}+0.1624-0.1624*(x-1)\!$$ $$-.0577*(x-1)^2-.0113*(x-1)^3-.0034*(x-1)^4\!$$

Solving using the initial conditions yields;

$$y_4(x)=.0595e^x-.0076e^{2x}+0.1624-0.1624*(x-1)\!$$ $$-.0577*(x-1)^2-.0113*(x-1)^3-.0034*(x-1)^4\!$$

General Solution, n=7
Using the taylor series approximation from earlier with $$n=7\!$$ we have

$$r_7(x)=log(2)+\frac{(x-1)}{2ln(10)}-\frac{(x-1)^2}{8ln(10)}+\frac{(x-1)^3}{24ln(10)}-\frac{(x-1)^4}{64ln(10)}+\frac{(x-1)^5}{160ln(10)}-\frac{(x-1)^6}{384ln(10)} +\frac{(x-1)^7}{896ln(10)}\!$$

In a similar fashion we construct a matrix equation for n=7:


 * $$ \begin{bmatrix}

2 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ -21 & 2 & 0 & 0 & 0 & 0 & 0 & 0\\ 42 & -18 & 2 & 0 & 0 & 0 & 0 & 0\\ 0 & 30 & -15 & 2 & 0 & 0 & 0 & 0\\ 0& 0 & 20 & -12 & 2 & 0 & 0 & 0\\ 0& 0 & 0 & 12 & -9 & 2 & 0 & 0\\ 0& 0 & 0 & 0 & 6 & -6 & 2 & 0\\ 0& 0 & 0 & 0 & 0 & 2 & -3 & 2\end{bmatrix}* \begin{bmatrix} a_7 \\ a_6 \\ a_5 \\ a_4 \\ a_3\\ a_2\\ a_1\\ a_0\end{bmatrix}= \begin{bmatrix} \frac{1}{896ln(10)}\\ -\frac{1}{384ln(10)}\\ \frac{1}{160ln(10)}\\ -\frac{1}{64ln(10)}\\ \frac{1}{24ln(10)}\\ -\frac{1}{8ln(10)}\\ \frac{1}{2ln(10)}\\ log(2)\end{bmatrix}\!$$

Solving:

$$a_7=.0002, a_6=.0020, a_5=.0141, a_4=.0725, a_3=.3034, a_2=.9029, a_1=1.9072, a_0=2.1084\!$$

So the particular solution $$y_{p7}\!$$ is

$$y_{p7}=2.1084+1.9072*(x-1)+.9029*(x-1)^2+.3034*(x-1)^3+.0725*(x-1)^4+.0141*(x-1)^5+.0020*(x-1)^6+.0002*(x-1)^7\!$$

We can now find the general solution for n=7, $$y_7(x)\!$$.

$$y_7(x)=y_h(x)+y_{p7}(x)\!$$

$$y_7(x)=c_1e^x+c_2e^{2x}+2.1084+1.9072*(x-1)+.9029*(x-1)^2+\!$$ $$.3034*(x-1)^3+.0725*(x-1)^4+.0141*(x-1)^5+.0020*(x-1)^6+.0002*(x-1)^7\!$$

Solving using our initial conditions yields

$$y_7(x)=-.7271e^x+.0233e^{2x}+2.1084+1.9072*(x-1)+\!$$ $$.9029*(x-1)^2+.3034*(x-1)^3+.0725*(x-1)^4+.0141*(x-1)^5+\!$$ $$.0020*(x-1)^6+.0002*(x-1)^7\!$$

General Solution, n=11
Using the taylor series approximation from earlier with $$n=11\!$$ we have

$$r_{11}(x)=log(2)+\frac{(x-1)}{2ln(10)}-\frac{(x-1)^2}{8ln(10)}+\frac{(x-1)^3}{24ln(10)}-\frac{(x-1)^4}{64ln(10)}+\frac{(x-1)^5}{160ln(10)}-\frac{(x-1)^6}{384ln(10)}+\!$$

$$\frac{(x-1)^7}{896ln(10)}-\frac{(x-1)^8}{2048ln(10)}+\frac{(x-1)^9}{4608ln(10)}-\frac{(x-1)^{10}}{10240ln(10)}+\frac{(x-1)^{11}}{22528ln(10)}\!$$

Finally, we write out the matrix equation for n=11:



$$A* \begin{bmatrix} a_{11}\\ a_{10}\\ a_9\\ a_8\\ a_7 \\ a_6 \\ a_5 \\ a_4 \\ a_3\\ a_2\\ a_1\\ a_0\end{bmatrix}= \begin{bmatrix} \frac{1}{22528ln(10)}\\ -\frac{1}{10240ln(10)}\\ \frac{1}{4608ln(10)}\\ -\frac{1}{2048ln(10)}\\ \frac{1}{896ln(10)}\\ -\frac{1}{384ln(10)}\\ \frac{1}{160ln(10)}\\ -\frac{1}{64ln(10)}\\ \frac{1}{24ln(10)}\\ -\frac{1}{8ln(10)}\\ \frac{1}{2ln(10)}\\ log(2)\end{bmatrix}\!$$

Solving the system in matlab:

$$a_{11}=0, a_{10}=.0002, a_9=.0019, a_8=.0181, a_7=.15, a_6=1.0675, a_5=6.4597,\!$$

$$a_4=32.4318, a_3=130.0033, a_2=390.3968, a_1=781.289, a_0=781.6873\!$$

So the particular solution $$y_{p11}\!$$ is

$$y_{p11}=781.6873+781.289*(x-1)+390.3968*(x-1)^2+130.0033*(x-1)^3+32.4318*(x-1)^4+\!$$

$$6.4597*(x-1)^5+1.0675*(x-1)^6+.15*(x-1)^7+.0181*(x-1)^8+.0019*(x-1)^9+.0002*(x-1)^{10}\!$$

We can now find the general solution for n=11, $$y_11(x)\!$$.

$$y_{11}(x)=y_h(x)+y_{p11}(x)\!$$

$$y_{11}(x)=c_1e^x+c_2e^{2x}+781.6873+781.289*(x-1)\!$$ $$+390.3968*(x-1)^2+130.0033*(x-1)^3+32.4318*(x-1)^4\!$$ $$6.4597*(x-1)^5+1.0675*(x-1)^6+.15*(x-1)^7+.0181*(x-1)^8+.0019*(x-1)^9+.0002*(x-1)^{10}\!$$

Solving using our initial conditions yields

$$y_{11}(x)=-287.5907e^x+.05e^{2x}+781.6873+781.289*(x-1)\!$$ $$+390.3968*(x-1)^2+130.0033*(x-1)^3+32.4318*(x-1)^4\!$$ $$6.4597*(x-1)^5+1.0675*(x-1)^6+\!$$ $$.15*(x-1)^7+.0181*(x-1)^8+.0019*(x-1)^9+.0002*(x-1)^{10}\!$$

Plot
$$y_4\!$$ shown in red

$$y_7\!$$ shown in blue

$$y_{11}\!$$ shown in green



Part 4
Solved by Luca Imponenti

Use the matlab command ode45 to integrate numerically $$y''-3y'+2y=r(x)\!$$ with $$r(x)=log(1+x)\!$$

and the initial conditions from Part 3 to obtain the numerical solution for y(x).

Plot y(x) in the same figure as above.

Matlab Solution
The numerical solution calculated using the matlab ode45 command is shown below:

ans = 0.2788   0.2854    0.2923    0.2997    0.3074    0.3229    0.3401    0.3592    0.3804    0.4040    0.4302    0.4595    0.4921    0.5285    0.5691    0.6145    0.6651    0.7218    0.7850    0.8557    0.9346    1.0228    1.1213    1.2313    1.3542    1.4914    1.6445    1.8155    2.0063    2.2193    2.4569    2.7219    3.0175    3.3471    3.7146    4.1243    4.5809    5.0898    5.6568    6.2885    6.9921    7.3442    7.7142    8.1032    8.5119

Plot
Plotting the aboved vector of y-values,along with the results from earlier yields the following graph:



where the answer calculated in matlab is shown in yellow.

Egm4313.s12.team11.imponenti (talk) 08:04, 14 March 2012 (UTC)