1 | initial version |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# import some libraries
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works! (nicely separating the cases $a=0$, $a\neq 0$).
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names. 2 | No.2 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# import some libraries
sympy dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works! (nicely separating the cases $a=0$, $a\neq 0$).
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable 3 | No.3 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# import sympy we need sympy's dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works! (nicely separating the cases $a=0$, $a\neq 0$).
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names.4 | No.4 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# we need sympy's dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works! (nicely separating the cases $a=0$, $a\neq 0$).
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names.5 | No.5 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# we need sympy's dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works!
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names.6 | No.6 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# we need sympy's dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works!
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names.7 | No.7 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# we need sympy's dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works!
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names.8 | No.8 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# we need sympy's dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes its time, but it works!
Comment:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names.9 | No.9 Revision |
How about trying dsolve function from SymPy?
# expected behaviour as in 'plain' SymPy (optional)
preparser(False)
# we need sympy's dsolve and other stuff
from sympy import Function, dsolve, Eq, Derivative, symbols, sqrt, sympify, pprint
# import some variable names
from sympy.abc import t, a, v, c
# instantiate abstract function
x = Function('x')
# define the ode
g = 1/sqrt(1-v**2/c**2)
ode = g.subs(v, Derivative(x(t), t))*Derivative(x(t), t) - a*t
In another cell,
%%time
dsolve(ode, x(t))
CPU times: user 1min 6s, sys: 226 ms, total: 1min 6s
Wall time: 1min 6s
Eq(x(t), Piecewise((C1 - a*c*t**2*sqrt(c**(-2))/2, Eq(a, 0)), (C1 - c*(a**2*t**2 + c**2)*sqrt(1/(a**2*t**2 + c**2))/a, True)))
Conclusion: it takes time, but it works!
Comment:Notes:
type(g)
should be a SymPy object (in this case, <class 'sympy.core.power.Pow'>
). Unfortunately (in Sage v7.4), if we do something like sympify(ode)
, it raises a NotImplementedError: relation
. This is why I suggest to define the differential equation via sympy.abc
variable names.