matlab教程--matlab快速入门-文字版, matlab电子书, 和matlab diff有关的电子书:

4.2.1 导数 -matlab求导数

4.2.1 导数


在MATLAB系统中为用户提供了一元显函数求导的符号计算函数diff,可以调用此函数求符号导数,不但使用方便,而且计算准确,迅速,尤其是求结构复杂的高阶导数更显示出其优越性。用diff可以求一元显函数的各阶导函数和在某点处的各阶导数。在这里将一元显函数的各阶导函数分别记作。用diff 作符号求导函数和在一点处的导数的调用格式和功能如表4-1。


表4-1  求一元显函数的各阶导函数的MATLAB方法

符号求导的命令

功  能

yx=diff(f(x),x)

求函数的一阶导函数

yxx=diff(f(x),x,2)

或yxx=diff(yx,x)

求函数的二阶导函数

yxxx=diff(f(x),x,3)

或yxxx=diff(yxx,x)

求函数的三阶导函数

yxn=diff(f(x),x,n)

求函数阶导函数

yn=simple(yxn)

阶导函数化简,并记作yn。

pretty(diff(f(x),x)

输出一个符合日常书写习惯的表达式

[例1]  设一元函数,求的一阶导函数和四阶导函数

解  下面用函数diff的两种调用格式求解。

(1)输入计算的一阶导函数和四阶导函数的程序:

>> syms x y

y=atan(3*x^2+2*sin(5*x^3-2));

yx=diff (y,x);

yx4=diff (y,x,4);

y1=simple(yx), pretty(y1)

y4=simple(yx4), pretty(y4)

运行后屏幕显示的一阶导数和四阶导数如下:

y1 =

(6*x+30*cos(5*x^3-2)*x^2)/(1+(3*x^2+2*sin(5*x^3-2))^2)

y4 =

(101250*sin(5*x^3-2)*x^8-81000*cos(5*x^3-2)*x^5-9000*sin(5*x^3-2)*x^2)/(1+(3*x^2+2*sin(5*x^3-2))^2)-8*(-6750*cos(5*x^3-2)*x^6-2700*sin(5*x^3-2)*x^3+60*cos(5*x^3-2))/(1+(3*x^2+2*sin(5*x^3-2))^2)^2*(3*x^2+2*sin(5*x^3-2))*(6*x+30*cos(5*x^3-2)*x^2)+48*(6-450*sin(5*x^3-2)*x^4+60*cos(5*x^3-2)*x)/(1+(3*x^2+2*sin(5*x^3-2))^2)^3*(3*x^2+2*sin(5*x^3-2))^2*(6*x+30*cos(5*x^3-2)*x^2)^2-12*(6-450*sin(5*x^3-2)*x^4+60*cos(5*x^3-2)*x)/(1+(3*x^2+2*sin(5*x^3-2))^2)^2*(6*x+30*cos(5*x^3-2)*x^2)^2-6*(6-450*sin(5*x^3-2)*x^4+60*cos(5*x^3-2)*x)^2/(1+(3*x^2+2*sin(5*x^3-2))^2)^2*(3*x^2+2*sin(5*x^3-2))-48*(6*x+30*cos(5*x^3-2)*x^2)^4/(1+(3*x^2+2*sin(5*x^3-2))^2)^4*(3*x^2+2*sin(5*x^3-2))^3+24*(6*x+30*cos(5*x^3-2)*x^2)^4/(1+(3*x^2+2*sin(5*x^3-2))^2)^3*(3*x^2+2*sin(5*x^3-2))

(2) 用下面的MATLAB程序分别计算的一阶导数和四阶导数:

>> syms x y

yx=diff((6*x+30*cos(5*x^3-2)*x^2)/(1+(3*x^2+2*sin(5*x^3-2))^2),x)

yx4=diff((6*x+30*cos(5*x^3-2)*x^2)/(1+(3*x^2+2*sin(5*x^3-2))^2),x,4)

所得到的结果与(1)相同。


[例2]  设一元函数

(1)求的一阶导函数和五阶导函数;

(2)求处的一阶导数和五阶导数

解 (1)输入计算的一阶导函数和五阶导函数的程序:

>> syms x y

y=(3*x^2+2*cos(5*x^3-2))*log(13*x^5+6)+(2*x-1)/(5*x^2+6);

yx=diff (y,x,1);

yx5=diff (y,x,5);

y1=simple(yx)

y5=simple(yx5)

运行后屏幕显示化简后的的一阶导函数y1和五阶导函数y5如下:

y1 =

(6*x-30*sin(5*x^3-2)*x^2)*log(13*x^5+6)+65*(3*x^2+2*cos(5*x^3-2))*x^4/(13*x^5+6)+2/(5*x^2+6)-10*(2*x-1)/(5*x^2+6)^2*x

y5 =

2400000*(2*x-1)/(5*x^2+6)^5*x^3-507000*(6-450*cos(5*x^3-2)*x^4-60*sin(5*x^3-2)*x)*x^7/(13*x^5+6)^2-2028000*(6*x-30*sin(5*x^3-2)*x^2)*x^6/(13*x^5+6)^2+325*(101250*cos(5*x^3-2)*x^8+81000*sin(5*x^3-2)*x^5-9000*cos(5*x^3-2)*x^2)*x^4/(13*x^5+6)+7800*(6-450*cos(5*x^3-2)*x^4-60*sin(5*x^3-2)*x)*x^2/(13*x^5+6)+7800*(6*x-30*sin(5*x^3-2)*x^2)*x/(13*x^5+6)-90000*(2*x-1)/(5*x^2+6)^4*x-360000/(5*x^2+6)^4*x^2+(-1518750*sin(5*x^3-2)*x^10+2025000*cos(5*x^3-2)*x^7+540000*sin(5*x^3-2)*x^4-18000*cos(5*x^3-2)*x)*log(13*x^5+6)+2400000/(5*x^2+6)^5*x^4+6000/(5*x^2+6)^3+197730000*(3*x^2+2*cos(5*x^3-2))*x^10/(13*x^5+6)^3+2600*(6750*sin(5*x^3-2)*x^6-2700*cos(5*x^3-2)*x^3-60*sin(5*x^3-2))*x^3/(13*x^5+6)+1560*(3*x^2+2*cos(5*x^3-2))/(13*x^5+6)-42250*(6750*sin(5*x^3-2)*x^6-2700*cos(5*x^3-2)*x^3-60*sin(5*x^3-2))*x^8/(13*x^5+6)^2+5492500*(6-450*cos(5*x^3-2)*x^4-60*sin(5*x^3-2)*x)*x^12/(13*x^5+6)^3+65910000*(6*x-30*sin(5*x^3-2)*x^2)*x^11/(13*x^5+6)^3-535518750*(6*x-30*sin(5*x^3-2)*x^2)*x^16/(13*x^5+6)^4-4284150000*(3*x^2+2*cos(5*x^3-2))*x^15/(13*x^5+6)^4+27846975000*(3*x^2+2*cos(5*x^3-2))*x^20/(13*x^5+6)^5-12000000*(2*x-1)/(5*x^2+6)^6*x^5-2535000*(3*x^2+2*cos(5*x^3-2))*x^5/(13*x^5+6)^2

(2)输入计算处的一阶导数和五阶导数的程序:

>> x=0;

y1=(6*x-30*sin(5*x^3-2)*x^2)*log(13*x^5+6)+65*(3*x^2+2*cos(5*x^3......-2))*x^4/(13*x^5+6)+2/(5*x^2+6)-10*(2*x-1)/(5*x^2+6)^2*x,

y5=2400000*(2*x-1)/(5*x^2+6)^5*x^3-507000*(6-450*cos(5*x^3-2)*x^4......-60*sin(5*x^3-2)*x)*x^7/(13*x^5+6)^2-2028000*(6*x-30*sin(5*x^3-2)*x^2)*x^6/(13*x^5+6)^2+325*(101250*cos(5*x^3-2)*x^8+81000*sin(5*x^3-2)*x^5-9000*cos(5*x^3-2)*x^2)*x^4/(13*x^5+6)+7800*(6-450*cos(5*x^3-2)*x^4-60*sin(5*x^3-2)*x)*x^2/(13*x^5+6)+7800*(6*x-30*sin(5*x^3-2)*x^2)*x/(13*x^5+6)-90000*(2*x-1)/(5*x^2+6)^4*x-360000/(5*x^2+6)^4*x^2+(-1518750*sin(5*x^3-2)*x^10+2025000*cos(5*x^3-2)*x^7+540000*sin(5*x^3-2)*x^4-18000*cos(5*x^3-2)*x)*log(13*x^5+6)+2400000/(5*x^2+6)^5*x^4+6000/(5*x^2+6)^3+197730000*(3*x^2+2*cos(5*x^3-2))*x^10/(13*x^5+6)^3+2600*(6750*sin(5*x^3-2)*x^6-2700*cos(5*x^3-2)*x^3-60*sin(5*x^3-2))*x^3/(13*x^5+6)+1560*(3*x^2+2*cos(5*x^3-2))/(13*x^5+6)-42250*(6750*sin(5*x^3-2)*x^6-2700*cos(5*x^3-2)*x^3-60*sin(5*x^3-2))*x^8/(13*x^5+6)^2+5492500*(6-450*cos(5*x^3-2)*x^4-60*sin(5*x^3-2)*x)*x^12/(13*x^5+6)^3+65910000*(6*x-30*sin(5*x^3-2)*x^2)*x^11/(13*x^5+6)^3-535518750*(6*x-30*sin(5*x^3-2)*x^2)*x^16/(13*x^5+6)^4-4284150000*(3*x^2+2*cos(5*x^3-2))*x^15/(13*x^5+6)^4+27846975000*(3*x^2+2*cos(5*x^3-2))*x^20/(13*x^5+6)^5-12000000*(2*x-1)/(5*x^2+6)^6*x^5-2535000*(3*x^2+2*cos(5*x^3-2))*x^5/(13*x^5+6)^2

运行后屏幕显示处的一阶导数y1和五阶导数y5如下:

y1 =

    0.3333

y5 =

 -188.6186


[例3] 求下列函数的导数

(1)  ; (2) 

解 输入程序:

>>  syms x

y=(log(5*x))^(x+2);

f=3*x^3*(sqrt((23-6*x^5)/(6+7*x)^2))/(1-2*x);

yx=diff (y,x);

fx=diff(f,x);

y1=simple(yx)

f1=simple(fx)

运行后屏幕显示(1)和(2)的导数分别为f1和y1如下:

y1 =

log(5*x)^(x+2)*(log(log(5*x))+(x+2)/x/log(5*x))

f1 =

3*(294*x^7+135*x^6-198*x^5-322*x^2-230*x+414)*x^2/(23-6*x^5)^(1/2)/(-1+2*x)^2/(6+7*x)^2


欢迎转载,转载请注明来自一手册:http://yishouce.com/book/2/2040201.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1