为NotimplementedError工作:初始条件为DSOLVE的常数产生了太多的解决方案吗?

问题描述 投票:0回答:1

为此有解决方法吗? 尝试解决时,将Sympy 1.13.3与Python 3.13.1一起使用

 y'(x)=y(x)^(1/3)
带有ic
y(0)=1
它给予

notimplementedError:初始条件产生了太多的解决方案 对于常数

Sympy真的无法解决这个问题,还是我需要一些选项或设置才能使用?我是使用Sympy解决Ode的新手。这种颂歌只是正交颂,所以我期望在Sympy中解决它没有问题。
here是完整的代码

python Python 3.13.1(Main,Dec 4 2024,18:05:56)[GCC 14.2.1 20240910]在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})

给了

> 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 > >>>
解决方案应为

ode:=diff(y(x),x)=y(x)^(1/3); dsolve([ode,y(0)=1]) # y(x) = (9 + 6*x)^(3/2)/27
    

sympy可以在没有

ics
或其他提示的情况下解决这个问题 - 这是您所期望的吗?
>>> 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: ... print(solve(Eq(e.rhs, 1), x)) # hack together y(0)=1 ... [-C1 - 3/4 - 3*sqrt(3)*I/4, -C1 - 3/4 + 3*sqrt(3)*I/4] [3/2 - C1]
python sympy
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.