Solving ODEs with Forward Euler & Sampled Data Systems

  • Thread starter adoprea
  • Start date
  • Tags
    Odes
In summary: The Attempt at a SolutionNothing 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
  • #1
adoprea
6
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
  • #2
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​
 
  • #3
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.
 
  • #4
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...)

--
 
  • #5
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.
 
  • #6
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 \\
\dot{x_2}= x_3 & \Rightarrow & r B = C \\
\dot{x_3} = -2x_1-3x_2-4x_3 &\Rightarrow & r C = -2A - 3B - 4C
\end{array}
[/tex]
This implies
[tex] \pmatrix{r & -1 & 0 \\
0 & r & -1 \\
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.
 
  • #7
Not sure ado is really interested in the actual solution (#1, #3). Could well be a step-up for a numerical solution exercise.
But still interesting !
 

1. What is the purpose of using Forward Euler to solve ODEs?

The purpose of using Forward Euler is to approximate the solution to a differential equation at discrete time steps. This method is commonly used in numerical analysis and is useful for solving ODEs for which there is no analytical solution.

2. How does Forward Euler work?

Forward Euler works by taking the current value of the solution and using the slope of the differential equation at that point to estimate the value at the next time step. This process is repeated until the desired number of time steps is reached.

3. What are the limitations of Forward Euler?

One of the main limitations of Forward Euler is its tendency to accumulate error over time. This can lead to inaccurate solutions, especially for ODEs with steep slopes or large time steps. Additionally, Forward Euler may not accurately capture oscillatory behavior in the solution.

4. How do I choose the appropriate time step for Forward Euler?

The appropriate time step for Forward Euler depends on the specific ODE being solved. Generally, a smaller time step will result in a more accurate solution, but it also increases the computational cost. It is important to balance accuracy and efficiency when choosing a time step.

5. Can Forward Euler be applied to systems with sampled data?

Yes, Forward Euler can be applied to systems with sampled data. In this case, the time step is determined by the sampling rate of the data. The method can be used to estimate the behavior of the system between the sampled data points.

Similar threads

Replies
8
Views
157
  • Calculus and Beyond Homework Help
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
5K
  • Calculus and Beyond Homework Help
Replies
24
Views
2K
  • Calculus and Beyond Homework Help
Replies
10
Views
4K
  • Calculus and Beyond Homework Help
Replies
3
Views
2K
  • Calculus and Beyond Homework Help
Replies
7
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
1
Views
3K
  • Calculus and Beyond Homework Help
Replies
2
Views
2K
Back
Top