# Revision history [back]

### Solving an ODE system with initial conditions

Hi!

I want to solve system of equations with initial conditions:

x''(t)=-\gamma x'(t)

y''(t)=-g-\gamma y'(t)

with the initial conditions: x(0)=0, y(0)=0, x'(0)=v0cos(\theta), y'(0)=v0sin(\theta).

I've solved this with Mathematica with no problem, but I don't know how to work in Sage, and friend has asked me for help. Now, I've searched a bit, and I made this:

t, G, g, v0, T = var('t G g v0 T')
x(t) = function('x',t)
y(t) = function('y',t)
assume(g>0)
assume(G>0)
X = x(t).diff(t,2) == - G*x(t).diff(t,1)
Y = y(t).diff(t,2) == - g - G*y(t).diff(t,1)
desolve_system([X,Y],[x,y],ics = [0,0,v0*cos(T),v0*sin(T)],ivar=t)


And I get, as a result this:

[x(t) == -e^(-G*t)*D[0](x)(0)/G + D[0](x)(0)/G, y(t) == -g*t/G -
(G*D[0](y)(0) + g)*e^(-G*t)/G^2 + (G^2*v0*cos(T) + G*D[0](y)(0) +
g)/G^2]


Now, Mathematica will give me entirely different result. So what am I doing wrong? :\ I defined the variables, I defined the functions, made differential equations. I even tried solving the equations separately (without initial conditions), and the solutions are different.

 2 No.2 Revision calc314 4101 ●20 ●47 ●109

### Solving an ODE system with initial conditions

Hi!

I want to solve system of equations with initial conditions:

x''(t)=-\gamma x'(t)

y''(t)=-g-\gamma y'(t)$x''(t)=-\gamma x'(t)$

$y''(t)=-g-\gamma y'(t)$

with the initial conditions: x(0)=0, $x(0)=0, y(0)=0, x'(0)=v0cos(\theta), \cos(\theta), y'(0)=v0sin(\theta).\sin(\theta)$.

I've solved this with Mathematica with no problem, but I don't know how to work in Sage, and friend has asked me for help. Now, I've searched a bit, and I made this:

t, G, g, v0, T = var('t G g v0 T')
x(t) = function('x',t)
y(t) = function('y',t)
assume(g>0)
assume(G>0)
X = x(t).diff(t,2) == - G*x(t).diff(t,1)
Y = y(t).diff(t,2) == - g - G*y(t).diff(t,1)
desolve_system([X,Y],[x,y],ics = [0,0,v0*cos(T),v0*sin(T)],ivar=t)


And I get, as a result this:

[x(t) == -e^(-G*t)*D[0](x)(0)/G + D[0](x)(0)/G, y(t) == -g*t/G -
(G*D[0](y)(0) + g)*e^(-G*t)/G^2 + (G^2*v0*cos(T) + G*D[0](y)(0) +
g)/G^2]


Now, Mathematica will give me entirely different result. So what am I doing wrong? :\ I defined the variables, I defined the functions, made differential equations. I even tried solving the equations separately (without initial conditions), and the solutions are different.

### Solving an ODE system with initial conditions

Hi!

I want to solve system of equations with initial conditions:

$x''(t)=-\gamma x'(t)$

$y''(t)=-g-\gamma y'(t)$

with the initial conditions: $x(0)=0, y(0)=0, x'(0)=v0\cos(\theta), y'(0)=v0\sin(\theta)$.

I've solved this with Mathematica with no problem, but I don't know how to work in Sage, and friend has asked me for help. Now, I've searched a bit, and I made this:

t, G, g, v0, T = var('t G g v0 T')
x(t) = function('x',t)
y(t) = function('y',t)
assume(g>0)
assume(G>0)
X = x(t).diff(t,2) == - G*x(t).diff(t,1)
Y = y(t).diff(t,2) == - g - G*y(t).diff(t,1)
desolve_system([X,Y],[x,y],ics = [0,0,v0*cos(T),v0*sin(T)],ivar=t)


And I get, as a result this:

[x(t) == -e^(-G*t)*D[0](x)(0)/G + D[0](x)(0)/G, y(t) == -g*t/G -
(G*D[0](y)(0) + g)*e^(-G*t)/G^2 + (G^2*v0*cos(T) + G*D[0](y)(0) +
g)/G^2]


Now, Mathematica will give me entirely different result. So what am I doing wrong? :\ I defined the variables, I defined the functions, made differential equations. I even tried solving the equations separately (without initial conditions), and the solutions are different.

EDIT: I'm using http://www.sagenb.org/ to process this.

 4 No.4 Revision calc314 4101 ●20 ●47 ●109

### Solving an ODE system with initial conditions

Hi!

I want to solve system of equations with initial conditions:

$x''(t)=-\gamma x'(t)$

$y''(t)=-g-\gamma y'(t)$

with the initial conditions: \$x(0)=0,

$$x(0)=0, y(0)=0, x'(0)=v0x'(0)=v_0 \cos(\theta), y'(0)=v0\sin(\theta).y'(0)=v_0 \sin(\theta).$$

I've solved this with Mathematica with no problem, but I don't know how to work in Sage, and friend has asked me for help. Now, I've searched a bit, and I made this:

t, G, g, v0, T = var('t G g v0 T')
x(t) = function('x',t)
y(t) = function('y',t)
assume(g>0)
assume(G>0)
X = x(t).diff(t,2) == - G*x(t).diff(t,1)
Y = y(t).diff(t,2) == - g - G*y(t).diff(t,1)
desolve_system([X,Y],[x,y],ics = [0,0,v0*cos(T),v0*sin(T)],ivar=t)


And I get, as a result this:

[x(t) == -e^(-G*t)*D[0](x)(0)/G + D[0](x)(0)/G, y(t) == -g*t/G -
(G*D[0](y)(0) + g)*e^(-G*t)/G^2 + (G^2*v0*cos(T) + G*D[0](y)(0) +
g)/G^2]


Now, Mathematica will give me entirely different result. So what am I doing wrong? :\ I defined the variables, I defined the functions, made differential equations. I even tried solving the equations separately (without initial conditions), and the solutions are different.

EDIT: I'm using http://www.sagenb.org/ to process this.