1

I want to consider this differential system: $$ \ \frac{dx}{dt} = -y(t)\\ \frac{dy}{dt} = \ x(t) $$ where $t>0$ with initial condition$ (x(0),y(0))=(1,0).$

First I want to show that this differential equation admits an invariant of $I = x(t)^2 + y(t)^2$ Also, Can someone help me to figure out if Forward Euler, backwards Euler, or implicit trapezoidal rule admit invariants similar to $I = x(t)^2 + y(t)^2$?

Jackson Hart
  • 1,600

2 Answers2

0

I wonder how I found this old question. The right way to consider this is interpreting your equation (which is the harmonic oscillator) as a Hamiltonian system with Hamiltonian $H= (x^2+y^2)/2$.

Then, the way to find an invariant is to look for a so-called modified Hamiltonian which is solved exactly by the method and hence an invariant.

Good candidates for such methods go by the name symplectic integrators since their modified equations are Hamiltonian. None of your methods is symplectic and you will probably have a hard time finding invariants in the modified equations (which are then not Hamiltonian) ;) Try implicit midpoint & symplectic Euler, the latter has the invariant $H=x^2+y^2+hxy$ where $h$ is your time-step.

Mårten W
  • 3,480
phil
  • 11
0

I would like to explain this, using explicit Euler, because it is the most elementary. We have: \begin{align} \begin{pmatrix} x \\ y \end{pmatrix}' = \begin{pmatrix} -y \\ x \end{pmatrix} = f(x,y) \end{align} Explicit euler looks like this: $z_{k+1} = z_k +h \cdot f(z_k)$, applied to our problem it becomes: \begin{align} \begin{pmatrix} x_{k+1} \\ y_{k+1} \end{pmatrix} = \begin{pmatrix} x_{k} \\ y_{k} \end{pmatrix} +h \begin{pmatrix} -y_{k} \\ x_{k} \end{pmatrix} = \begin{pmatrix} x_{k}-hy_k \\ y_{k}+h x_k \end{pmatrix} \end{align} So if we want to know, whether $x(t)^2+y(t)^2$ are constant, we check \begin{align} x_{k+1}^2+y_{k+1}^2 = (x_k -h y_k)^2 +(y_k+ h x_k)^2 = (x_k^2+y_k^2)(1+h^2) \end{align} Give the initial values $x_0=1$ and $y_0=0$ and using recursion, we get \begin{align} x_{k+1}^2+y_{k+1}^2 &=(x_k^2+y_k^2)(1+h^2) =(x_{k-1}^2+y_{k-1}^2)(1+h^2)^2 =\ ... \ =(x_0^2+y_0^2)(1+h^2)^{k+1}\\ &= (1+h^2)^{k+1} \end{align} So it is no invariant.

Next implicit euler. The method reads $z_{k+1} = z_k +h \cdot f(z_{k+1})$ So we get \begin{align} & \begin{pmatrix} x_{k+1} \\ y_{k+1} \end{pmatrix} = \begin{pmatrix} x_{k} \\ y_{k} \end{pmatrix} +h \begin{pmatrix} -y_{k+1} \\ x_{k+1} \end{pmatrix} = \begin{pmatrix} x_{k}-hy_{k+1} \\ y_{k}+h x_{k+1} \end{pmatrix} \\ & \Leftrightarrow \begin{pmatrix} x_{k+1}+ h y_{k+1} \\ y_{k+1} -h x_{k+1} \end{pmatrix} = \begin{pmatrix} x_{k} \\ y_{k} \end{pmatrix} \\ & \Leftrightarrow \begin{pmatrix} 1 & h \\ 1 & -h \end{pmatrix} \begin{pmatrix} x_{k+1} \\ y_{k+1} \end{pmatrix} = \begin{pmatrix} x_{k} \\ y_{k} \end{pmatrix} \end{align} So as you can see, you end up with a linear system you have to solve for $x_{k+1} $ and $y_{k+1}$. This is the price you pay for an implicit scheme. If you solve for $x_{k+1} $ and $y_{k+1}$ you can again check the invariant. Good luck,

Thomas

Thomas
  • 4,363
  • How are these compared to FE and BE? Also, do you know what method I should use to find the invariant of the diffeq is what I described above? – Jackson Hart Nov 12 '12 at 21:17
  • And how do you know it is not invariant exactly? – Jackson Hart Nov 12 '12 at 21:20
  • I showed that $x(t)^2+y(t)^2$ are not invariant for all $t$. If they where, also $x_{k+1}^2+y_{k+1}^2$ would be constant for all $k$. But this is not the case. For larger $k$ we get $x_{k+1}^2+y_{k+1}^2 \rightarrow \infty$ with $h>0$. – Thomas Nov 12 '12 at 21:38
  • @macdaynim Do you know how to show that the diffeq does infact admit that invariant? – Jackson Hart Nov 12 '12 at 21:39
  • Could you help show me the method for FE, BE, and trap? At least where to start? I am very lost here. – Jackson Hart Nov 12 '12 at 21:41
  • @macydaynim I see why it is not invariant but I think I am suppose to show somehow that the invariant does exist for the diffeq, maybe not exactly for that technique – Jackson Hart Nov 12 '12 at 21:44
  • Okay FE is what I used in my answer.

    To a given problem $ z' = f(z) $, given an inital value $z(0)=z_0$, we can approximate the solution of this ODE (ordinary differential equation), by evaluating the our approximation at discrete points. Thus, the FE can be written as $z_{k+1} = z_k +h \cdot f(z_k)$ with som stepsize h. The smaller h, the more detailed you approximate the solution. For backward Euler the methods reads $z_{k+1} = z_k +h \cdot f(z_{k+1})$.

    – Thomas Nov 12 '12 at 21:44
  • When my teacher did FE in class, he showed that it equaled (1+del(t)^2)*In. Is that what you have? It appears that yours is different – Jackson Hart Nov 12 '12 at 21:47
  • If $del$ means $\Delta$ my $h$ is the same. I am not sure what you mean by $*In$ – Thomas Nov 12 '12 at 21:48
  • In = (xn^2+yn^2) – Jackson Hart Nov 12 '12 at 21:48
  • SO how would BE be any different except adding n+1 to everything? – Jackson Hart Nov 12 '12 at 21:50
  • yes, then you state \begin{align} (x_{n+1}^2+y_{n+1}^2) = (1+delt(t)^2)\cdot In \end{align} And i state \begin{align} (x_{k+1}^2+y_{k+1}^2) = (1+h^2)\cdot In \end{align} So just another notation. But in my opinion, invariant means, that the value is unchanged. And $x_{n+1}^2+y_{n+1}^2$ changes as it is multiplied by a factor (1+delt(t)^2) in each iteration. – Thomas Nov 12 '12 at 21:51
  • I see, could you show me more of BE? I see the difference, but would anything else be different? – Jackson Hart Nov 12 '12 at 21:51
  • Actually, I think I got them. Do you know how to show the initial invariant that I asked in the problem? – Jackson Hart Nov 12 '12 at 22:01
  • i added BE to my answer – Thomas Nov 12 '12 at 22:02
  • Ok thanks! That makes sense! Did you understand my first question? – Jackson Hart Nov 12 '12 at 22:02
  • I am sorry which one was your first question? Concerning the invariant? I proofed, that for FE $I$ is no invariant. For BE you have to work it out the same way as I did in FE. Something completely different is the fact, that for the analytical solution ( sin and cos) $x(t)^2+y(t)^2=1$ are invariant. But this is only the case, if you don't approximate via Euler. – Thomas Nov 12 '12 at 22:04
  • My first question is to show that the invariant does exist of what I put up there – Jackson Hart Nov 12 '12 at 22:06
  • It is suppose to be a perfect circle. FE spirals out. BE spirals in. Do you know how to show the invariant should be what I said in beginning? – Jackson Hart Nov 12 '12 at 22:06
  • $x' = -y $ and $ y' = x$ , therefore $x'' = -y' = -x$ So this gives us together with the initial conditions $x(t) = cos(t)$ and $y(t) = sin(t)$ and you get $I = x(t)^2+y(t)^2= cos(t)^2+sin(t)^2=1$, i.e. a circle – Thomas Nov 12 '12 at 22:11
  • I am confused of you just just went from cos(t) and sin(t) to making them squared? – Jackson Hart Nov 12 '12 at 22:15
  • Could you just help me with that last part? A full explanation. I have really appreciated all of your help. Thank you so much – Jackson Hart Nov 12 '12 at 22:16
  • Well i have squared them, because that was the definition of your invariant. You stated $I = x(t)^2+y(t)^2$ is an invariant. I stated $x(t) = \cos(t)$ and $y(t) = \sin(t)$ Therefore my solution in your invariant gives us $I = x(t)^2+y(t)^2 = \cos(t)^2+\sin(t)^2 = 1$ – Thomas Nov 12 '12 at 22:18
  • No, I do not know what the invariant is, I am suppose to show thats what it equals – Jackson Hart Nov 12 '12 at 22:19
  • So do you know how to find that invariant? – Jackson Hart Nov 12 '12 at 22:21
  • Okay, but if you have the solution $x(t) = cos(t)$ and $y(t) = sin(t)$ and you are searching(?) for an invariant, this would be my first guess. You have the solution, and you know that $\cos(t)^2+\sin(t)^2$ add up to 1, so you define $I = x(t)^2 +y(t)^2$ as your invariant. Sorry I wouldnt know any further suggestions. Good luck! – Thomas Nov 12 '12 at 22:22
  • The exact problem is this: I=x(t)2+y(t)2=cos(t)^2+sin(t)^2=1, – Jackson Hart Nov 12 '12 at 22:22
  • And thats an invariant becuase it always equals 1? – Jackson Hart Nov 12 '12 at 22:23
  • Yes, $\cos(t)^2+\sin(t)$ is always equal 1 and therfore an invariant of your system. See e.g. http://www.gbbservices.com/math/cos2sin2.html (first guess on google) – Thomas Nov 12 '12 at 22:26
  • earler why did you show what x'' was? – Jackson Hart Nov 12 '12 at 22:38
  • last q: how does initial conditions yield sin and cos – Jackson Hart Nov 12 '12 at 22:40
  • I showed that $x'' = -x$ to obtain my 2nd order ODE I wanted to solve. The general solution of $x'' = -x$ is $x = a \sin(x) + b\cos(x)$ as you can see if you simply plug it into your equation. So knowing $x = a \sin(x) + b\cos(x)$ and having $x(0) = 1$ as your initial condition you can plug it into the general form and get $x(0) = a \sin(0) +b \cos(0) = b =1 $ to fullfill your first initial condition, b hast to be equal to 1. But you also have the condition $y(0) = 0$. As $y = -x'$ (your first ODE) you have calculate the derivative of $x(t)$ and check the initial value. – Thomas Nov 13 '12 at 06:15