Diference between numerical and analitical sollution (Matlab)

mat_ziv

New member
Joined
Jun 15, 2019
Messages
1
Hello All,

I am new on this forum.

I am trying to solve the following first order ODE:

dy/dt=(w*i-const_G)*y + 2*exp(w*t*i)

Analitacly, the result should have a form Y*exp(w*t*i). When I put it in to the equation I am getting:

Y*exp(w*t*i)*w*i=(w*i-const_G)*Y*exp(w*t*i) + 2*exp(w*t*i)

Now deviding with exp(w*t*i), I am getting:

Y*w*i=(w*i-const_G)*Y + 2

Now Y is:

Y=2/const_G

The solution is y(t)=2/const_G * exp(w*t*i). Which meens that the amplitude is reduced by const_G, the frequency is the same.

Using MATLAB to solve this equation and to get a graph, I have become confused.

This is the function in MATLAB:
------------------------------------------------------------------------------------
function result = mode_decay(inputs)
time=inputs(1);
frequency = inputs(2);
const_G=inputs(3);
y_re=inputs(4);
y_im=inputs(5);

y=y_re+y_im*1i;

input = 2*exp(2*pi*frequency*time*1i);
dydt=(2*pi*frequency*1i-const_G)*y + input;

result = [input; dydt];

end
------------------------------------------------------------------------------------
On the image you can see the simulation and resulting graph.

simulation.png

I am confised, how am I getting this amplitude rising graph. From where it comes.

Any advice will be very helpful for me.

Thanks in advance
 
First, the word is "analytically".

You have the differential equation dy/dt=(w*i-const_G)*y + 2*exp(w*t*i)
The associated homogenous equation is dy/dt= (wi- const_G)y so dy/y= (wi- const_G)dt. Integrating \(\displaystyle ln(y)= (wi- const_G)t+ C\). Taking the exponential of both sides, \(\displaystyle y(t)= C'exp(wi- const_G)t)\) where \(\displaystyle C'= e^C\) is still an undetermined constant.

For a solution to the entire problem, since the "non-homogeneous" part, 2exp(wit), is an exponential, we try y(t)= Aexp(wit). Then y'= Awi exp(wit). The equation becomes Awi exp(wit)= (wi- const_G)Aexp(wit)- 2exp(wit). We can divide through by exp(wit) leaving Awi= (wi- const_G)A- 2. const_G A= -2 so A= -2/const_G.

y(t)= C'exp(wi- const_G)t)- (2/const_G)exp(wit).

That does not appear to be what you got for your analytical solution.
 
Top