# University of Florida/Egm4313/s12.team8.dupre/R4.4.3

Jump to navigation Jump to search

R4.4.3

## Problem Statement

Find $\displaystyle y_{n}(x)$ for n=4,7,11 such that:

$\displaystyle y''_{n}+ay'_{n}+by_{n}=r_{n}(x)$ (1)

for x in [.9,3] with the initial conditions found i.e, $\displaystyle y_{n}(x_{1}),y'_{n}(x_{1}).$ Plot $\displaystyle y_{n}(x)$ for n=4,7,11 for x in [.9,3].

### Solution

Using a modified version of the Matlab code used in 4.4.1, shown here below, we can solve our coefficients for each y equation (at the specified n values):

```function [y, yp, c1, c2, c] = coeffs(n, x)
A = zeros(n+1);
a = -3;
b = 2;
d = zeros(n+1, 1);

x0 = 0.9;
y0 = -22.1530;
yp0 = -55.9732;

for i = 2:n+1
d(i) = (-1)^i/(i-1);
end

for i = 1:(n-1)
A(i,i) = b;
A(i,i+1) = i * a;
A(i,i+2) = i * (i+1);
end

A(n,n) = b;
A(n,n+1) = a * n;
A(n+1,n+1) = b;

%coefficients for particular solution
c = A \ d;
c = wrev(c); %reverse for use in polyval

%coefficients for general solution
c1 = (2* y0 - yp0 + polyval(polyder(c), x0) - 2 * polyval(c, x0)) / exp(x0);
c2 = (yp0 - y0 + polyval(c, x0) - polyval(polyder(c), x0)) / exp(2*(x0));

%generate y and y' matrices for given n
y = c1 * exp(x) + c2 * exp(2*x) + polyval(c, x);
yp = c1 * exp(x) + 2 * c2 * exp(2*x) + polyval(polyder(c), x);
```

Our previously solved initial conditions are:

$\displaystyle y_{n}(x_{1})=-22.153,y'_{n}(x_{1})=-55.9732$ Using the above code, we can solve for the coefficients and final y equation to be as shown below:

For n=4:

```$\displaystyle y_{n}(x)=8.9210e^{x}-5.6353e^{2x}-0.125x^{4}-0.583x^{3}-2.125x^{2}-4.125x^{1}-4.0625$ (4.4.3.1)
```

For n=7:

```$\displaystyle y_{n}(x)=-615.0725e^{x}-3.3884e^{2x}+0.07143x^{7}+0.6666x^{6}+4.6x^{5}+24.375x^{4}+100.4166x^{3}+305.375x^{2}+615.375x+617.6875$ (4.4.3.2)
```

For n=11:

```$\displaystyle y_{n}(x)=-3301815e^{x}+734.893e^{2x}+0.04545x^{11}+0.7x^{10}+8.0556x^{9}+\cdots$ $\displaystyle 77.1875x^{8}+636.3214x^{7}+4520x^{6}+27318x^{5}+137082x^{4}+549316x^{3}+1649429x^{2}+3300389x+3301079$ (4.4.3.3)
```