import numpy as np
from scipy import optimize
import matplotlib.pyplot as plt
%matplotlib inline
def logistic4(x, A, B, C, D):
return (A-D)/(1+(x/C)**B)+D
def residuals(p, y, x):
A, B, C, D = p
return y - logisctic4(x, A, B, C, D)
def peval(x, p):
A, B, C, D = p
return logistic4(x, A, B, C, D)
A, B, C, D = .5, 2.5, 8, 7.3
x = np.linspace(0, 20, 20)
y_true = logistic4(x, A, B, C, D)
y_meas = y_true + 0.2 * np.random.randn(len(y_true))
from sympy.parsing.sympy_parser import parse_expr
from sympy import plot_implicit
import numpy as np
temp3 = np.sqrt(3)
ezplot = lambda expr : plot_implicit(parse_expr(expr))
#3*sin(y)**2+cos(410*x)**2*cos(y)**2+2*1.732*cos(410*x)*sin(y)*cos(y)-4*(sin(410*x)+8)**2+sin(410*x)**2
string_math = "-3*cos(2*y)+0.5*(cos(2*x)+1)*(cos(2*y)+1)+2*{0}*cos(x)*sin(2*y)+3*cos(2*x)-1.5".format(temp3)
# string_math = "17 * x **2 - 16 *Abs(x)*y +17* y**2 - 256 "
print(string_math)
ezplot(string_math)
-3*cos(2*y)+0.5*(cos(2*x)+1)*(cos(2*y)+1)+2*1.7320508075688772*cos(x)*sin(2*y)+3*cos(2*x)-1.5
<sympy.plotting.plot.Plot at 0x200e7cc99b0>
np.exp(1)+np.pi
5.8598744820488378
计算 2√