Python - Sympy Minima和Maxima

时间:2017-11-21 19:11:04

标签: python sympy calculus

我试图学习同情的微积分函数,并且我能够通过以下方式获得极值临界点的二阶导数的根源:

    import numpy as np
    from numpy import linspace, math, arange, linspace
    from sympy import *
    import sympy as sp
    import math

    x = Symbol('x')
    f = (x**4) - (24*x**2) + 80  
    fd = diff(f)
    fdd = diff(fd)
    print(fd)
    print(fdd)

    polyRoots = solveset(f,x)
    dRoots = solveset(fd,x) #gets critical x values
    ddRoots = solveset(fdd,x)

如何将我从dRoots获得的值替换为原始等式f,并让它输出一个值列表?

1 个答案:

答案 0 :(得分:2)

>>> [f.subs(x, _) for _ in polyRoots]
[0, 0, 0, 0]

您可以通过执行以下操作验证这是否有意义:

    Process.Start("d:\test.pdf")
    My.Computer.FileSystem.DeleteFile("d:\test.pdf")