为什么在使用sympy求解时会出现空白列表?我想找到零线的交点

I have to find the equilibrium points where the nullclines intersectMy code is as below.

`from sympy import symbols, Eq, solve
 A,M = symbols('A M')
 dMdt = Eq(1.05 - (1/(1 + pow(A,5))) - M)
 dAdt = Eq(M*1 - 0.5*A - M*A/(2 + A))
 solve((dMdt,dAdt), (M,A))`
评论
  • 已婚女嗨
    已婚女嗨 回复

    在我努力获得解决方案时,您将明白为什么。

    我将方程式写为e1和e2-在没有第二个arg的情况下使用Eq不再起作用(或者在SymPy的最新版本中使用警告来这样做):

    >>> from sympy import solve, nsimplify, factor, real_roots
    >>> from sympy.abc import A, M
    >>> e1 = (1.05 - (1/(1 + pow(A,5))) - M)
    >>> e2 = (M*1 - 0.5*A - M*A/(2 + A))
    

    使用e1求解M

    >>> eM = solve(e1, M)[0]
    

    代入e2

    >>> e22 = e2.subs(M, eM); e22
    -0.5*A - 0.05*A*(21.0*A**5 + 1.0)/((A + 2)*(A**5 + 1.0)) + 0.05*(21.0*A**5 + 1.0)/(A**5 + 1.0)
    

    获取分子和分母

    >>> n,d=e22.as_numer_denom()
    

    找到该表达式的实根(仅取决于A)

    >>> rA = real_roots(n)
    

    通过将每个值代入eM来找到M的对应值:

    >>> [(a.n(2), eM.subs(A, a).n(2)) for a in rA]
    [(-3.3, 1.1), (-1.0, zoo), (-0.74, -0.23), (0.095, 0.050)]
    

    That root of A = -1 is spurious -- if you look at your denominator of e1 you will see that such a value causes division by zero. So that root can be ignored. The others can be verified graphically.

    Why didn't solve give the solution? It couldn't give the solution for this high-order polynomial in closed form. Even if you factor the numerator described above (and make floats into Rationals with nsimplify) you have a factor of degree 7:

    >>> factor(nsimplify(n))
    -(A + 1)*(A**4 - A**3 + A**2 - A + 1)*(5*A**7 + 10*A**6 - 21*A**5 + 5*A**2 + 10*A - 1)/10