matlab求两向量夹角_MATLAB教程-台大郭彦甫-第十节,含练习答案

10-数值微积分

一、Polynomial differentiation and integration(多项式微分与积分)

(一)Differentiation(微分)

1、The derivative of a function

is written as(微分方程可以写成下列式子)

or

2、The rate of the change in the function

with respect to
(函数变化率,即斜率)

3、Geometrically,

represents the coefficient of the line tangent to the curve in the point
(几何上,微分表示与点中曲线相切的线的系数)

4153ffea5a3518cf3a187678c009c718.png

(二)Polynomial Differentiation(多项式微分)

1、Polynomials are often used in numerical calculations(多项式常用于数值计算)

2、For a polynomial

the derivative is(导数是)

(三)Representing Polynomials in MATLAB(如何表示多项式)

1、Polynomials were represented as row vectors(使用行向量来表示多项式)

2、For example,consider the equation(例如,考虑如何表示以下方程式)

(注意:相当于

3、To enter this polynomial into MATLAB,use(将以下多项式输入MATLAB)

p 

(四)Values of Polynomials:polyval()

1、Polt the polynomial

for

示例代码:

a 

输出结果:

941f10b37c45ba3d15c4c9a761b8b76b.png

(五)Polynomial Differentiation:polyder()(多项式微分)

1、Given

(1)What is the derivative of the function

?(函数的微分是什么)

(2)What is the derivative of the function value of

示例代码:

p 

输出结果:

4b2ffb0ccfbea495b50be248a4c96660.png

六)Excise

1、Plot the polynomial

and its derivative for

2、Hint:conv()

答案代码:

hold 

输出结果:

e2d4b3f542d1a8edaa7f296ae5870051.png

(七)Polynomial Integration(多项式积分)

1、For a polynomial

the integration is

(八)Polynomial Integration:polyint()

1、Given

(1)What is the integral of the function

with a constant of 3?

(2)What is the derivative of the function value of

示例代码:

p 

输出结果:

43d5ef87a2794d650ac79dbe49815736.png

二、Numerical differentiation and integration(数值微分与积分)

(一)Numerical differentiation(数值微分)

1、The simplest method:finite difference approximation(最简单的方法:有限差分逼近)

2、Calculating a secant line in the vicinity of

(计算
附近的割线)

where

represents a small change in
表示在
附近很小的变化)

08557c41b591cbaff884d2176fc9105f.png

(二)Differences:diff()

1、diff() calculates the differences between adjacent elements of a vector

e0b3ea10746c954ca60f0ae7d2c7edd2.png

示例代码:

x 

输出结果:

ca472f9138249a29fb747f15c1cc0894.png

2、Exercise:obtain the slope of a line between 2 points(1,5)and(2,7):(获取两点之间直线的斜率)

c0bf25dab132362fa5935e89fba36402.png

答案代码:

x 

输出结果:

eda76965c2f61d9deecc1a1e601956b9.png

(三)Numerical Differentiation Using diff()

1、Given

,find
at
using

728ff1a2f0251e4b69296504b221fcdf.png

示例代码:

x0 

输出结果:

107418447a4817b827d0739ab8a694d6.png

(四)Excise

1、Given

,write a script to find the error of
at
using various
(求误差)

54eb6a42691add9a67c376c59369f101.png

答案代码:

x0 

输出结果:

ac4b060b427919fc99d18e4820c3754a.png

(五)How to Find the

over An Interval [0,2Π]?

1、In the previous example,

6c94e1d23c99e9c3c02d7dbc31deb947.png

2、Strategy

(1)Create an array in the interval[0,2Π](创建一个区间数组)

(2)The step is the

(步距为h)

(3)Calculate the

at these points(计算)

7929eaa5ff3e3d0cef6da55c967de7a2.png

示例代码:

h 

输出结果:

716062229897cdc1a7a7257d71e0e233.png

(六)Various Step Size

1、The derivative of

calculated using various
values

cbcaeffe14b387ee6810b5534a1ded80.png

示例代码:

g 

输出结果:

298037246edc934741d22515116ee761.png

注意:

%set(gca,"FontName",'symbol');%R2018不用设置字体

具体操作前面的章节已经写出,可参照

country:MATLAB教程-台大郭彦甫-第五节,含练习答案​zhuanlan.zhihu.com

b4653c6af8942b4f1f3656495f28a30b.png

(七)Exercise:

1、Given

,plot the approximate derivatives
of
=0.1,0.01,0.001

83c9baead236148d438c8756d83dd718.png

答案代码:

g 

输出结果:

e2ae2c2043adf5d782e93f2ad8e68d24.png

(八)Second and Third Derivatives(二阶和三阶导数)

1、The second derivative

and third derivative
can be obtain using similar approachs

2、Given

,plot
and
for

示例代码:

x 

输出结果:

c8de91c9afd031ca27608f99f6ac5095.png

(九)Numerical Integration(数值积分)

1、Calculating the numerical value of a definite integral(定积分的数值计算)

2、Quadrature method approximating the integral by using a finite set of points(用有限点集逼近积分的求积法)

490b670a66b70fe9a3678df80646b3f8.png

(十)Numerical Quadrature Rules(数值求积规则)

1、Basic quadrature rules:(基本求积规则)

(1)Minpoint rule(zeroth-order approximation)(用矩形预测大小)

c106711cf4304a7a51cf5a1acd03ae95.png

(2)Trapezoid rule(first-order approximation)(用梯形预测大小)

1d261ecff1cd20a479664ee0b47f3b5a.png

(3)Second-order Rule:1/3Simpson's(辛普森公式)

ec1428c0b968c89377a597a8bbc9dbba.png

(十一)Midpoint Rule Using :sum()

Example:

策略

f611c39242f2a83b254252668c808d38.png

示例代码:

h 

输出结果:

f0feab6c2ed486fa8b2eacccf9f2f154.png

(十二)Trapezoid Rule Using:trapz()

Example:

策略

35847b221bfa62a2a03e72dc27e2820a.png

示例代码:

h 

输出结果:

b85980a810296fd163ad20ef582942c8.png

(十三)Simpson's Rule

Example:

注意:辛普森公式系数大概为12421

示例代码:

h 

输出结果:

c6adcaf216425a3fec656544b4e319aa.png

(十四)Comparison(三种方法的比较)

Mindpoint rule

Trapezoid rule

Simpson's rule

99e3ddc71dba94ef9b87d5db3fc870c4.png

(十五)Review of Function Handles(@)(即C中的构造函数)

1、A handle is a pointer to function(句柄是指向函数的指针)

2、Can be used to pass functions to other functions(句柄是指向函数的指针,可用于将函数传递给其他函数)

示例代码:

function

输出结果:

508302d458988221c5e6b25750794c4f.png

(十六)Numerical Integration :integral()(数值积分)

1、Numerical integration on a function from using global adaptive quadrature and default and default error tolerances(全局自适应求积函数的数值积分)

Example:

示例代码:

y 

输出结果:

a57d515d75d7e9f381362e72f9dce76d.png

(十七)Double and Triple Integrals

1、Example:

示例代码:

f 

输出结果:

9b2e112e2acfb291bf1e3309dcc43e19.png

2、Example:

示例代码:

f 

输出结果:

dd7e3e24c32e6a36f17dac17ff5aa324.png

第十节结束

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值