Backward Euler technique vs. periodic function: Damping out?

Click For Summary
SUMMARY

The discussion centers on the challenges faced when implementing the Backward Euler technique for solving the differential equation y" + y = 0, particularly in relation to periodic functions. The user reports discrepancies in results when comparing their Backward Euler implementation with BDF2 and BDF4 methods, despite using validated test functions. Key insights reveal that first-order methods, like Backward Euler, perform poorly on periodic functions, leading to amplitude decay and phase shifts. The conversation also touches on the complexities of variable-order approaches in multistep methods and the necessity of understanding numerical analysis for effective implementation.

PREREQUISITES
  • Understanding of Backward Euler method
  • Familiarity with BDF (Backward Differentiation Formula) methods
  • Knowledge of periodic functions in differential equations
  • Basic concepts of numerical analysis
NEXT STEPS
  • Study the stability and convergence properties of the Backward Euler method
  • Explore the implementation of BDF2 and BDF4 methods in MATLAB
  • Investigate the effects of variable-order methods in numerical integration
  • Learn about the analysis of numerical methods for periodic functions
USEFUL FOR

Mathematicians, numerical analysts, and software developers working with differential equations, particularly those interested in the stability of numerical methods and the behavior of periodic functions in simulations.

maistral
Messages
235
Reaction score
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
In this case, the backwards Euler method with timestep h yields <br /> \begin{pmatrix} 1 &amp; -h \\ h &amp; 1 \end{pmatrix}\begin{pmatrix} u_{n+1} \\ v_{n+1} \end{pmatrix} =<br /> \begin{pmatrix} u_n \\ v_n \end{pmatrix} where u_n = y_n and v_n = y_n&#039;. The eigenvalues of the matrix on the left are 1 \pm ih, so their reciprocals both have magnitude (1 + h^2)^{-1/2} &lt; 1 for any positive h. Thus |u_n| \to 0.
 
  • Like
Likes   Reactions: Delta2
An alternative approach is to integrate once to obtain <br /> y&#039; = \pm \sqrt{y(0)^2 + y&#039;(0)^2 - y^2} and solve that instead (remembering that you have to change signs whenever y&#039; = 0).
 
Finally: solving the recurrence relation yields <br /> \begin{pmatrix} u_n \\ v_n \end{pmatrix} = (1 + h^2)^{-n/2} \begin{pmatrix} \cos n\alpha &amp; -\sin n \alpha \\<br /> \sin n \alpha &amp; \cos n\alpha \end{pmatrix} \begin{pmatrix} u_0 \\ v_0 \end{pmatrix} where <br /> \cos \alpha = \frac{1}{\sqrt{1 + h^2}}. For (u_0, v_0) = (1,0) this yields <br /> u_n = \frac{\cos n\alpha}{(1 + h^2)^{n/2}} as compared with the exact \cos nh. You can see that the amplitude decays and the phase shifts.
 
  • Like
Likes   Reactions: pbuk
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   Reactions: pasmith
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?
 
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!
 
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 15 ·
Replies
15
Views
32K
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K