Backward Euler technique vs. periodic function: Damping out?

In summary: Is there something with the backward Euler and periodic functions that I am missing?Yes, you are missing something about the way the function behaves.
  • #1
maistral
240
17
So I've been programming the BDF methods and for some reason I have an issue with the Backward Euler technique.

Given the differential equation y" + y = 0 (with y(0) = 2, y'(0) = 0), my backward Euler solution goes like this:
1624118443111.png


Obviously this is not possible as the function should be a well-behaved periodic. So I tried running my BDF2 and BDF4 on it, and this happens:
1624118495928.png


So yeah. What the actual flying :headbang::headbang::headbang::headbang:. I have had this issue since about a week and a half now and I am running out of ideas. I made sure that my backward Euler code isn't the problem as I used test functions from different literature like those in Chapra and such other examples available; and the results from my code and those in examples are practically identical to the last digit in those examples.

What's stranger is the fact that I used the same Backward Euler code in order to generate the initial points for BDF2/BDF4! I am totally confused and appalled.

Is there something with the backward Euler and periodic functions that I am missing?
 
Physics news on Phys.org
  • #2
In this case, the backwards Euler method with timestep [itex]h[/itex] yields [tex]
\begin{pmatrix} 1 & -h \\ h & 1 \end{pmatrix}\begin{pmatrix} u_{n+1} \\ v_{n+1} \end{pmatrix} =
\begin{pmatrix} u_n \\ v_n \end{pmatrix}[/tex] where [itex]u_n = y_n[/itex] and [itex]v_n = y_n'[/itex]. The eigenvalues of the matrix on the left are [itex]1 \pm ih[/itex], so their reciprocals both have magnitude [itex](1 + h^2)^{-1/2} < 1[/itex] for any positive [itex]h[/itex]. Thus [itex]|u_n| \to 0[/itex].
 
  • Like
Likes Delta2
  • #3
An alternative approach is to integrate once to obtain [tex]
y' = \pm \sqrt{y(0)^2 + y'(0)^2 - y^2}[/tex] and solve that instead (remembering that you have to change signs whenever [itex]y' = 0[/itex]).
 
  • #4
Finally: solving the recurrence relation yields [tex]
\begin{pmatrix} u_n \\ v_n \end{pmatrix} = (1 + h^2)^{-n/2} \begin{pmatrix} \cos n\alpha & -\sin n \alpha \\
\sin n \alpha & \cos n\alpha \end{pmatrix} \begin{pmatrix} u_0 \\ v_0 \end{pmatrix}[/tex] where [tex]
\cos \alpha = \frac{1}{\sqrt{1 + h^2}}.[/tex] For [itex](u_0, v_0) = (1,0)[/itex] this yields [tex]
u_n = \frac{\cos n\alpha}{(1 + h^2)^{n/2}}[/tex] as compared with the exact [itex]\cos nh[/itex]. You can see that the amplitude decays and the phase shifts.
 
  • Like
Likes pbuk
  • #5
maistral said:
Is there something with the backward Euler and periodic functions that I am missing?
Yes: first order methods perform badly on periodic functions. In general, explicit methods explode to infinity and implicit methods decay to zero (you can see this from the sign of the truncated ## f'' ## error term), and @pasmith has provided an execellent analysis for this particular problem.

Where are you learning about these methods from? If you are to use them successfully you can't skip the 'analysis' part of 'numerical analysis'.
 
  • Like
Likes pasmith
  • #6
I have a final question.

With respect to multistep methods I have noticed that some algorithms do variable-order approach. May I know the reason behind this? Why would you select Backward Euler over BDF4?
 
  • #7
maistral said:
Why would you select Backward Euler over BDF4?
Generally you wouldn't, but you can't select BDF4 over Backward Euler until you have already done 3 steps!
 
  • #8
pbuk said:
Generally you wouldn't, but you can't select BDF4 over Backward Euler until you have already done 3 steps!
No, what I mean is the variable step/variable order BDF/NDF which is typically used by programs like MATLAB. I don't quite understand why on Earth would you force the order to be lowered; I fully understand the vsriable step part but not the variable order part.
 

1. What is the Backward Euler technique?

The Backward Euler technique is a numerical method used to approximate the solution of a differential equation. It is a type of implicit method, meaning that the future value of the function is calculated using the current value and the derivative at the future point.

2. How does the Backward Euler technique differ from the Forward Euler technique?

The main difference between the Backward Euler technique and the Forward Euler technique is the way in which the derivative is calculated. In the Forward Euler technique, the derivative is calculated at the current point, whereas in the Backward Euler technique, the derivative is calculated at the future point. This makes the Backward Euler technique more accurate for stiff differential equations.

3. What is a periodic function?

A periodic function is a function that repeats itself at regular intervals. This means that the function has a specific pattern that repeats over and over again. Examples of periodic functions include sine, cosine, and tangent functions.

4. How does the Backward Euler technique handle damping out in a periodic function?

The Backward Euler technique can handle damping out in a periodic function by using a smaller time step. This allows the technique to better capture the behavior of the function and prevent it from damping out. However, if the damping is too strong, the Backward Euler technique may not be able to accurately approximate the solution.

5. When is it appropriate to use the Backward Euler technique for a periodic function?

The Backward Euler technique is most appropriate for periodic functions that have a small amount of damping. It is also useful for solving stiff differential equations, as it is more stable and accurate than the Forward Euler technique. However, for highly damped periodic functions, other numerical methods may be more suitable.

Similar threads

  • Programming and Computer Science
Replies
2
Views
902
  • Linear and Abstract Algebra
Replies
6
Views
1K
  • Electrical Engineering
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • Introductory Physics Homework Help
Replies
15
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • General Math
Replies
2
Views
727
  • Differential Equations
Replies
1
Views
9K
  • Classical Physics
Replies
6
Views
1K
Back
Top