资源描述:
《符号计算与数值计算习题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验:MATLAB符号计算与数值计算呢(1-7题为符号计算,8-15为数值计算)1.简化方程。clearf=sym('1/(x^3)+6/(x^2)+12/x+8');simplify(f)yians=(1+6*x+12*x^2+8*x^3)/x^32.验证三角等式clearsymsabf=sym('sin(a)*cos(b)-cos(a)*sin(b)');simple(f)ersimplify:sin(a)*cos(b)-cos(a)*sin(b)radsimp:sin(a)*cos(b)-cos(a)*sin(b)combine(t
2、rig):sin(a-b)factor:sin(a)*cos(b)-cos(a)*sin(b)expand:sin(a)*cos(b)-cos(a)*sin(b)combine:sin(a-b)convert(exp):-1/2*i*(exp(i*a)-1/exp(i*a))*(1/2*exp(i*b)+1/2/exp(i*b))+1/2*i*(1/2*exp(i*a)+1/2/exp(i*a))*(exp(i*b)-1/exp(i*b))convert(sincos):sin(a)*cos(b)-cos(a)*sin(b)convert
3、(tan):2*tan(1/2*a)/(1+tan(1/2*a)^2)*(1-tan(1/2*b)^2)/(1+tan(1/2*b)^2)-2*(1-tan(1/2*a)^2)/(1+tan(1/2*a)^2)*tan(1/2*b)/(1+tan(1/2*b)^2)collect(b):sin(a)*cos(b)-cos(a)*sin(b)mwcos2sin:sin(a)*cos(b)-cos(a)*sin(b)ans=sin(a-b)1.用符号计算。clearsymstxf=sym('1/ln(t)');int(f,t,0,x)sana
4、ns=-Ei(1,-log(x))2.求方程组,关于的解。clearsymstxf=sym('1/ln(t)');int(f,t,0,x)sanans=-Ei(1,-log(x))siclearsymsuvyzwf1=sym('u*y^2+v*z+w=0');f2=sym('y+z+w=0');A=solve(f1,f2,y,z);si>>AA=y:[2x1sym]z:[2x1sym]>>A.yans=-1/2/u*(-2*u*w-v+(4*u*w*v+v^2-4*u*w)^(1/2))-w-1/2/u*(-2*u*w-v-(4*u*w*
5、v+v^2-4*u*w)^(1/2))-w>>A.zans=1/2/u*(-2*u*w-v+(4*u*w*v+v^2-4*u*w)^(1/2))1/2/u*(-2*u*w-v-(4*u*w*v+v^2-4*u*w)^(1/2))3.求的解。clearsymsxytdsolve('Dx=y','Dy=-x')wuA=x:[1x1sym]y:[1x1sym]>>A.xans=-C1*cos(t)+C2*sin(t)>>A.yans=C1*sin(t)+C2*cos(t)1.求极限的命令及结果为clearsymsxtlimit((1+(2*t)
6、/x)^(3*x),x,inf)liuans=exp(6*t)7求矩阵的行列式值、逆和特征根。(特征根函数eig())clearsymsa11a12a21a22A=[a11a12;a21a22]qiA=[a11,a12][a21,a22]>>det(A)ans=a11*a22-a12*a21>>inv(A)ans=[a22/(a11*a22-a12*a21),-a12/(a11*a22-a12*a21)][-a21/(a11*a22-a12*a21),a11/(a11*a22-a12*a21)]>>eig(A)ans=1/2*a11+1/
7、2*a22+1/2*(a11^2-2*a11*a22+a22^2+4*a12*a21)^(1/2)1/2*a11+1/2*a22-1/2*(a11^2-2*a11*a22+a22^2+4*a12*a21)^(1/2)8.建立M文件并执行以下代码:randn('state',0);A=gallery('randsvd',100,2e14,2);x=ones(100,1);b=A*x;此时已得到数据A和b,分别用(1)逆矩阵的方法(2)左除的方法求解该线性方程组AX=b。比较两种方法的计算时间和计算误差。(计算时间用tictoc,真解为x=o
8、nes(100,1))ticrandn('state',0);A=gallery('randsvd',100,2e14,2);x=ones(100,1);b=A*x;a1=inv(A)*b;t