Fourth Block – Laplace Transforms

December 17, 2008

Part 1

The differential equations below were solved using Laplace transforms.

(A) \frac{dy}{dt} +y =e^{-t}

(B) \frac{dy}{dt} + y = cos(x)

(C) \frac{d^2y}{dt^2} + 4 \frac{dy}{dt} + 4y = 0

(D) \frac{d^2y}{dt^2} - 2 \frac{dy}{dt} + 5x =0

A benefit of the Laplace (s) domain is that it reduces calculus into algebra. For example integration in the Laplace domain is simply dividing by s and inversely differentiation is multiplying by s. The properties \mathscr{L} [ \frac{dy}{dt} ] =s \mathscr{L} [y] -y(0) and \mathscr{L} [ \frac{d^2y}{dt^2} ] = s^2 \mathscr{L} [y] - s y(0) - y(0) prove to be instrumental in solving differential equations.

1(A)

Start by applying the Laplace operation across the equation:

\mathscr{L} [ \frac{dy}{dt} ] + \mathscr{L} [y] =\mathscr{L} [ e^-t]

Convert known functions(e^{-t} ) to the Laplace domain and eliminate any differentials.

s \mathscr{L} [y] - y(0) + \mathscr{L} [y] = \frac{1}{(s + 1)}

Use algebra to Solve for \mathscr{L} [y] .

\mathscr{L} [y] = \frac{1}{(s + 1)^2} + \frac{y(0)}{(s + 1)}

From this point MATLAB’s ilaplace can be used to give the general solution.

syms A s t (defines symbols in equation) let y(0)=A

ilaplace(1/(s+1)^2 + A/(s+1),s,t)

ans= t e^{-t} + A e^{-t}

The solution can then be graphed by giving value to the initial condition

laplace1a

The given initial conditionson are 3 in the red, 1 in green, 0.5 in blue.

1(B)

This equation was solved using the same method as 1(A). After the algebra the following equation was obtained.

\mathscr{L} [y] = \frac{s}{(s^2 + 1)(s+1)} + \frac{A}{(s+1)}

This equation was then solved using the ilaplace in MATLAB to get the general solution.

\frac{cos(t)}{2} +\frac{sin(t)}{2} + (A - \frac{1}{2} ) e^{-t}

Graphing the solution for initial values of 5, 10,and 15 produces the graph below.

laplace1b

1(C)

The same approach can be used for C resulting in.

\mathscr {L} [y] = \frac{A(s+4)}{(s+2)^2}

solved with MATLAB’s ilaplace gives.

A e^{-2t} + 2At e^{-2t}

The graph was produce with initial values of 5, 10, and 15.

laplace1c

1(D)

The same method was again used for D, the algebra produced the following.

\mathscr {L} [y] = \frac{A(s+3)}{(s^2+2s+5)}

Solving with MATLAB’s ilaplace gives.

A e^{t} (cos(2t) + 2sin(2t))

Graphing with initial values of 5, 10, and 15 give the following graph.

laplace1d

Part 2

This section of the forth block involved exploration of solutions for the differential equation used to model forced undamped motion. 

Equation: \frac{d^2y}{dt^2} + \omega_0^2 y = F sin( \omega t + \beta)

The same approach from part one was applied to this equation. the general solution is:

\frac{ \omega_0 (sin( \omega_0 t)(F \omega cos( \beta) + A( \omega_o^2 - \omega^2)) + cos( \omega_0 t)(F sin( \beta) + A( \omega_0^2 - \omega^2)) - F(sin( \beta) cos( \omega t) + cos( \beta) sin( \omega t)))}{ \omega_0 ( \omega^2 - \omega_0^2)}

 

The graph below was generated with \omega \approx \omega_0

undamped

The graph shows an explosion over time as the amplitude of the wave continually grows. Interestingly enough the case were \omega \approx \omega_0 is one the conditions needed for harmonic structural failure in the physical world.  Everything on the earth vibrates with a specific frequency. When a force with the same frequency with suficient magnitude and enough time the object will be destroyed. One famous case is the Oprah singer who breaks a crystal glass. this is possible because of the matched frequencies of the voice and the glass. This phenomena also forced the Roman Legions to cease marching and walk across bridges.

Another case found in the physical world is \omega_0 greater than \omega . As shown in the graph below this case produces a repeating harmonic motion.undamped_3w_wo

This is common in automobiles because of the harmonic motion of the vehicle and the motion of the drive train.

Part3

This section was using Laplace transforms to solve the differential equation for KCL in a closed loop. 

Equation: \frac{d^2i}{dt^2} + \frac{R}{L} \frac{di}{dt} + \frac{1}{CL} i = \frac{F \omega}{L} cos( \omega + \beta)

The solution was solved using the same method but because of the solutions length it makes it irrational to print out. This is the approximately the MATLAB code used to obtain the graph below (note the general solution has been altered to fit and the element by element operators have been removed)

t=0:.0001:.01;

R=100;

L=.1;

C=1e-6;

w=1000;

F=1;

A=1;

solution=F/(R^2*C^2*w^2+w^4*L^2*C^2-2*w^2*L*C+1)*(R*C^2*sin(w*t)
 *w^2+((-R^2*C+4*L)^2*(-w^2*L*C+1)*cos(w*t)*C+(C*(w^2*L*C-1)
 *cosh(1/2*t/L/C*(C*(R^2*C-4*L))^(1/2))*(-R^2*C+4*L)^2-R*(C*(R^2*C-4*L))^(3/2)
 *sinh(1/2*t/L/C*(C*(R^2*C-4*L))^(1/2))*(1+w^2*L*C))*exp(-1/2*t/L*R))/(-R^2*C+4*L)^2*w)
 +exp(-1/2*t/L*R)*(A*cosh(1/2*t/L/C*(C*(R^2*C-4*L))^(1/2))+1/(-R^2*C+4*L)*(C*(R^2*C-4*L))^(1/2)
 *sinh(1/2*t/L/C*(C*(R^2*C-4*L))^(1/2))*(A*R-2*R-2*L));

plot(t,solution)

grid
title(‘KCL Closed Loop’)

xlabel(‘t’)
ylabel(‘y’)

kcl

The decay of the current is due to the energy storage units (the inductor and capacitor). As the capacitor charges it begins to act as an open circuit and effectively halts current flow.

Third Block

November 14, 2008

 The differential equations \frac{dx}{dt} = ax+by and \frac{dy}{dt} = cx+dy and the associated linear function T[(x,y)]=(ax + by , cx + dy) which is commonly expressed in the form below:

 \left( \begin{array}{cc} a & b \\ c & d \end{array} \right) \left( \begin{array}{c} x \\ y \end{array} \right) = \left( \begin{array}{c} ax + by \\ cx + dy \end{array} \right) 

The constants a,b,c, and d were given values from -5 to 5 and the vector fields were generated.  From these fields we discovered that there were typically appeared to be two lines which the vectors on the line all had the same unit vector but with varying magnitudes.  It was determined to find these lines the equations ax+by=\lambdax and cx+dy=\lambday would need to be solved.  Using substitution the quadratic (\lambda-a)(\lambda-d)-bc was obtained.  Solving this quadratic gives the eigan values.  These values are then plugged back into the linear equation obtained from rearranging the the equation ax+by=\lambdax into y=\frac{\left(\lambda -a \right)}{b} x The vector fields with the invariant line below were produced with matlab.  The solutions of the differential equations follow the vector fields nicely.  All solution curves below were produced using the HPG System solver from Blanchard, Deveney, Hall Differential Equations. 

 

saddle-0-1-1-0

saddle

The first case encountered was the saddle.  This occurs when there are two real roots to the quadratic (\lambda - a)(\lambda - d) - bc The values of the constants were: a=0, b=1, c=1, d=0

The the eigan values were -1 and 1.

The solution curves show a convergence to the invariant line going from quadrant three to quadrant one.

 

 

 sink2

sink1

The sink is produced when the eigan values are both negative real numbers.  It is apparent that the solution comes to rest at the origin where the two invariant lines cross.  The values of the constants were: a=-1, b=-1, c=-1, d=-2.

  The eigan values were: -2.6180 and -0.3820

 

 source1

source

  The source is achieved by having two positive real  eigan values.  The solution cures are emanating from the origin.  This is a complete opposite to the sink.  The values of the constants were: a=1, b=1, c=1, d=2.

The eigan values were:     0.3820 and 2.6180

spiral-in-0-1-1-1

spiral-in

The inward spiral is produced with constants that will give a negative real value with an imaginary value and its conjugates eigan values.  The solutions all spiral into the origin.  The values of the constants were: a=0, b=-1, c=1, d=-1.

 The eigan values were: -0.5000 + 0.8660i and -0.5000 – 0.8660i

 

spiral-out-0-1-1-1

spiral-out

The spiral out is the same as the spiral in but negated.  The eigan values mus be positive real values with an imaginary value and is conjugate.  The values of the constants were:  a=0, b=1, c=-1, d=1.

The eigan values were: 0.5000 + 0.8660i and 0.5000 – 0.8660i

center-0-1-1-0

The circle occurs when the eigan values are strictly imaginary.  The solutions are  when given different initial values form concentric circles. The values of the constants were:  a=0, b=-1, c=1, d=0.

The eigan values were: 0 + 1.0000i and 0 – 1.0000i

single-line-2-2-2-2

Finally there was a case were only one invariant line was present.  Upon further inspection of this line there were not vectors along it but dots.  This would mean there is no change on this diagonal.  This occurred when a=c and b=d making the change in x and y identical.  Therefore when initial x and y values were equal (any point on the line y=x) there was no change.  the values of the constants were: a=-2, b=2, c=-2, d=2.

  The eigan values were: 0.0650 + 0.3140i and 0.0650 – 0.3140i

Second Three Week Project

October 10, 2008

In this post the following subjects will be examined.

  1. The efficiency of Euler’s method for first order differential equations.
  2. Euler’s method for Lorenz equations.
  3. Lotka-Volterra predator-prey equations.
  4. Rossler attractor.

The Efficiency of Euler’s Method for First Order Differential Equations

Euler’s method \frac{dy}{dx}\approx \frac{y(x+\Delta x) - y(x)}{ \Delta x} is a convenient way to approximate values.  The problem is the trade off between accuracy and range.  The \Delta x was .0001 in this example.  To get and idea of how accurate it is the percent error will be calculated for the differential equation \frac{dy}{dx} = -x(y+1) .  The following graphs were produced with Excel and MATLAB. 

The Euler approximation crosses zero roughly at 2.6 and the exact solution crosses at 2.25.  The percent error is then=\frac{2.25-2.6}{2.25} x 100 =15%.  This shows the limitations of Euler’s method.  Even with a relatively small \Delta x only an estimate can be attained.

Euler’s method for Lorenz equations

The Lorenz equations are:

\frac{dx}{dt}=\sigma(y-x)

\frac{dy}{dt}=x(\rho-z)-y

\frac{dz}{dt}=xy-\beta z

 No predictable effect could be determined with the varying of the constants.  Altering one as small as a single unit frequently changed the plots completely.  The following plots were generated in excel using the given values of \sigma =10, \beta = \frac{8}{3} and \rho = 28.

Lotka-Volterra preditor-prey equations

The Lotka-Volterra equations are:

\frac{dx}{dt} = x(\alpha -\beta y)

\frac{dy}{dt} = -y(\gamma -\delta x)

The equation model the population response of two species one the predator the other prey.  The constants \alpha, \beta, \gamma, and \delta represent prey’s growth, interaction, predator death, predator growth respectively.  MATLAB command ode45 was used to approximate the values.  Two     M-files were created pred_prey.m and pred_prey_plot.m.  Pred_prey_plot was then used to generate all the graphs below.

 MATLAB commands

pred_prey.m

function pred_prey=f(t,x)

pred_prey=zeros(2,1);

alpha=20;

beta=7;

gama=3;

delta=4;

pred_prey(1)=x(1)*(alpha-beta*x(2));

pred_prey(2)=-x(2)*(gama-delta*x(1));

pred_prey_plot.m

function pred_prey_plot(time)

[t,y]=ode45(‘pred_prey’,[0 time],[1;2]);

disp(‘press any key to continue …’)

plot(t,x)

grid

legend(‘Prey’,'Preditors’)

pause

plot(x(:,1),x(:,2))

xlabel(‘Prey’)

ylabel(‘Preditors’)

 

This graph was generated with small initial values and a small time range.  This allows for a good illustration of the harmonic fluctuation of the populations with the predator population reacting to increases and decreases of the prey.

This graph was generated over a large time range with a dominant \alpha.  This gave an increase to the amplitude of the harmonics or a larger climb in prey reproduction.  The change became more radical which can be seen in the rings of this graph.  The inner rings are from earlier calculations but as time passed the rings expanded reaching all extremes from predominantly prey to only predators to a minor population for both.

This graph was created over a large time range as well but the rings remain together.  This is because of a balance of the constants.  The value of \alpha, \beta, \gamma, and \delta was 70, 30, 40,and 20 respectively.  Something notable is that the prey never reach extinction which gives some validity to the model.

Setting the initial conditions proved to be less effective at changing the plot output.  Although their was an initial spike after a few cycles the output settled to its normal self.

Rossler Attractor

The Rossler Attractor is formed by the system of equations

\frac{dx}{dt} = -y-z

\frac{dy}{dt} = x+ay

\frac{dx}{dt} = b+z(x-c)

Two attractors were plotted the chaotic attractor and the common attractor.  The chaotic attractor as a and b values of .2 and a c value of 5.7.  The common attractor has a and b values of .1and a c value of 14.  The a and b values regulate the disk shape at the base of the attractor.  the c value regulates the raised portion of the attractor. 

Chaotic Attractor

The chaotic attractor has a smaller disk in the x-y plane and a lower but more frequently active z axis height.

Common Attractor

The larger disk and less frequent but higher z axis height can be seen in the common attractor.

Graphs were produced using MATLAB.  The M-file euler_system was provided and the M-file attractor.m was created.  In the workspace a three element column vector y_int with rand() as values for each element was the created.  Then euler_system was executed.

MATLAB Commands

atractor.m

function yprime = attractor(t,y)

yprime=[-y(2)-y(3);y(1)+.1*y(2);.1+y(3)*(y(1)-14)];

euler_system.m

function [ t, y ] = euler_system( f, t_range, y_initial, nstep)

t(1) = t_range(1);

dt = ( t_range(2) – t_range(1) ) / nstep;

y(:,1) = y_initial;

for i = 1 : nstep
t(i+1) = t(i) + dt;
y(:,i+1) = y(:,i) + dt * feval ( f, t(i), y(:,i) );
end

plot(t,y)

plot3(y(1,:),y(2,:),y(3,:))

 

 

 

Differential Equation Solution

September 19, 2008

The differential equation \frac{dy}{dx} = -x(y+1) was solved three ways. First a direction field was produced, then Euler’s method, finally a solution was found using MATLAB’s dsolve.

DIRECTION FIELD

The direction field is produced buy calculating the slopes at numerous points in a coordinate plane and plotting them. MATLAB was used to calculate and plot these slope vectors. using the mesh grid feature allowed me to pick the boundaries and intervals of the plane. Next all the slopes are calculated and stored in a function array. To create a more legible graph the vectors are scaled to the same magnitude. this is accomplished by dividing the function array buy its magnitude \Vert(1,s)\Vert = \sqrt{1+s^2}. The quiver command then plots the graph below. This gives a good overall picture of equations flow.

Direction Field for \frac{dy}{dx} = -x(y+1)

EULER’S METHOD

Euler’s method is \frac{dy}{dx}\approx \frac{y(x+\Delta x) - y(x)}{ \Delta x} which can be solved for y(x+\Delta x). This produces y(x+\Delta x)\approx y(x) + \Delta x \frac{dy}{dx}. Using x = 0, \Delta x = 0.0001 and y(x) = 11 Excel computed y(x+\Delta x) and the results produced the following graph. unfortunately a greater \Delta x wil produre greater error but a smaller \Delta x will give a shorter range. Nevertheless euler’s method is a good estimation tool.

MATLAB TO SOLVE

Matlab is an extremely handy tool to solve differrential eqations. First you must pick a starting number for y(x), y(0) = 10 for example. Then set a variable equal to the dsolve comand to create a solution array.

solution = dsolve(‘Dy=-x*(y+1)’,'y(o)=10′,’x')

This will return solution = -1 + 11{\it e}^{-\frac{1}{2}x^2}

Now use the ezplot comand to gragh solution, the numbers in the brackets set the range for the graph.

ezplot(solution,[0,5])

Euler’s method graph

September 18, 2008

matlab comands and graph for -x(y+1)

September 12, 2008

solution = dsolve(‘Dy=-x*(y+1)’,'y(0)=10′,’x')

ezplot(solution,[0,5])

Mesh Grid

 

 

 

 

 

 

 

 

 

>> [x,y]=meshgrid(-5:.5:5,-5:.5:5);
>> s=-x.*(y+1);
>> l=sqrt(1+s.^2);
>> quiver(x,y,1./l,s./l,.5), axis tight

September 9, 2008

I an working on the differential equation \frac{dy}{dx} = -x(y+1)


Follow

Get every new post delivered to your Inbox.