Is there a workaround for this? Using sympy 1.13.3 with python 3.13.1 when trying to solve
y'(x)=y(x)^(1/3)
with IC y(0)=1
it gives
NotImplementedError: Initial conditions produced too many solutions for constants
Does sympy really not able to solve this, or do I need some option or setting to use? I am new to using sympy for solving ode's. This ode is just quadrature ode, so I expected no problem solving it in sympy.
Here is complete code
python Python 3.13.1 (main, Dec 4 2024, 18:05:56) [GCC 14.2.1 20240910] on linux
from sympy import *
x=symbols('x')
y=Function('y')
dsolve(Eq(-y(x)**(1/3) + Derivative(y(x), x),0) , y(x), ics={y(0):1})
It gives
> Traceback (most recent call last): File "<python-input-4>", line 1,
> in <module>
> dsolve(Eq(-y(x)**(1/3) + Derivative(y(x), x),0) , y(x), ics={y(0):1})
> ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.13/site-packages/sympy/solvers/ode/ode.py",
> line 640, in dsolve
> return _helper_simplify(eq, hint, hints, simplify, ics=ics) File "/usr/lib/python3.13/site-packages/sympy/solvers/ode/ode.py", line
> 709, in _helper_simplify
> solved_constants = solve_ics([s], [r['func']], cons(s), ics) File "/usr/lib/python3.13/site-packages/sympy/solvers/ode/ode.py",
> line 817, in solve_ics
> raise NotImplementedError("Initial conditions produced too many solutions for constants") NotImplementedError: Initial conditions
> produced too many solutions for constants
> >>>
The solution should be
ode:=diff(y(x),x)=y(x)^(1/3);
dsolve([ode,y(0)=1])
# y(x) = (9 + 6*x)^(3/2)/27
Is there a workaround for this? Using sympy 1.13.3 with python 3.13.1 when trying to solve
y'(x)=y(x)^(1/3)
with IC y(0)=1
it gives
NotImplementedError: Initial conditions produced too many solutions for constants
Does sympy really not able to solve this, or do I need some option or setting to use? I am new to using sympy for solving ode's. This ode is just quadrature ode, so I expected no problem solving it in sympy.
Here is complete code
python Python 3.13.1 (main, Dec 4 2024, 18:05:56) [GCC 14.2.1 20240910] on linux
from sympy import *
x=symbols('x')
y=Function('y')
dsolve(Eq(-y(x)**(1/3) + Derivative(y(x), x),0) , y(x), ics={y(0):1})
It gives
> Traceback (most recent call last): File "<python-input-4>", line 1,
> in <module>
> dsolve(Eq(-y(x)**(1/3) + Derivative(y(x), x),0) , y(x), ics={y(0):1})
> ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/usr/lib/python3.13/site-packages/sympy/solvers/ode/ode.py",
> line 640, in dsolve
> return _helper_simplify(eq, hint, hints, simplify, ics=ics) File "/usr/lib/python3.13/site-packages/sympy/solvers/ode/ode.py", line
> 709, in _helper_simplify
> solved_constants = solve_ics([s], [r['func']], cons(s), ics) File "/usr/lib/python3.13/site-packages/sympy/solvers/ode/ode.py",
> line 817, in solve_ics
> raise NotImplementedError("Initial conditions produced too many solutions for constants") NotImplementedError: Initial conditions
> produced too many solutions for constants
> >>>
The solution should be
ode:=diff(y(x),x)=y(x)^(1/3);
dsolve([ode,y(0)=1])
# y(x) = (9 + 6*x)^(3/2)/27
Share
Improve this question
edited Feb 15 at 4:06
John Kugelman
362k69 gold badges552 silver badges596 bronze badges
asked Feb 15 at 3:43
NasserNasser
13.2k6 gold badges56 silver badges114 bronze badges
1 Answer
Reset to default 0SymPy's dsolve
can solve this when given without ics
or other hints - is this what you were expecting?
>>> from sympy import *
>>> x = symbols("x")
>>> y = Function("y")
>>> exprs = dsolve(-y(x)**(1/3) + Derivative(y(x), x))
>>> exprs
[Eq(y(x), -2*sqrt(6)*(C1 + x)**(3/2)/9), Eq(y(x), 2*sqrt(6)*(C1 + x)**(3/2)/9)]
>>> for e in exprs: # solve for C1 when y(0)=1
... print(solve(e.rhs.subs({x:0}) - 1))
...
[(sqrt(6)/4 - 3*sqrt(2)*I/4)**2, (sqrt(6)/4 + 3*sqrt(2)*I/4)**2]
[3/2]
Using SymPy 1.13.3 and passing x0=1
gives the same result
That said, I'm not absolutely certain why it doesn't like ics
or how to better structure it