matlab1-8章课后作业

Matlab 第七章

1.创建符号表达式f(X)=sinx+x。

>> f = sym('sin(x)+x');

2.计算习题1中表达式在

处的值,并将结果设置为以下 5 种精度:小数点之后 1

位、2 位、5 位、10位和20位有效数字。

>> digits(2)

>> vpa(subs(f,pi/6)) ans = 1.0

>> digits(3)

>> vpa(subs(f,pi/6)) ans = 1.02

>> digits(6)

>> vpa(subs(f,pi/6)) ans = 1.0236

>> digits(11)

>> vpa(subs(f,pi/6)) ans =

1.0235987756 >> digits(21)

>> vpa(subs(f,pi/6)) ans =

1.02359877559829870464

3.设x为符号变量,f(x)=x4+x2+1,g(x)=x3+4x2+5x+8,试进行如下运算: (1)f(x)+g(x) (2)f(x)*g(x)

(3)求g(x)的反函数

(4)求g以f(x)为自变量的复合函数

>> f = sym('x^4 + x^2 + 1');

g = sym('x^3 + 4*x^2 + 5*x + 8'); >> f+g ans =

x^4 + x^3 + 5*x^2 + 5*x + 9 >> f*g

ans =

(x^4 + x^2 + 1)*(x^3 + 4*x^2 + 5*x + 8) >> finverse(g)

Warning: Functional inverse is not unique.

> In D:\\Program Files\\MATLAB\\R2011a\\toolbox\\symbolic\\symbolic\\symengine.p>symengine at 52

In sym.finverse at 41 ans =

1/(9*(x/2 + ((x/2 - 82/27)^2 - 1/729)^(1/2) - 82/27)^(1/3)) + (x/2 + ((x/2 - 82/27)^2 - 1/729)^(1/2) - 82/27)^(1/3) - 4/3 >> syms x

>> compose(g,f,x) ans =

4*(x^4 + x^2 + 1)^2 + (x^4 + x^2 + 1)^3 + 5*x^2 + 5*x^4 + 13

4.合并同类项

(1)3x-2x2+5+3x3-2x-5

(2)2x2-3xy+y2-2xy-2x2+5xy-2y+1

>> f = sym('3*x - 2*x^2 + 5 + 3*x^2 - 2*x -5'); >> collect(f) ans = x^2 + x

>> f = sym('2*x^2 - 3*x*y + y^2 - 2*x*y - 2*x^2 + 5*x*y - 2*y + 1'); >> collect(f) ans =

y^2 - 2*y + 1

5.因式分解

(1)7798666进行因数分解,分解为素数乘积的形式 (2)-2m8+512

(3)3a2(x-y)2-4b2(y-x)2

>> sym 779866 ans = 779866

>> factor(779866) ans =

2 149 2617 >> f=sym('-2*m^8+512') f =

512 - 2*m^8 >> factor(f) ans =

-2*(m - 2)*(m + 2)*(m^2 + 4)*(m^4 + 16) >> g=sym('3*a^3*(x-y)^3-4*b^2*(y-x)^2') g =

3*a^3*(x - y)^3 - 4*b^2*(x - y)^2 >> factor(g) ans =

(x - y)^2*(3*a^3*x - 3*a^3*y - 4*b^2)

6.绘制下列函数的图像 (1)(2)

>> f=sym('sin(x)+x^2') f =

sin(x) + x^2

>> ezplot(f,[0,2*pi])

>> g=sym('x^3 + 2*x^2 + 1') g =

x^3 + 2*x^2 + 1 >> ezplot(g,[-2,2])

,,

7. 计算下列各式

(1)(2)(3)(4)

,求,求,

>> limit(sym('(tan(x)-sin(x))/(1-cos(2*x))')) ans = 0

>> y=sym('x^3-2*x^2+sin(x)') y =

sin(x) - 2*x^2 + x^3 >> diff(y) ans =

cos(x) - 4*x + 3*x^2 >> f=sym('x*y*log(x+y)') f =

x*y*log(x + y) >> diff(f,'x') ans =

y*log(x + y) + (x*y)/(x + y) >> diff(f,'y') ans =

x*log(x + y) + (x*y)/(x + y) >> y=sym('ln(1+t)') y =

log(t + 1) >> int(y) ans =

(log(t + 1) - 1)*(t + 1) >> int(y,0,27) ans =

28*log(28) - 27

8.计算下列各式

(1)

(2)(3)

在 0 附近的Taylor 展开

>> symsum(sym('(3/n)^n'),1,inf) ans =

sum(3^n/n^n, n = 1..Inf)

>> symsum(sym('2^n*sin(pi/(3^n))'),1,inf) ans =

sum(2^n*sin(pi/3^n), n = 1..Inf)

>> taylor(sym('sin(x)')) ans =

x^5/120 - x^3/6 + x

9.求解线性方程组

>> [x,y] = solve(sym('2*x+3*y=1'),sym('3*x+2*y=-1')) x = -1 y = 1

10.对符号表达式z=xe-x2-y2,进行如下变换 (1)关于的傅立叶变换 (2)关于

的拉普拉斯变换

的 Z 变换

(3)分别关于和

>> syms x y

>> z=x*exp(-(x^2)+y^2) z =

x*exp(y^2 - x^2) >> syms u v >> fourier(z,x,u) ans =

-(pi^(1/2)*u*exp(y^2 - u^2/4)*i)/2 >> laplace(z,y,v) ans =

x*laplace(exp(y^2 - x^2), y, v) >> ztrans(z,y,v) ans =

x*ztrans(exp(y^2 - x^2), y, v)

11.绘制函数在,上的表面图

>> syms x y

>> z = 1/(2*pi)*exp(-(x^2+y^2)) z =

5734161139222659/(36028797018963968*exp(x^2 + y^2)) >> ezsurf(x,y,z,[-3,3,-3,3])

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4