在SymPy中为何nonlinsolve返回错误结果?求dx=dy的nullcline
Alright, let's walk through your nullcline solution step by step. You're working with a 3D system of differential equations, and you want to find the intersection of the dx=0 and dy=0 nullclines (with dz=0 fixed). Your SymPy code is correctly set up to solve this nonlinear system, so let's unpack the results.
Your Code
from sympy import * x, y, z = symbols('x, y, z') dx = x - x ** 3 / 3 - z + y dy = -y ** 2 * 0.1 + z dz = 0 xy_nullcline = nonlinsolve([dx, dy], [x, y, z]) print(xy_nullcline)
Output
{
(x, -3.16227766016838sqrt(z), z),
(x, 3.16227766016838sqrt(z), z)
}
What This Means
First, let's translate the numerical approximation to exact terms: that 3.16227... value is just √10 (since 0.1 = 1/10). So the solution set simplifies to two families of curves:
- For any real values of
xandz(wherez ≥ 0, since we're taking square roots),y = -√(10z) - For the same domain of
xandz,y = √(10z)
From the dx=0 equation, we also have the relationship:x - x³/3 - z + y = 0 → z = x - x³/3 + y
This means for each pair of (y, z) from the dy=0 solution, x must satisfy the cubic equation x³/3 - x + (z - y) = 0—so for each valid z, there can be 1 to 3 real x values that satisfy the nullcline condition.
Connecting to Your 3D Plot
Looking at your visualization:
- The orange surface (you mentioned it as a curve, but it's technically a cubic surface) is the
dx=0nullcline, defined by the polynomial relationship betweenx,y, andz. - The purple curves correspond to the intersection of this cubic surface with the
dy=0surface (a parabolic cylindery²=10z). These are exactly the two curves output by your code: one whereyis positive for non-negativez, and one whereyis negative.
内容的提问来源于stack exchange,提问作者Josh.F

