odepack.error:该函数及其雅可比行列式必须是可调用函数

时间:2016-03-23 20:39:08

标签: python odeint

odepack.error:该函数及其雅可比行列式必须是可调用函数。我怎么解决这个问题?

#!/usr/bin/env python
from sympy import *
from scipy.integrate import odeint
from matplotlib import pyplot as plt 
from scipy import optimize as opt 
import numpy as np 

x = Symbol('x')

def f(x):
    y =  100*(1-x**2)**2+(1-x)**2
    return y

def steepestDescent(f,x0,x):
    #y = np.zeros(100)
    for i in range(100):
        y = odeint(f,x0,x)
        x0 = x0-0.1*y;
    return x0

if __name__ == '__main__':
    x = np.linspace(-8,8,100)
    plt.plot(x,f(x),x,steepestDescent(f(x),2,x))
    plt.show()

0 个答案:

没有答案