資源描述:
《matlab中的數(shù)值計算與符號計算.ppt》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、微積分實驗(2)MATLAB中的數(shù)值計算與符號計算本教程介紹MATLAB在數(shù)值計算與符號計算方面的應(yīng)用.要注意的是MATLAB在數(shù)值計算方面,功能強(qiáng)大,但在符號計算方面,直到V5.1版后,才引入Waterloo公司的MapleV4版的核心計算引擎(目前Maple的版本是V7),因此,它的符號計算功能有限,還不能稱得上一個真正的數(shù)學(xué)符號計算軟件包.下面我們按照微積分課程的授課順序,介紹一下MATLAB在這方面的應(yīng)用.請注意,以下的所有文字說明均用黑色字,MATLAB語句,用紅色字,MATLAB的輸出結(jié)果,用蘭色
2、字.◆函數(shù)復(fù)合命令格式:compose(f,g,x),即求f(g(x);例子:symsf,x;f=sin(x);compose(f,f,x)ans=sin(sin(x))symsf,x;f=sin(x);g=1+x^2;compose(f,g,x)ans=sin(1+x^2)◆設(shè)f(sin(x/2))=cos(x)+1,求f(x)與f(cos(x/2)).symsx,f;old='cos(x)';new='1-2*sin(x/2)^2';subs('f(sin(x/2))=cos(x)+1',old,new)
3、ans=f(sin(x/2))=(1-2*sin(x/2)^2)+1symsu;subs(ans,'sin(x/2)',u)ans=f(u)=2-2*u^2Symsx,f,g;f=x/sqrt(1+x^2);g=x;g=simple(compose(f,f,x))f=x/(1+x^2)^(1/2)g=x/(2*x^2+1)^(1/2)g=simple(compose(g,f,x))g=x/(3*x^2+1)^(1/2)g=simple(compose(g,f,x))g=x/(4*x^2+1)^(1/2)g=s
4、imple(compose(g,f,x))g=x/(5*x^2+1)^(1/2)symsx,f;f=sin(x)^2/(1+cot(x))+cos(x)^2/(1+tan(x));diff(f,x)Ans=2*sin(x)/(1+cot(x))*cos(x)-sin(x)^2/(1+cot(x))^2*(-1-cot(x)^2)-2*cos(x)/(1+tan(x))*sin(x)-cos(x)^2/(1+tan(x))^2*(1+tan(x)^2)simple(ans)ans=-2*cos(x)^2+1di
5、ff(f,x,2)ans=2*cos(x)^2/(1+cot(x))-4*sin(x)/(1+cot(x))^2*cos(x)*(-1-cot(x)^2)-2*sin(x)^2/(1+cot(x))+2*sin(x)^2/(1+cot(x))^3*(-1-cot(x)^2)^2+2*sin(x)^2/(1+cot(x))^2*cot(x)*(-1-cot(x)^2)+2*sin(x)^2/(1+tan(x))+4*cos(x)/(1+tan(x))^2*sin(x)*(1+tan(x)^2)-2*cos(x)
6、^2/(1+tan(x))+2*cos(x)^2/(1+tan(x))^3*(1+tan(x)^2)^2-2*cos(x)^2/(1+tan(x))^2*tan(x)*(1+tan(x)^2)simple(ans)ans=4*sin(x)*cos(x)symsxyzfg;f=exp(z)-z+x*y-3;g=jacobian(f,[x,y,z])g=[y,x,exp(z)-1]g(1)ans=yg(2)ans=xg(3)ans=exp(z)-1g(1)/g(3)ans=y/(exp(z)-1)symsxyta
7、;x=a*cos(t)^3;y=a*sin(t)^3;y=simple(diff(y,t)/diff(x,t))y=-tan(t)simple(diff(y,t)/diff(x,t))ans=1/3/cos(t)^4/a/sin(t)symsx;int((1-sin(x)+cos(x))/(1+sin(x)-cos(x)))ans=2*log(tan(1/2*x))-2*log(tan(1/2*x)+1)-2*atan(tan(1/2*x))simple(ans)ans=2*log(tan(1/2*x))-2
8、*log(tan(1/2*x)+1)-2*atan(tan(1/2*x))MATLAB做不到這一點,但這個積分在Mathematica中的計算結(jié)果為先畫出圖形symsxy;y=2*x^3-6*x^2-18*x+7;ezplot(y,[-5,5])再求出駐點(有2個,分別為-1及3)solve(diff(y,x),x)ans=[-1][3]求函數(shù)的2階導(dǎo)數(shù)y=diff(y,x,2)y=12*x-12計