0
$\begingroup$

I'm trying to solve a system of ODEs, symbolically, using Maple and Mathematica. I'm actually comparing the analytic solution with a numerical one (this is for a large simulation project, of which this is a part), and what I find is that the Mathematica solution appears to follow the numerical solutions I'm running, whereas the Maple solution does not. The solutions in this case are too long to be computationally feasible when compared with a numerical solution anyway, so I won't be using either answer, but I'm very curious as to why there is a disagreement. The system of equations is not complex:

$$y_1=A(e^{-at}-e^{-bt})$$ $$\dot{y_2}=a_1y_1-a_2y_2$$ $$\dot{y_3}=a_2y_2-a_3y_3$$

The solution to $y_2$ is the same between Maple and Mathematica, but $y_3$ is very different. I'm aware that sometimes approximate solutions are used, but no warnings came up for this. Is there some other uniqueness in how the two packages handle symbolic solutions that I'm missing?

For completeness, my Mathematica code is: (https://i.stack.imgur.com/3qcr9.png)

And for Maple: (https://i.stack.imgur.com/pjAiS.png)

Any thoughts? Many thanks!

EDIT: While the initial values in general are variables, for purposes of comparison, I set them all to 0.

EDIT 2: Even though the form of the equations are very different, I know they could be mathematically identical. I think they are different, though, because I substituted values for all the parameters and get two different numbers as output.

$\endgroup$
4
  • $\begingroup$ Are you sure that the expressions represent different functions? $\endgroup$
    – rogerl
    Oct 26, 2017 at 18:45
  • $\begingroup$ Moo - Using FullSimplify makes it a much smaller result, to be sure. However, I'm totally confident that the equation itself is different because I compare it by substituting in the various parameters and solving it at a given t. I compare this to the Maple, Mathematica, and the numerical solutions. Maple was the outlier here. $\endgroup$
    – buggaby
    Oct 26, 2017 at 19:55
  • $\begingroup$ Maple,Mathematica give correct answer numericall or analytical.See imgur.com/a/UA2HC $\endgroup$ Oct 26, 2017 at 21:11
  • $\begingroup$ Thank you Mariusz. When I copied your code it worked, eventually leading me to find a bug. I thought I had checked it all. Appreciate it. $\endgroup$
    – buggaby
    Oct 26, 2017 at 22:31

2 Answers 2

0
$\begingroup$

This is not an answer, just an extended comment. I have not look at your codes, but if you want to find an analytic form of the solution it is quite easy to do by hand. The system you are considering is $$ \begin{bmatrix}\dot y_2\\\dot y_3\end{bmatrix}= \begin{bmatrix}-a_2 & 0\\a_2 & -a_3\end{bmatrix}\begin{bmatrix} y_2\\y_3\end{bmatrix}+\begin{bmatrix}a_1\\0\end{bmatrix}y_1. $$ It takes the form of linear equation $$ \dot x=Ax+Bu $$ with the general solution being $$ x(t)=e^{At}x(0)+e^{At}\int_0^te^{-As}Bu(s)\,ds. $$ In your case, $u(s)=y_1(s)$ is a scalar function of exponentials, so the integral can be easily calculated. For example, $$ \int_0^te^{-As}Be^{-as}\,ds=\int_0^te^{-(A+aI)s}\,ds\cdot B=(A+aI)^{-1}(I-e^{-(A+aI)t})\cdot B. $$

$\endgroup$
2
  • $\begingroup$ Thanks for the comment! I started using Laplace integrals and got $y_2$ but then it got much harder. Using this method to solve $y_3$ looks interesting. However, the full question actually goes analogously up to $y_5$, which is a bit bonkers of a solution. A numerical solution is probably a necessity here. $\endgroup$
    – buggaby
    Oct 26, 2017 at 20:00
  • $\begingroup$ @buggaby If the system is linear in other variables too then it is still possible to find the analytic form in the same way, just the matrix dimention gets larger. I would probably do it this way - it seems easier to do simulation in matrix form compared to what Matematica/Maple suggest. $\endgroup$
    – A.Γ.
    Oct 26, 2017 at 20:25
0
$\begingroup$

The problem was one of those RATS (Read All The Screen) errors. Thanks to the comment by Mariusz I was able to find the bug. So this isn't really a good question after all. But I would like to keep this silly question up because of the answer that did come. It seems good to know.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .