第四单元 用python学习微积分(二十五)三角函数,反向变量替换,配方,三角函数变换表

本文详细介绍了微积分中使用三角替换来简化积分的过程,包括secant、cosecant、tangent和cotangent等三角函数的转换。通过实例展示了如何使用arccsc和arctan进行替换,并利用定积分进行验算。文章还提供了Python代码来图形化展示积分过程,以及梯形法的计算结果。最后,总结了三角替换的规律和应用。
摘要由CSDN通过智能技术生成

本文内容来自于学习麻省理工学院公开课:单变量微积分-反向变量替换,配方-网易公开课

开发环境准备:CSDN

目录

一、公式梳理

1、 ​ (secant)

2、 ​(cosecant)

3、 ​ (tangent)

4、 ​ (cotangent)

5、 ​

6、 ​

7、 ​

8、 ​

9、 ​

二、例题

1、 ​

2、 ​

3、如上题去除表达式 " tan(arccsc(x)) " 中三角函数

三、三角替换的小结

1、表

2、例题


一、公式梳理

1、 sec(\theta) = \frac{1}{cos(\theta)} (secant)

2、 cec(\theta) = \frac{1}{sin(\theta)}(cosecant)

3、 tan(\theta) = \frac{sin(\theta)}{cos(\theta)} (tangent)

4、 cot(\theta) = \frac{cos(\theta)}{sin(\theta)} (cotangent)

5、 sec^2(\theta) = \frac{cos^2(\theta)+sin^2(\theta)}{cos^2(\theta)} =1+tan^2(\theta)

6、 tan'(\theta) = (\frac{sin(\theta)}{cos(\theta)})' = \frac{cos^2(\theta)+sin^2(\theta)}{cos^2(\theta)} = \frac{1} {cos^2(\theta)} = sec^2(\theta)

7、 sec'(\theta) = (\frac{1}{cos(\theta)})' = \frac{-(-sin(\theta))} {cos^2(\theta)} = tan(\theta)sec(\theta)

8、 \int tan(x)dx = \int \frac{sin(x)}{cos(x)}dx

设 u = cos(x), u' =du = -sin(x)dx

\int \frac{-du}{u} = -ln(u) +c = -ln(cos(x)) +c

9、 \int sec(x) dx

u = tan(x) + sec(x)

由公式 6, 7

du = sec^2(x) + tan(x)sec(x) = sec(x)(sec(x) + tan(x))dx

sec(x)dx = \frac{du}{u}

\int sec(x) dx = \int \frac{du}{u} = ln(u) +c = ln(tan(x) + sec(x) ) +c

二、例题

1、 \int sec^4(x)dx = \int (1+tan^2(x))sec^2(x)dx

u = tan(x) ; du = sec^2(x)dx

\int (1+u^2)du = u +\frac{u^3}{3} +c= tan(x) + \frac{tan^3(x)}{3}+c

用定积分做个简单的验算,取值 \in (0 , \frac{\pi}{3}),结果是符合的

import numpy as np 
from sympy import *
import matplotlib.pyplot as plt 

def DrawXY(xFrom,xTo,steps,expr,color,label,plt):
    yarr = []
    xarr = np.linspace(xFrom ,xTo, steps) 
    for xval in xarr:
        yval = expr.subs(x,xval)
        yarr.append(yval)
    y_nparr = np.array(yarr) 
    plt.plot(xarr, y_nparr, c=color, label=label)    
    
def DrawTrapezoidal(xFrom,xTo,steps,expr,color,plt, label=''):
    width = (xTo - xFrom)/steps
    xarrRect = []
    yarrRect = []
    area = 0
    xprev = xFrom
    yvalAll =  0
    for step in range(steps):
        yval1 =expr.subs(x,xprev) 
        yval2 = expr.subs(x,xprev + width)
        xarrRect.append(xprev)
        xarrRect.append(xprev)
        xarrRect.append(xprev + width)
        xarrRect.append(xprev + width)
        xarrRect.append(xprev)
        yarrRect.append(0)
        yarrRect.append(yval1)
        yarrRect.append(yval2)
        yarrRect.append(0)
        yarrRect.append(0)
        area += width * (yval1+yval2)/2
        plt.plot(xarrRect, yarrRect, c=color)    
        xprev= xprev + width
    print('============================')    
    if len(label)!=0:
        print(label)    
    print('============================')
    print('width = ', width)
    print('area = ',area)
    
x = symbols('x')
expr = sec(x)**4
DrawXY (0,np.pi/3,1000, expr, 'c', label='sec(x)',plt=plt)
print(integrate(expr,(x,0,np.pi/3)))
print(tan(np.pi/3)+tan(np.pi/3)**3/3 - tan(0)+tan(0)**3/3)
plt.legend(loc='upper left')
plt.show() 

添加图片注释,不超过 140 字(可选)

2、 \int \frac{dx}{x^2\sqrt{1+x^2}}

由于tan取值范围从负无穷一直到正无穷, 所以可以进行三角替换

tan(\theta) = x 则 dx = tan'(\theta) = sec^2(\theta)d\theta

另由1+tan^2(\theta) =sec^2

\int \frac{dx}{x^2\sqrt{1+x^2}} = \int \frac{sec^2(\theta)d\theta}{tan^2(\theta)\sqrt{1+tan^2(\theta)}}

= \int \frac{sec^2(\theta)d\theta}{tan^2(\theta)\sqrt{sec^2(\theta)}} = \int \frac{sec(\theta) d\theta}{tan^2(\theta)} = \int \frac{\frac{1}{cos(\theta)}d\theta}{\frac{sin^2(\theta)}{cos^2(\theta)}}

= \int \frac{cos(\theta)}{sin^2(\theta)} d\theta

u = sin(\theta) , du = cos(\theta)d\theta

= \int \frac{du}{u^2} = \frac{1}{-u} +c= \frac{1}{-sin(\theta)}+c = -csc(\theta) +c

还原三角替换

在上图中直角三角形中, 设 \theta的对边长为x, 则根据前面假设tan(\theta) = x , 有 临边长为1,另斜边长则为\sqrt{1+x^2}

-csc(\theta) +c = -\frac{1}{sin(\theta)} + c =-\frac{\sqrt{1+x^2}}{x} +c

或由 tan(\theta) = x

-csc(\theta) +c = -csc( arctan(x)) +c

用定积分验算下, 用梯形法得到的结果和计算出的结果近似。

x = symbols('x')
expr = 1/ (x**2*(1+x**2)**0.5)
DrawXY (2,5,100, expr, 'c', label='',plt=plt)
DrawTrapezoidal(2,5,100,expr,'c',plt, label='1/ (x**2*(1+x**2)**0.5)')
#print(integrate(expr,(x,2,5)))
print('result with arc tangent=', float(-csc(atan(5)) + csc(atan(2))))
print('result = ', -((1+5**2)**0.5)/5 + ((1+2**2)**0.5)/2 )

3、如上题去除表达式 " tan(arccsc(x)) " 中三角函数

theta = 45

angle = np.linspace( 0 , 2 * np.pi , 150 ) 
 
radius = 1
 
xarr = radius * np.cos( angle ) 
yarr = radius * np.sin( angle ) 
 
figure, axes = plt.subplots( 1 ) 
 
axes.plot( xarr, yarr, label='radius='+format(radius) ) 


angleInner = np.linspace( theta/180*np.pi , 0 , 150 ) 
xArcInner = radius /10 * np.cos( angleInner ) 
yArcInner = radius /10 * np.sin( angleInner ) 

axes.plot( xArcInner, yArcInner,color='b') 

plt.text(0.18, 0.03, 'θ', fontsize=9)

plt.text(cos(theta)-0.18, -0.08, 'adj', fontsize=9)
plt.text(cos(theta)+0.22, sin(theta)-0.48, 'opp', fontsize=9)
plt.text(cos(theta)-0.3, sin(theta)-0.48, 'hyp', fontsize=9)

axes.set_aspect( 1 ) 
 
x1 = np.cos( theta/180*np.pi )
y1 = np.sin( theta/180*np.pi ) 

xarr1 = [0,1]
yarr1 = [0,0]
plt.plot(xarr1, yarr1,'r',linestyle='-',marker='')

xarr2 = [0,x1]
yarr2 = [0,y1]
plt.plot(xarr2, yarr2,'orange',linestyle='-',marker='')

plt.plot([x1,x1], [0,y1],'green',linestyle='-',marker='')
plt.plot([0,x1], [0,0],'green',linestyle='-',marker='')

plt.text(x1+0.05, y1+0.05, '(cosθ ,sinθ)', fontsize=9)
plt.text(-0.1, -0.1, 'O', fontsize=9)
plt.legend(loc='upper left')
plt.show() 

csc(\theta) = x

\frac{1}{sin(\theta)} =x = \frac{hyp}{opp}

设斜边(hyp)为x,则对边(opp)为1, 临边(adj)为 \sqrt{x^2 -1}

tan(arccsc(x)) = tan(\theta) = \frac{opp}{adj} = \frac{1}{\sqrt{x^2 -1}}

三、三角替换的小结

1、表

如果积分包含 -- 要做的替换 -- 得到

\sqrt{a^2 -x^2}-- x = a \times cos(\theta) or x = a \times sin(\theta)--a \times sin(\theta) or a \times cos(\theta)

x = a \times cos(\theta)dx = -a*sin(\theta)d\theta

x = a \times sin(\theta)dx = a*cos(\theta)d\theta

\sqrt{a^2 +x^2}  --  x = a \times tan(\theta)   --  a \times sec(\theta)    --   dx = asec(\theta)^2d\theta

\sqrt{x^2 -a^2}  --  x = a \times sec(\theta)   --   a \times tan(\theta)   --   dx = atan(\theta)sec(\theta)d\theta 

\sqrt{a^2 + x^2} = \sqrt{a^2 + a^2tan(x)} = a \times \sqrt{1+tan^2(x)}=a\sqrt{\frac{cos^2(x)}{cos^2(x)}+\frac{sin^2(x)}{cos^2(x)}} =a\sqrt{\frac{1}{cos^2(x)}} =a \times sec(x)

\sqrt{x^2 -a^2} = \sqrt{a^2sec^2(x) -a^2} = a\sqrt{\frac{1}{cos^2(x)} - \frac{cos^2(x)}{cos^2(x)}} = a \times tan(x)

2、例题

\int \frac{dx}{ \sqrt{x^2 +4x}} =\int \frac{dx}{ \sqrt{(x+2)^2 - 4} }

u = x-2 , du = dx, x^2+4x = u^2 -2^2

\int \frac{du}{ \sqrt{u^2 -2^2} }

u = 2sec(\theta) , du = 2tan(\theta)sec(\theta)d\theta,

\sqrt{x^2 -a^2} -- x = a \times sec(\theta) -- a \times tan(\theta)

\sqrt{u^2 - 2^2} = 2tan(\theta)

\int \frac{du}{ \sqrt{u^2 -2^2} } = \int \frac{2tan(\theta)sec(\theta)d\theta}{2tan(\theta)} =\int sec(\theta)d\theta

由公式9:

\int sec(x) dx = \int \frac{du}{u} = ln(u) +c = ln(tan(x) + sec(x) ) +c

\int sec(\theta)d\theta = ln(tan(\theta) + sec(\theta) ) +c

u = 2sec(\theta), \sqrt{u^2 - 2^2} = 2tan(\theta)

\int sec(\theta)d\theta = ln(tan(\theta) + sec(\theta) ) +c= ln(tan(\theta) + sec(\theta) ) +c = ln(\frac{\sqrt{u^2-2^2}}{2} + \frac{u}{2}) +c

u = x-2 , x^2+4x = u^2 -2^2

ln(\frac{\sqrt{u^2-2^2}}{2} + \frac{u}{2})+c = ln(\frac{\sqrt{x^2+4x}}{2} + \frac{x-2}{2})+c

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Bullseye

您的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值