Search code examples
differential-equationsmaxima

Plot for the Solutions of Non-linear differential equations


I have a system of differential equations in Maxima. And I am trying to draw the solutions.

diff_eq1: 'diff(p(t),t) = (5/2 + (3^(1/2))/24 - (5/8)*p(t) - ((3^(1/2))/24)*q(t)) * p(t);
diff_eq2: 'diff(q(t),t) = (7/8 + (3*(3^(1/2))/2) - (3*(3^(1/2))/8)*p(t) - (7/8)*q(t)) * q(t);
atvalue (p(t), t=0, 0.25);
atvalue (q(t), t=0, 3);
sol: desolve([diff_eq1, diff_eq2], [p(t),q(t)]);
plot2d([rhs(sol[1]), rhs(sol[2])], [t,0,5]);

But I have an error:

plot2d: expression evaluates to non-numeric value everywhere in plotting range.
plot2d: expression evaluates to non-numeric value everywhere in plotting range.
plot2d: nothing to plot.

Solution

  • It seems maxima has not found the solution. However you can use Runge-Kutta method to get numerical result.

    http://maxima.sourceforge.net/docs/manual/en/maxima_50.html

    diff_eq1: (5/2 + (3^(1/2))/24 - (5/8)*p - ((3^(1/2))/24)*q) * p;
    diff_eq2: (7/8 + (3*(3^(1/2))/2) - (3*(3^(1/2))/8)*p - (7/8)*q) * q;
    
    (p0: 0.25, q0: 3);
    sol: rk([diff_eq1, diff_eq2], [p, q], [p0, q0], [t, 0, 2, 0.1])$
    pq: map( lambda([x], [x[2], x[3]]), sol)$
    plot2d( [discrete, pq], [xlabel, "p"], [ylabel, "q"]);