sympy实战

本文介绍了如何使用SymPy库进行代数运算,包括计算2的平方根小数点后一百位,有理数算术,展开(x+y)^6,简化三角表达式。同时讲解了微积分部分,如计算极限、导数、高阶导数、泰勒级数和积分。此外,还展示了如何在SymPy中求解线性代数方程、超越方程、微分方程以及含有自由变量的方程组。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

png

<sympy.plotting.plot.Plot at 0x200e7cc99b0>
np.exp(1)+np.pi
5.8598744820488378

计算 2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值