Posted by: stocky2345 | December 18, 2008

Laplace Transforms

In this fourth block we had  solved four diffrent types of laplace transforms.  Laplace transforms are used to to solve certian diferential equations when the initial condition is zero. laplace transforms are also used in circiut analysis.

The laplace transforms that we had to preform are:

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

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

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

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

1)       The first laplace transform that I had atempted was  \frac{dy}{dt} +y =e^{-t}.  The first step I did was to convert the diferential equation wqas to take the laplace of each part \mathscr{L} [ \frac{dy}{dt} ] + \mathscr{L} [y] =\mathscr{L} [ e^-t].

What this step does is it allows me to algibraically solve the equation.  \frac{dy}{dt} +y =e^{-t} .

next I am going to preform the laplace transfomation to solve the problem.

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

Now that the laplace transformation is done you can solve the problem algibraically and you will get:

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

Once you have done the laplace transform and you have solved the equation algibraically you can simply put the answer into matlab and do ilaplace to convert it back to laplace. ilaplace is the inverse of laplace. When you do this you should get  t e^{-t} + A e^{-t}.

Also make sure  you let Y(0) be A and that you type syms A s t. This tells mat labe that A is just a symbol. When I first tryed to complete this step I couldn’t figure out why i was getting a error message when i was typing it the exact same way that the book was.

When completeing the graphs I had got together with adam because he knows how to use mat lab a lot better that I do. When graphing \frac{dy}{dt} +y =e^{-t} you need to plug in multiple numbers for the initial conditions y(0) . We had used 3 which is the red line, 1 which is the green line green and 0.5 for the blue line.

Pic 1  solution for 1A:

laplace1a

The second equation is  \frac{dy}{dt} + y = cos(x). I had completed this problem the same way that I did the first problem.

When I was done with completeing the laplace trans form and the algabra I was left with : \mathscr{L} [y] = \frac{s}{(s^2 + 1)(s+1)} + \frac{A}{(s+1)}.

To find the inverse of this i had done ilaplace in mat lab again and I had gotten:

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

Plug in 5, 10,and 15 for values for Y(0).

pic 2 solutions for 1B:

laplace1b

The third equation is  \frac{d^2y}{dt^2} + 4 \frac{dy}{dt} + 4y = 0. I had preformed the same step as in the first two equations. After completing the laplace transform and all of the algabra I was left with:

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

After doing the ilaplace in matlab we get:

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

Plug in 5, 10,and 15 for values for Y(0).

pic 3 solutions for 1C:

laplace1c

The fourth equatiion is  \frac{d^2y}{dt^2} - 2 \frac{dy}{dt} + 5x =0. Once again I had completed the same steps as the previous problem for the fourth equation \frac{d^2y}{dt^2} - 2 \frac{dy}{dt} + 5x =0. After completing the following steps i was left with:

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

Next i will have to do the the ilaplace  with mat lab for

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

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

Plug in 5, 10,and 15 for values for Y(0).

pic 4 solutions for 1D:

laplace1d

2)     In the second question we were to explore forced undamped motion with the eqation: \frac{d^2y}{dt^2} + \omega_0^2 y = F sin( \omega t + \beta).  Using the laplace transform like in the previous problems. After doing the laplace transform and all of the algabra plus the ilaplace in matlab we are left with the following equation:

\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)}

If you graph the following equation with \omega \approx \omega_0 you will notice that the wave will start off small and end up larger. What this means is that the frequecy is growing ggradually of a period of time. for an example if you make a high pitch nose and contiue at the same pitch but hold it for a longer period of time the frequency will become so great that it could break a crystal glass. the reason is that the magnitude of the frequency became much greater than the crystal glass causing it to shader as you can notice from the graph below.

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

Pic 5 undamped motion:

undamped

As you can notice it has started off small at 0 and ends up large at 12.

Now if you make \omega_0 greater than \omega you will notice that the wave is not increasing over a period of time but instead repeat itself over a period of time.

Pic 6 undamped motion:

undamped_3w_wo

3)    In this next section we were to use laplace transforms to solve the following equation\frac{d^2i}{dt^2} + \frac{R}{L} \frac{di}{dt} + \frac{1}{CL} i = \frac{F \omega}{L} cos( \omega + \beta) using KCL in a closed loop. KCL stands for kircoffs current laws.  I had did the same steps as in the previous problems and using matlab we were able to get a solution for  \frac{d^2i}{dt^2} + \frac{R}{L} \frac{di}{dt} + \frac{1}{CL} i = \frac{F \omega}{L} cos( \omega + \beta). Also to do the KCL in a closed loop I had to define values for the resistance, inductor, and capacitor.

The values are:

R=100 ohms

L=.1 herrys

C=1micro farrid

Using matlab we get :

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’)

Pic 7 for KCL in a closed loop:

kcl

The decrease of the current is from to the energy being affected by the  inductor and capacitor. As the capacitor charges it tends to act as an open circuit andthe inductor is slowing down the capacitor charge rate  effectivelycausing the current to stop flowing through the circiut as you can see in the picture above. In the begining the current is moving steadly as it passes through the inductor and charges the capacitor it is slowly decreasing over time as you can see from the graph above.

Posted by: stocky2345 | December 9, 2008

Systems of linear differential equations

Systems of linear differential equations:

The diferential equation  \frac{dx}{dt} = ax+by and \frac{dy}{dt} = cx+dy can also be expressed as a linear function  T[(x,y)]=(ax + by , cx + dy).

As you can see ffrom the above equations as time t changes the solutions change acording to time t. In this three week block we had payed a lot of attention to vector fields and to explore every possible vector of the system of linear differential equations.

Using matlab  you can come up with some code that will allow to to visually see the vector fields and how the are reacting for that particular equation. In this three week block we have a wide veriaty of combinations of vector fields. Some of the vectors flow away from the orgin, some flow towards the orgin , and a combination of both.

pic1: 

Saddle: This only happens when you are to have two real roots of the equation.

pic-2

If you look at the picture cosely you will notice that the arrows are flowing to the upper right hand conner and to the lower left hand coner. there is one positve and one negitive eigen values in this picture. You can also notice that the arrows are being repelled from the center.

Eigen Values for pic 1 are:

The Eigenvalues are -1 and 5. The eigenvectors are (1,-2) and (1,1).

The two lines are at 3x+2y and 4x+y.

 

pic 2

Sink: this only occurs when both of the eigen values are negative real number.

pic-310

If you look at the picture closly you will notice that all of the arrows are flowing towards the center. This is known as the sink because in a sink all of the water flows towards the center.

sink2

Eigen Values for pic 2 are:

The Eigenvalues  are (-3+ (5^1/2)/2) and (-3-(5^1/2)/2). The Eigenvectors are (1, (-3+(5^1/2)/2) and (1, (-3-(5^1/2)/2).

The equation of the line is (-x)-3y.

 

pic 3

Source: This occurs when you have two positive real eigen values.

pic-1

 

As you can see the arrows are flowing away from the center or the orgin this is known as the source. Think of it like a battery the voltage flows away from it.

 source1

 

Eigen Values for pic 3 are:

The Eigen values are: 1 and 4. The Eigenvectors are (-2, 1) and (1, 1).

The equation of the line is: 2x + 2y and x + 3y.

 

Pic 4

Inward Spiral: This is produced by having two negative real numbers with (i) imaginary values and you also need to have consecutive Eigen valuses.

 pic-75

By looking at the picture you can notice that all of the arrows are spining in the right dirrection. this is known as a spral. Thats not all though if you look closly you will also notice that all the arrows are flowing inward like the sink. This is why it is called the inward spiral.

 pic-510

 The Eigen Values for Pic 4 are:

The Eigen values are -(1/2) (+/-) ((3^1/2)/2)i.

the equation of the line is yand -x-y.

 

 

Pic 5

Spiral Outward: Is the same as the spiral inward but it has positive real numbers with (i) imaginary values and you also need to have consecutive Eigen valuses.

pic115

By looking at this picture you can tell that the arrows are now flowing in an outward direction hence the term spiral outward, considering that it is spiraling at the same time.

pic1110

 The Eigen values for Pic 5 are:

The eigen values are(1 (+/-) 2i).

The equation of the line is x+2y and -2x+y

 

Pic 6

Circle: This occurs when the eigen values are (i) imaginary and has no real numbers.

pic-65

When looking at this pic you should notice that all of the arrows moving in the same direction and that each row creats a circle.

pic-615

The Eigen values for Pic 6 are:

The eigen valuea are (+/-)(2^(1/2))i.

The equation of the line is y and -2x

When doing this prodject i had noticed that by changing the ration you can get a close image of the vector field and you can get a distant image of the vector field. this is good because it allows you to see what is truely happening. Also when putting my prodject together i had noticed that addam had a few good pics that had showed what the arrows was doing so i had used them to hepl describe what the vector fields were doing in the first few pictures.

Posted by: stocky2345 | October 21, 2008

Lorenz Equations

In my second three week block of differential equations we did the following:

1. Euler’s method for lorenz equation with excel.

2. Euler’s method for Lorenz equations using matlab.

3.Rossler attractor.

Lorenz equations

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

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

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

Euler’s Method

Euler’s method \frac{dy}{dx}\approx \frac{y(x+\Delta x) - y(x)}{ \Delta x} is verry usefull tool for creating a quick graph of a lorenz equation. There is only one problem with using Eulers method. When using Eulers method it doesnt give you an exact answer it can only give you an aproximation. When choosing your \Delta x you need to expriemment a little bit. if you choose your \Delta x to be to small your graph will be so tight to gether you cannot make out for what is going on. up. if you choose\Delta x to be to small you can only see a small section. I had chosen \Delta x to be .01you can see that the graphs are clear.

To plot the graphs we used \sigma =10, \beta = \frac{8}{3} and \rho = 28.

sigma: 10 t x(t) y(t) z(t)
rho: 28 0 0.383205 0.39771154 0.96382726
beta: 2.66666667 0.01 0.38465565 0.49733839 0.93964925
delta t: 0.01 0.02 0.39592392 0.59645417 0.91650498
0.03 0.41597695 0.69771967 0.89442635

Graphs:

Using excel I graphed X(t) vs Y(t), Y(t) vs Z(t), X(t) vs Z(t), and X(t) vs Y(t) vs Z(t)

Euler’s method for Lorenz equations using matlab.

When using matlab it is important to save your m files in the proper location. as i was saving my m file in matlab it was not reading the file when i went to exacute the file to produce a graph. What needed to be done was that the m files like euler_system.m needed to be saved in the student folder under matlabfor07. After finding one problem i quickly ran into another by not adding the .m after the file name. once i had fixed all of my problems i was able to produce the following graphs.

X(t), Y(t), Z(t)

Rossler Attractor

The Rossler Attractor is one of the most famous strange attractor. It was found by Otto Rossler while studying the oscillations in chemical reaction. Rossler came up with three formulas that could model a chemical reaction. “(http://library.thinkquest.org/26242/full/fm/fm27.html)”

The Rossler Attractor equations:

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

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

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

Using matlab I was able to create the rossler attractor. At first we were having a hard time creating the atractor because matlab for some reason it was loosing the comand line. to fix the problem i had to close out of matlab and oppen it again and it had seemed to work. after several trys and geting help from adam a class mate i was finally able to produce the rosline attractor.

Matlab :

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,:))

Rossler Attractor Graph:

Posted by: stocky2345 | September 22, 2008

diferential equation

The differential equation that I have been working on is \frac{dy}{dx}={-x}{(y+1)}.

The first step that I had taken was to use matlab to plot the diferential equation \frac{dy}{dx}={-x}{(y+1)} in doing so I had encountered some problems. One of theses problems was that i have never used matlab before. when using matlab you have to make sure that you type the exactly what you need and nothing else it is also case sensitive as well. For example I had typed <span style="color:#ff0000;">explot (sol1,[0 5]). </span><span style="color:#000000;">After I hit the enter key it gave me an undefined function or method. to fix this problem i had to switch the x with a z to make it<span style="color:#ff0000;"> ezplot (sol1,[0 5]). </span><span style="color:#000000;">the reason that I had chosen to plot the differential equationlatex \frac{dy}{dx}={-x}{(y+1)}$ first is because it wiould give me the expodential curve. to plot the curve i had to complete these following steps in matlab:

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

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

sol1 = -1+3/2*exp(-1/2*x^2)

ezplot(sol1 [0 5])

d12

 

euler’s method

euler’s method is  \frac{dy}{dx}\approx \frac{y(x+\Delta x) - y(x)}{ \Delta x} .  it is basically setting an initial condition and your delta t. m= dy/dt. you take the m and *delta t. once you have done that you can then take the old y and add it to the solution from the previous statement. That answer is your new y. you would do these steps several time to produce euler’s method. the smaller your delta t the smaller the range, the bigger the delta t the bigger the error. so you would want to pick a delta t that is not to big but also not to small. iIn excel write the equation y(x+\Delta x)=y(x) + \Delta x(-x(y+1)). I had chose x to be 0 and y to be 3.

 

As you can see uler’s aproximation was a good aproximation because if you were to compare it to the the graph that was created with matlab they are very simular to one another.

 

 

Mesh Grids are ude to determine the boundry points of the diferential equation \frac{dy}{dx}={-x}{(y+1)}. by looking at the diagram  you can see that there is a line at -1. From -5 to -1 the arrows are flowing away from the line at 0 they are flowing perpendicular with the line at -1. From 1 to 5 the arrows are converging back to the line at -1.

The code that i had used to produce the mesh grid is:

>> [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
 
 

 

 

 

Posted by: stocky2345 | September 4, 2008

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Categories

Follow

Get every new post delivered to your Inbox.