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

R4.4.3

Problem Statement edit

Find   for n=4,7,11 such that:

  (1)

for x in [.9,3] with the initial conditions found i.e,  

Plot   for n=4,7,11 for x in [.9,3].

Solution edit

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:

 

Using the above code, we can solve for the coefficients and final y equation to be as shown below:

For n=4:

       (4.4.3.1)

For n=7:

      (4.4.3.2)

For n=11:

 
  (4.4.3.3)

Plot edit