University of Florida/Egm4313/s12.team8.dupre/R4.4.3: Difference between revisions

From testwiki
Jump to navigation Jump to search
imported>MaintenanceBot
m Replace deprecated <source> with <syntaxhighlight>
 
(No difference)

Latest revision as of 03:47, 24 September 2020

Template:Big3

Problem Statement

Find yn(x) for n=4,7,11 such that:

y'n+ay'n+byn=rn(x) (1)

for x in [.9,3] with the initial conditions found i.e, yn(x1),y'n(x1).

Plot yn(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:

yn(x1)=22.153,y'n(x1)=55.9732

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

For n=4:

yn(x)=8.9210ex5.6353e2x0.125x40.583x32.125x24.125x14.0625      (4.4.3.1)

For n=7:

yn(x)=615.0725ex3.3884e2x+0.07143x7+0.6666x6+4.6x5+24.375x4+100.4166x3+305.375x2+615.375x+617.6875     (4.4.3.2)

For n=11:

yn(x)=3301815ex+734.893e2x+0.04545x11+0.7x10+8.0556x9+
77.1875x8+636.3214x7+4520x6+27318x5+137082x4+549316x3+1649429x2+3300389x+3301079 (4.4.3.3)

Plot

File:Egm4313.s12.team8.dupre.r4.4.3.png

Template:CourseCat