第四单元 用python学习微积分(二十四)三角函数的积分以及三角替换

 本文内容来自于学习麻省理工学院公开课:单变量微积分-三角函数的积分及三角替换-网易公开课

开发环境准备:CSDN

目录

一、三角学中的基本知识

1、三角学公式:

(1) ​倍角公式

(2) ​ 半角公式

(3) 求导、求积

二、三角函数的积分

1、 简单的情况: m,n 至少有一个是奇数

2、 困难的情况: m,n 都是偶数 (用半角公式)

三、例子

1、求上图中浅蓝色线条包裹部分的面积


一、三角学中的基本知识

import numpy as np 
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)    
    
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)

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() 

​三角学中所有知识都是基于圆心在 ( 0, 0 ), 半径为1的⚪。

1、三角学公式:

sin^2\theta + cos^2\theta =1

cos(2\theta) = cos^2 \theta -sin^2\theta (倍角公式)

sin(2\theta) = 2sin\theta cos\theta (倍角公式)

(1) ​倍角公式

x = symbols('x')
expr = cos(2*x)
DrawXY(-2,0,20,expr,color = 'c',label='cos(2x)',plt=plt)

expr = cos(x)**2-sin(x)**2
DrawXY(0,2,20,expr,color = 'r',label='cos(x)**2+sin(x)**2',plt=plt)

expr = sin(2*x)
DrawXY(-2,0,20,expr,color = 'b',label='sin(2x)',plt=plt)

expr = 2*sin(x)*cos(x)
DrawXY(0,2,20,expr,color = 'g',label='2*sin(x)*cos(x)',plt=plt)

plt.legend(loc='upper left')
plt.show() 

cos(2\theta) = cos^2 \theta -(1-cos^2\theta)

cos^2(\theta) =\frac{cos(2\theta)+1}{2} (半角公式)

cos(2\theta) =1 - 2sin^2 \theta

sin^2 \theta =\frac{1 - cos(2\theta)}{2}(半角公式)

(2) ​ 半角公式

x = symbols('x')
expr = cos(x)**2
DrawXY(-2,0,20,expr,color = 'c',label='cos(x)**2',plt=plt)

expr = (1+cos(2*x))/2
DrawXY(0,2,20,expr,color = 'r',label='(1+cos(2*x))/2',plt=plt)

expr = sin(x)**2
DrawXY(-2,0,20,expr,color = 'b',label='sin(x)**2',plt=plt)

expr = (1-cos(2*x))/2
DrawXY(0,2,20,expr,color = 'g',label='(1+cos(2*x))/2',plt=plt)

plt.legend(loc='upper left')
plt.show() 
 
 

(3) 求导、求积

sin'(x) = cos(x)dx : \int cos(x) dx = sin(x) +c

cos'(x) = -sin(x)dx : \int sin(x)dx = -cos(x) +c

二、三角函数的积分

\int sin^n(x)cos^m(x)dx .......( m, n = 0, 1, 2, 3,.... )

1、 简单的情况: m,n 至少有一个是奇数

当m = 1时

\int sin^n(x)cos(x)dx

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

\int u^ndu = \frac{1}{n+1} u^{n+1} +c= \frac{sin^{n+1}(x)}{n+1} +c

当m=2, n=3时

\int sin^3(x)cos^2(x)dx = \int sin(x)(1-cos^2(x))cos^2(x)dx

= \int (cos^2(x)-cos^4(x))sin(x)dx

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

\int - (u^2-u^4)du = \frac{u^5}{5} - \frac{u^3}{3} + c = \frac{cos^5(x)}{5} - \frac{cos^3(x)}{3} + c

当m = 0, n =3时

\int sin^3(x)dx = \int (1-cos^2(x))sin(x)dx

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

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

2、 困难的情况: m,n 都是偶数 (用半角公式)

m = 2, n = 0

\int cos^2(x)dx

cos^2(\theta) =\frac{cos(2\theta)+1}{2}

\int cos^2(x)dx =\int \frac{cos(2x)+1}{2} dx = \frac{sin(2x)}{2\times 2} + \frac{x}{2} +c = \frac{sin(2x)}{4} + \frac{x}{2} +c

m = 2, n = 2

cos^2(\theta) =\frac{cos(2\theta)+1}{2} (半角公式)

sin^2 \theta =\frac{1 - cos(2\theta)}{2} (半角公式)

\int sin^2(x) cos^2(x)dx =\int (1-cos^2(x))cos^2(x)dx

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

\frac{1}{8}\int2 -1-cos(4x)dx = \frac{1}{8}\int1-cos(4x)dx =\frac{1}{8} x- \frac{sin(4x)}{32}+c

sin(2\theta) = 2sin\theta cos\theta (倍角公式)

\int sin^2(x) cos^2(x)dx =\int (sin(x) cos(x))^2dx = \int (\frac{sin(2x)}{2})^2dx

=\int \frac{sin^2(2x)}{4}dx = \int \frac{1}{4}(1-\frac{cos(4x)}{2})dx

\frac{1}{8}\int2 -1-cos(4x)dx = \frac{1}{8}\int1-cos(4x)dx =\frac{1}{8} x- \frac{sin(4x)}{32}+c

三、例子

theta = 45

r = 1
figure, axes = plt.subplots( 1 )  
radius = r

angle = np.linspace( theta/180*np.pi , 2 * np.pi , 150 ) 
xarr = radius * np.cos( angle ) 
yarr = radius * np.sin( angle ) 
axes.plot( xarr, yarr, label='radius=r',color = 'b') 

angle = np.linspace( 0 , theta/180*np.pi , 150 ) 
xarr = radius * np.cos( angle ) 
yarr = radius * np.sin( angle ) 
axes.plot( xarr, yarr, label='' ,color = 'c') 


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)

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

plt.plot([0,0], [0,y1],'c')
plt.plot([0,0], [y1,1],'b')
plt.text( -0.2, y1, 'y=b', fontsize=9)

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

plt.plot([0,x1], [y1,y1],'c')

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

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

plt.text(x1+0.05, y1+0.05, '(r*cosθ ,r*sinθ)', fontsize=9)
plt.text(-0.1, -0.1, 'O', fontsize=9)


plt.legend(loc='upper left')
plt.show() 

1、求上图中浅蓝色线条包裹部分的面积

一般来说是列如: \int f(x)dx求体积,这个例子比较麻烦,需要分开两段计算,因为f(x) 在 x = r \times cos \theta 点前后,有不同的定义。

因为这例子中 f(y) 对 y 轴的包裹面积可以用一个式子表达, 所以考虑用如下算式计算面积: \int f(y) dy

A = \int_{0}^{b} \sqrt{r^2-y^2} dy

\sqrt{r^2-y^2} = \sqrt{r^2-(r\times sin(\theta))^2} = r cos(\theta)

dy = (rsin(\theta))' =rcos(\theta) d\theta

A = \int \sqrt{r^2-y^2} dy = \int r cos(\theta) \times rcos(\theta) d\theta = \int r^2cos^2(\theta)d\theta

由前面例子可知: \int cos^2(x)dx = \frac{sin(2x)}{4} + \frac{x}{2} +c

\int r^2cos^2(\theta)d\theta = r^2 ( \frac{sin(2\theta)}{4} + \frac{\theta}{2}) +c

sin(2\theta) = 2sin\theta cos\theta , \theta = arcsin(\frac{y}{r})

所以:

A = \int \sqrt{r^2-y^2} dy=r^2 ( \frac{2sin(\theta)cos(\theta)}{4} + \frac{\theta}{2} ) + c

= r^2 ( \frac{2\frac{y}{r}\frac{\sqrt{r^2-y^2}}{r}}{4} + \frac{arcsin(\frac{y}{r})}{2} ) +c

= \frac{y\sqrt{r^2-y^2}}{2} + \frac{r^2arcsin(\frac{y}{r})}{2} +c

A = \int_0^b \sqrt{r^2-y^2}

= \frac{y\sqrt{r^2-y^2}}{2} + \frac{r^2arcsin(\frac{y}{r})}{2} +c |_{0}^{b} = \frac{b\sqrt{r^2-b^2}}{2} + \frac{r^2arcsin(\frac{b}{r})}{2}

上面红色三角形的面积正是计算公式这部分\frac{b\sqrt{r^2-b^2}}{2}
 

由扇形面积公式: \frac{lr}{2}(l为弧长), 弧长公式: l = \theta r( \theta 为弧度),\frac{lr}{2} = \frac{r^2\theta}{2}

上面绿色扇形的面积正是计算公式这部分 \frac{r^2arcsin(\frac{b}{r})}{2}

  • 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、付费专栏及课程。

余额充值