Hi there.

I have the following system of ODEs to solve:

Subject to .

As you can see, the first equation is a first order separable equation which is simple to solve. The second one has as a variable... so it was my thought to solve the first equation, then subtitute the solution into the 2nd equation and then solve that by separation of variables. So, here's my solution to the first:

Applying the initial condition, I find .

So I substituted this solution for into the second differential equation, and set about solving that by separation of variables too. Here's the solution I got:

Here, is the integration constant which resulted from the integration of the first differential equation, and is the integration constant from the integration of the second differential equation. Applying the initial condition for and substituting in for as found before, we find:

So, putting that all together, the solved system is:

Now, I compared these analytical results against a numerical integration of the same differential equations, and I'm getting confused by the results. Here's the values of the constants and the initial conditions that I used (which are specific to a physical problem I'm trying to solve):

And the integration time interval is [0,1000000].

I integrated with MATLAB's ode45, which is a runge-kutta based integrator, with a maximum step size of 100, and relative and absolute tolerances of .

I've attached the results... 1.png and 2.png show the results of numerical/analytical comparisons for x(t) and y(t) respectively, when I choose , and 3.png and 4.png show the same thing, but for .

Now, it was my expectation that ONE of the choices of C would produce the correct result, and one would produce the wrong results. However... I have a mix. Because choosing C to be positive gives agreement for y(t), but disagreement for x(t), and visa versa for choosing C to be negative.

How can this be?... surely the constant C must be the same value for both equations, since they describe a single system... how can it be that the first equation requires a negative C, and the second requires a positive C? Have I missed some step in my integration process that should fix this?

Finally, I can't explain why the numerical/analytical match for x(t) is PERFECT (i.e. when correct C is chosen), whereas the match for y(t) diverges with time. Even setting lower integration tolerances and small time steps does not eliminate the error at all, it always diverges at the same rate regardless, leading me to believe that it is not a numerical error, but something inherent in the equations.

Could anybody help shed light on these two issues?