# solve a system of two equations for a derivative

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/sage_server.py", 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/relation.py", line 822, in solve variables = tuple(args) TypeError: 'sage.symbolic.expression.Expression' object is not iterable

=============================

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

edit retag close merge delete

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)

Sort by » oldest newest most voted

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])
sol


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)


Then, the Jacobian is:

jacobian(F,[x,y])


Does that resolve the issue?

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,

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.

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

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.

In your case it would be something like this:

var('t');
x=function('x')(t)
y=function('y')(t)
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)]

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,