2.2 导数与微分

from sympy import* 
init_printing()
# 代码2-5
x = Symbol('x')
C = 2
y = C
diff(y,x)

0

# 代码2-6
x = Symbol('x')
mu = Symbol('mu')
y = x**mu
diff(y,x)

\frac{\mu x^{\mu}}{x}

# 代码2-7
x = Symbol('x')
a = Symbol('a')
y = a**x
diff(y,x)

a^{x} \log{\left (a \right )}

# 代码2-8
x = Symbol('x')
a = Symbol('a')
y = log(x,a)
diff(y,x)

\frac{1}{x \log{\left (a \right )}}

# 代码2-9
x = Symbol('x')
y = sin(x)
diff(y,x)

\cos{\left (x \right )}

# 代码2-10
x = Symbol('x')
y = asin(x)
diff(y,x)

\frac{1}{\sqrt{- x^{2} + 1}}

# 代码2-11
# 函数和的导数
x = Symbol('x')
u = log(x,2)
v = x**2+1
y = u+v
diff(y,x)

2 x + \frac{1}{x \log{\left (2 \right )}}

# 函数差的导数
y = u-v
diff(y,x)

- 2 x + \frac{1}{x \log{\left (2 \right )}}

# 函数积的导数
y = u*v
diff(y,x)

\frac{2 x \log{\left (x \right )}}{\log{\left (2 \right )}} + \frac{x^{2} + 1}{x \log{\left (2 \right )}}

# 函数商的导数
y = u/v
diff(y,x)

- \frac{2 x \log{\left (x \right )}}{\left(x^{2} + 1\right)^{2} \log{\left (2 \right )}} + \frac{1}{x \left(x^{2} + 1\right) \log{\left (2 \right )}}

# 代码2-12
# 方法一
x = Symbol('x')
u = Symbol('u')
u = x**2
y = sin(u)
diff(y,x)

2 x \cos{\left (x^{2} \right )}

# 方法二
y = sin(x**2)  # 对符合函数的分解比较熟练后,可以不写出中间变量
diff(y,x)

2 x \cos{\left (x^{2} \right )}

# 代码2-13
x = Symbol('x')
y = log(tan(x))
diff(y,x)

\frac{\tan^{2}{\left (x \right )} + 1}{\tan{\left (x \right )}}

# 代码2-14
# 方法一
x = Symbol('x')
u = Symbol('u')
v = Symbol('v')
v = exp(x)
u = cos(v)
y = log(u)
diff(y,x)

- \frac{e^{x} \sin{\left (e^{x} \right )}}{\cos{\left (e^{x} \right )}}

# 方法二
y = log(cos(exp(x)))  # 对符合函数的分解比较熟练后,可以不写出中间变量
diff(y,x)

- \frac{e^{x} \sin{\left (e^{x} \right )}}{\cos{\left (e^{x} \right )}}

# 代码2-15
x = Symbol('x')
y = sin(2*x+1)
diff(y,x)

2 \cos{\left (2 x + 1 \right )}

# 代码2-16
x = Symbol('x')
y = log(x+sqrt(x**2+1))
diff(y,x)

\frac{\frac{x}{\sqrt{x^{2} + 1}} + 1}{x + \sqrt{x^{2} + 1}}

# 代码2-17
import numpy as np 
x = (29/360)*2*np.pi  # 设x=29°
y = np.sin(x)
print('29°角的正弦函数值为:',y)
29°角的正弦函数值为: 0.48480962024633706
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值