资源描述:
《MATLAB中的数值计算与符号计算》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、微积分实验(2)MATLAB中的数值计算与符号计算本教程介绍MATLAB在数值计算与符号计算方面的应用.要注意的是MATLAB在数值计算方面,功能强大,但在符号计算方面,直到V5.1版后,才引入Waterloo公司的MapleV4版的核心计算引擎(目前Maple的版本是V7),因此,它的符号计算功能有限,还不能称得上一个真正的数学符号计算软件包.下面我们按照微积分课程的授课顺序,介绍一下MATLAB在这方面的应用.请注意,以下的所有文字说明均用黑色字,MATLAB语句,用红色字,MATLAB的输出结果,用兰色字.
2、◆函数复合命令格式: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)◆设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)ans=
3、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=simple(
4、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+1diff(f,x,2
5、)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)^2/(1+tan(
6、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;x=a*cos(t)^
7、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*log(tan(1/2*x
8、)+1)-2*atan(tan(1/2*x))MATLAB做不到这一点,但这个积分在Mathematica中的计算结果为先画出图形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]求函数的2阶导数y=diff(y,x,2)y=12*x-12计