1 / 25

第三节 导数的运算

第三节 导数的运算. 1 、 MATLAB 求导 2 、 MATLAB 求函数零点 3 、 MATLAB 求极值 4 、最优化模型举例 5 、小结. 一、 MATLAB 求导. 1 、导数运算命令. diff (f,x). diff (f,x,n). diff (‘S’,’x’). diff (‘S’,’x’,n). 2 、运行格式. >> syms x >> 命令. 解:. >> syms x >> diff(asin(sqrt(1-x^2))) ans = -1/(1-x^2)^(1/2)*x/(x^2)^(1/2).

duscha
Download Presentation

第三节 导数的运算

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第三节 导数的运算 • 1、MATLAB求导 • 2、MATLAB求函数零点 • 3、MATLAB求极值 • 4、最优化模型举例 • 5、小结

  2. 一、MATLAB求导 1、导数运算命令 diff (f,x) diff (f,x,n) diff (‘S’,’x’) diff (‘S’,’x’,n)

  3. 2、运行格式 >> syms x >> 命令 解: >> syms x >> diff(asin(sqrt(1-x^2))) ans = -1/(1-x^2)^(1/2)*x/(x^2)^(1/2)

  4. >> syms x >> y=((1-(1-x^2)^2)/(1+(1-x^2)^2))^3;diff(y) ans = 12*(1-(1-x^2)^2)^2/(1+(1-x^2)^2)^3*(1-x^2)*x+12*(1-(1-x^2)^2)^3/(1+(1-x^2)^2)^4*(1-x^2)*x

  5. >> syms x >> diff((cos(x))^2*log(x),x,3) ans = 8*cos(x)*log(x)*sin(x)+6*sin(x)^2/x+6*cos(x)/x^2*sin(x)-6*cos(x)^2/x+2*cos(x)^2/x^3

  6. >> syms x y >> diff('y(x)=sin(x+y(x))','x') ans = diff(y(x),x) = cos(x+y(x))*(1+diff(y(x),x))

  7. 二、利用Mat lab求函数零点 1、求多项式的根 roots([A,B,C,…..,S,T])=求f(x)=0的根 注意(remark): (1)系数要按由高到低依次来输入。 (2)中间某个次数没有认为系数为零。

  8. >> syms x >> roots([-2,5.2,-4.8,7,0,2,9.8,1]) ans = 2.3248 0.7631 + 1.0729i 0.7631 - 1.0729i -0.1847 + 1.2228i -0.1847 - 1.2228i -0.7774 -0.1044 解:

  9. 2、求一元函数的零点 命令格式为: fzero(‘fun’,[a,b]) =求方程fun=0在[a,b]内的近似根 fzero(‘fun’, a) =求方程fun=0在a点附近的近似根 一般步骤为:(1)作图确定根的大致范围; (2)逐次缩小区间,输入命令。

  10. >> fplot('x-exp(-x)',[-10,10]) >> fplot('x-exp(-x)',[-5,5]) >> fplot('x-exp(-x)',[-2,2]) >> fplot('x-exp(-x)',[0,1]) >> syms x >> fzero('x-exp(-x)',[0,1]) ans = 0.5671 解:

  11. 3、求方程或方程组的解 求N个方程N个未知数的方程组解命令格式为: [var1,var2…varN]= solve(‘eqn1’,’eqn2’,……’eqnN’,’var1’,’var2’…’varN’) (其中‘eqnN’表示第N个方程式;‘varN’为第N个变量)

  12. >> [x,y]=solve('x^2+y-6','y^2+x-6','x','y') x = [ 2] [ -3] [ 1/2-1/2*21^(1/2)] [ 1/2+1/2*21^(1/2)] y = [ 2] [ -3] [ 1/2+1/2*21^(1/2)] [ 1/2-1/2*21^(1/2)]

  13. Example8:某实验室用500只老鼠做某一传染性疾病实验,以检验它的传播理论。由实验分析得到 t天后,感染数目N的数学模型如下: (1)实验开始时,有多少只老鼠感染此疾病? (2)什么时候有一半的老鼠感染此疾病? (3)预测很多天后,传染病的传播数量。

  14. >> syms t >> t=0;N=500/(1+99*exp(-0.2*t)) N = 5 >> solve('500/(1+99*exp(-0.2*t))=250','t') ans = 22.975599250672949634262170259051 >> limit(500/(1+99*exp(-0.2*t)),t,inf) ans = 500

  15. 三、MATLAB求极值 1、求极小值点命令 fmin(’fun’, a , b)------ 求函数y=fun在区间[a,b]内极小值点。 2、利用求导数、驻点的方法求极值点。

  16. >> syms x y >> y=x^2;x0=fmin('x^2',-2,2) >> dy=diff('x^2',x) dy = 2*x x0 = -5.5511e-017 >> y=x^2;x0=fmin('x^2',-0.2,0.2) >> x0=solve(dy) x0 = 0 x0 = 0 >> y0=subs(y,0) y0 = 0

  17. 四、最优化模型举例 最优问题求解步骤: (1)建立目标函数(对问题建立数学模型); (2)求最值;

  18. 解:(1)问题假设:设截掉小正方形边长为x;方盒容积为V解:(1)问题假设:设截掉小正方形边长为x;方盒容积为V (2)模型建立: (3)模型求解:

  19. >> d2y=diff('(6-2*x)^2*x',x,2) d2y = 24*x-48 >> subs(d2y,1) ans = -24 >> syms x >> dy=diff('(6-2*x)^2*x',x) dy = -4*(6-2*x)*x+(6-2*x)^2 >> x0=solve(dy) x0 = [ 1] [ 3] >> y=(6-2*x)^2*x;y0=subs(y,x0) y0 = [ 16] [ 0]

  20. 解:(1)问题假设:设底半径为r;高为h; 表面积为S (2)模型建立: (3)模型求解:

  21. >> syms r >> S=32*pi/r+2*pi*r^2;dS=diff(S,r) dS = -32*pi/r^2+4*pi*r >> r0=solve(dS) r0 = [ 2] [ -1+i*3^(1/2)] [ -1-i*3^(1/2)] >> d2S=diff(S,r,2) d2S = 64*pi/r^3+4*pi >> subs(d2S,2) ans = 37.6991 >> S0=subs(S,r0) S0 = [ 24*pi]

  22. 解:(1)问题假设:设售出x单位时利润为L. (2)模型建立: (3)模型求解:

  23. >> syms x >> L=-300-x^3/12+5*x^2-36*x;dL=diff(L,x) dL = -1/4*x^2+10*x-36 >> x0=solve(dL) x0 = [ 4] [ 36] >> subs(d2L,x0) ans = [ 8] [ -8] >> y0=subs(L,x0) y0 = [ -1108/3] [ 996] >> d2L=diff(L,x,2) d2L = -1/2*x+10

  24. 五、小结 1、MATLAB求导 2、MATLAB求函数零点 3、MATLAB求极值 4、最优化模型举例

More Related