Ask Your Question
0

solve a system of two equations for a derivative

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

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/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[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

Comments

Why not using desolve ? See documentation

ndomes gravatar imagendomes ( 2016-03-23 12:13:07 +0100 )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 +0100 )edit
kcrisman gravatar imagekcrisman ( 2016-03-24 19:34:04 +0100 )edit

2 Answers

Sort by ยป oldest newest most voted
0

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

calc314 gravatar image

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

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[0])

Then, the Jacobian is:

jacobian(F,[x,y])

Does that resolve the issue?

edit flag offensive delete link more

Comments

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 +0100 )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 +0100 )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 +0100 )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:

http://ask.sagemath.org/question/32876/finding-the-derivative-of-a-functional-wrt-a-function/ (http://ask.sagemath.org/question/3287...)

thank you again for your help.

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

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

castor gravatar image

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

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)]
edit flag offensive delete link more

Comments

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 +0100 )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

Stats

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

Seen: 674 times

Last updated: Mar 24 '16