Solving ODEs with Forward Euler & Sampled Data Systems

  • Thread starter Thread starter adoprea
  • Start date Start date
  • Tags Tags
    Odes
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
6 replies · 2K views
adoprea
Messages
5
Reaction score
0

Homework Statement


Sampled Data system
Using the forward Euler integration algorithm, convert these differential equations to a set of difference equations. Use a stept size of deltaT = 0.1s.

Homework Equations


x1(dot) = x2
x2(dot) = x3
x3(dot) = -2x1-3x2-4x3
y = 7x1-5x2

The Attempt at a Solution


Nothing relevant! I have scribbled around and played with stuff from wikipedia, mainly with the form yn = yn-1+deltaT*f(tn-1, yn-1), but to no avail. Do I start with:
dy/dt = 7x1(dot)-5x2(dot) and so on? I end up in a loop as soon as iI get to the derivation of x3. IIt doesn't feel like I am on the right path.

What I am looking for is the starting point (so far). I learned about this stuff in school about 5 years ago, but I haven't touched it ever since. Now I wanted to do some reading on system modeling and I thought I could give a go to the exercises in the book as well. First attempt, first failure. Help!
 
Physics news on Phys.org
With forward euler you shouldn't end up in a loop: you use ##\vec x_n## to calculate ##\dot {\vec x}_n ## which you use to calculate ##\vec x_{n+1}##.

Y is just a calculated variable ##y(t) =y (\vec x(t))##. The differential equation is in ##\vec x##

note: to actually solve, you need initial conditions (so it's funny you should ask where to start :smile: because without them the problem statement is incomplete)

Can't resist:
Ever tried. Ever failed.
No matter. Try Again.
Fail again. Fail better.

Samuel Beckett​
 
Haha! yes, "fail better" seems to apply here.

There are no initial conditions. The book asks for a path to the solution, not actually solving the equations. But your post gave me the starting point I was looking for.

The frustration I experience when I look at something that I was able to solve some years ago is infinite. I hope I am not the only one in this situation.
 
adoprea said:
There are no initial conditions. The book asks for a path to the solution, not actually solving the equations.
The better !
The frustration I experience when I look at something that I was able to solve some years ago is infinite. I hope I am not the only one in this situation.
This is a third order system. I don't think many people can solve that offhand; I sure can't. At first I thought I saw a glimpse of the equations for a harmonic oscillator, but that didn't last long.

Frustration is a self-imposed handicap. Unlike most other handicaps, you can throw it off: it doesn't help at all. :smile: And often, once you throw it aside, you find that it wasn't necessary in the first place (you know, like breaking in a door that isn't locked...)

--
 
There are two rather different ways to solve a system like this. The simpler (at least the method I learned first) is to differentiate the last equation again:
[itex]x_3''= -2x_1'- 3x_2'- 4x_3'[/itex]. Replace the derivatives of [itex]x_1[/itex] and [itex]x_2[/itex] from the first two equations: [itex]x_3''= -2x_2- 3x_3- 4x_3'[/itex]. Differentiate again: [itex]x_3'''= -2x_2'- 3x_3'- 4x_3''[/itex] which is the same as the "third order linear differential equation with constant coefficients", [itex]x_3''+ 4x_3''+ 3x_3'+ 2x_3[/itex] which has characteristic equation [itex]r^3+ 4r^2+ 3r+ 2= 0[/itex]

Second, more "sophisticated" method: write this linear system as a matrix equation. We can write
[tex]\begin{bmatrix}x_1' \\ x_2' \\ x_3'\end{bmatrix}= \begin{bmatrix}0 & 1 & 0 \\ 0 & 0 & 1 \\ -2 & -3 & -4 \end{bmatrix}\begin{bmatrix}x_1 \\ x_2\\ x_3\end{bmatrix}[/tex]
Simplify that by finding the eigenvalues and corresponding eigenvectors for that three by three matrix.
 
adoprea said:
Haha! yes, "fail better" seems to apply here.

There are no initial conditions. The book asks for a path to the solution, not actually solving the equations. But your post gave me the starting point I was looking for.

The frustration I experience when I look at something that I was able to solve some years ago is infinite. I hope I am not the only one in this situation.

Do you remember how you used to do it? I bet you started with the assumptions that ##x_1 = A e^{rt}, x_2 = B e^{rt}, x_3 = C e^{rt}##, then substituted these into the DE's and turned the crank. Let's do that:
[tex]\begin{array}{ccl} \dot{x_1} = x_2 &\Rightarrow& r A = B \\<br /> \dot{x_2}= x_3 & \Rightarrow & r B = C \\<br /> \dot{x_3} = -2x_1-3x_2-4x_3 &\Rightarrow & r C = -2A - 3B - 4C<br /> \end{array}[/tex]
This implies
[tex]\pmatrix{r & -1 & 0 \\<br /> 0 & r & -1 \\<br /> 2 & 3 & r+4} \pmatrix{A\\B\\C\\} = \pmatrix{0\\0\\0}[/tex]
So, you need the determinant of the matrix to = 0 in order to have a non-vanishing solution, and that produces a cubic equation in ##r##, Generally, there will be three roots ##r_1, r_2, r_3##, so you will actually have solutions of the form ##x_1 = A_1 e^{r_1 t} + A_2 e^{r_2 t} + A_3 e^{r_3 t}##, etc.