Ask Your Question

solve a system of two equations for a derivative

asked 2016-03-23 08:03:07 +0200

sophia gravatar image

I have the following defined:

sage: var('a, t');

sage: function('x, y, v, u')

sage: de1 = diff(x(t),t) - diff(y(t),t) == x(t)

sage: de2 = diff(y(t),t) == y(t)

I'd like to solve these two equations algebraically for diff(x(t),t) and diff(y(t),t).

sage: sol = solve(de1, diff(x(t),t)); works, and i get an explicit solution for diff(x(t),t), but when i try solving both equations using:

sage: sol = solve([de1, de2],diff(x(t),t),diff(y(t),t));

i get the following error:

Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/", line 822, in solve variables = tuple(args[0]) TypeError: 'sage.symbolic.expression.Expression' object is not iterable


I'd appreciate any help with this. thank you.

edit retag flag offensive close merge delete


Why not using desolve ? See documentation

ndomes gravatar imagendomes ( 2016-03-23 12:13:07 +0200 )edit

I'm not trying to solve the differential equations just yet. i only want to solve the equations algebraically (explicitly) for the derivatives, so I can compute the Jacobian matrix of the right hand sides for further bifurcation analysis. the equations in my actual problem have parameters.

(this is pretty easy to do in Maple)

sophia gravatar imagesophia ( 2016-03-23 21:45:55 +0200 )edit
kcrisman gravatar imagekcrisman ( 2016-03-24 19:34:04 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-03-23 22:47:39 +0200

calc314 gravatar image

updated 2016-03-24 04:49:40 +0200

I see what you want to do, but apparently solve will not work with two equations and two derivatives in this way. I think this must have something to do with how Maxima works or how Sage is passing info to Maxima.

Another option would be to use x1 and y1 in place of your derivatives and then solve, since you are really not using the fact that you have functions of t in this solving procedure.

var('x y x1 y1')
de1 = x1 - y1 == x
de2 = y1 == y
sol = solve([de1,de2],[x1,y1])

This gives:

[[x1 == x + y, y1 == y]]

To find the Jacobian, you need the appropriate vector field. You can get this from the solution with the following

F=map(lambda q: q.rhs(),sol[0])

Then, the Jacobian is:


Does that resolve the issue?

edit flag offensive delete link more


thanks for replying. i'd like to automate the solution process. i tried substituting x1 for diff(x(t),t), but got an error ( i don't want to manually type in the x1 and y1 part). i tried both:

sage: de1.substitute_function(diff(x(t),t),x1) and sage: de1.subs(diff(x(t),t)=x1)

any suggestions as to how i can sub x1 for diff(x(t),t) directly in de1?

thank you,

sophia gravatar imagesophia ( 2016-03-24 02:27:30 +0200 )edit

Since you originally stated that you were hunting for the Jacobian, I will update my post to include what you need to get that matrix.

calc314 gravatar imagecalc314 ( 2016-03-24 04:47:31 +0200 )edit

The following worked for me: de1.subs(diff(x(t),t)==x1,diff(y(t),t)==y1)

calc314 gravatar imagecalc314 ( 2016-03-24 04:52:16 +0200 )edit

that helps me solve what i wanted to, thank you!

i had simplified the problem that i wanted to solve considerably. finding the Jacobian will require solving for the derivative of a functional w.r.t a function. Instead of crowding this post, i've asked a new question here: (

thank you again for your help.

sophia gravatar imagesophia ( 2016-03-24 07:51:23 +0200 )edit

answered 2016-03-23 21:42:39 +0200

castor gravatar image

updated 2016-03-23 21:43:10 +0200

In your case it would be something like this:

de1 = diff(x,t) - diff(y,t) == x
de2 = diff(y,t) == y
desolve_system([de1, de2], [x,y])

and the result is as follows:

[x(t) == t*e^t*y(0) + e^t*x(0), y(t) == e^t*y(0)]
edit flag offensive delete link more


thanks for replying. i don't want to use desolve yet. all i'd like to do is to solve the equations algebraically (explicitly) for the derivatives. thank you,

sophia gravatar imagesophia ( 2016-03-24 02:28:57 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-03-23 08:03:07 +0200

Seen: 567 times

Last updated: Mar 24 '16