南京邮电大学数学实验A 作业4 符号计算 答案 | 《MATLAB数学实验》第三版 第七章 课后习题答案

发布于:2024-04-28 ⋅ 阅读:(34) ⋅ 点赞:(0)

若要获得更好的阅读体验,请前往 链接

求点赞。

1(课本习题2)

做因式分解 f ( x ) = x 4 − 5 x 3 + 5 x 2 + 5 x − 6 f(x) = x^{4} - 5x^{3} + 5x^{2} + 5x - 6 f(x)=x45x3+5x2+5x6.

代码:

syms x;
f = x^4-5*x^3+5*x^2+5*x-6;
factor(f)

输出:

( x − 1 x − 2 x − 3 x + 1 ) (\begin{matrix} x - 1 & x - 2 & x - 3 & x + 1 \end{matrix}) (x1x2x3x+1)

2(课本习题3)

求矩阵 A = ( 1 2 2 a ) A = \begin{pmatrix}1 & 2 \\ 2 & a \end{pmatrix} A=(122a)的逆和特征值.

代码:

syms a;
A = [1 2;2 a];
iA = inv(A)
e = eig(A)

答:

该矩阵的逆(iA)为 ( a a − 4 − 2 a − 4 2 a − 4 1 a − 4 ) (\begin{matrix} \frac{a}{a - 4} & - \frac{2}{a - 4} \\ \frac{2}{a - 4} & \frac{1}{a - 4} \end{matrix}) (a4aa42a42a41)
特征值(e)为 ( a 2 − a 2 − 2   a + 17 2 + 1 2   a 2 + a 2 − 2   a + 17 2 + 1 2 ) (\begin{array}{r} \frac{a}{2} - \frac{\sqrt{a^{2} - 2\, a + 17}}{2} + \frac{1}{2} \\\ \frac{a}{2} + \frac{\sqrt{a^{2} - 2\, a + 17}}{2} + \frac{1}{2} \end{array}) (2a2a22a+17 +21 2a+2a22a+17 +21)

3(课本习题4)

计算极限

lim ⁡ x → ∞ ( 3 x + 9 x ) 1 x , lim ⁡ y → 0 + lim ⁡ x → 0 + ln ⁡ ( 2 x + e − y ) x 3 + y 2 , lim ⁡ x → ∞ ln ⁡ ( 1 + 1 x ) a r c c o t   x , lim ⁡ x → 0 1 − 1 − x 2 e x − cos ⁡ x \lim_{x \rightarrow \infty}\left( 3^{x} + 9^{x} \right)^{\frac{1}{x}},\lim_{y \rightarrow 0^{+}}{\lim_{x \rightarrow 0^{+}}\frac{\ln{(2x + e^{- y})}}{\sqrt{x^{3} + y^{2}}}},\\ \lim_{x \rightarrow \infty}\frac{\ln{(1 + \frac{1}{x})}}{arccot \, x},\lim_{x \rightarrow 0}\frac{1 - \sqrt{1 - x^{2}}}{e^{x} - \cos x} xlim(3x+9x)x1,y0+limx0+limx3+y2 ln(2x+ey)xlimarccotxln(1+x1),x0limexcosx11x2

代码:

syms x y;
ans1 = limit((3^x+9^x)^(1/x),x,inf)
temp1 = limit(log(2*x+exp(-y))/(sqrt(x^3+y^2)-1),x,0);
ans2 = limit(s1,y,0)
ans3 = limit(log(1+1/x)/acot(x),x,inf)
ans4 = limit((1-sqrt(1-x^2))/(exp(x)-cos(x)),x,inf)

输出:

ans1 = 9

ans2 = 0

ans3 = 1

ans4 = 0

4(课本习题5)

计算

∑ k = 1 n k 2 ,   ∑ k = 1 ∞ 1 k 2 ,   ∑ n = 0 ∞ 1 ( 2 n + 1 ) ( 2 x + 1 ) 2 n + 1 . \sum_{k = 1}^{n}k^{2},\ \sum_{k = 1}^{\infty}\frac{1}{k^{2}},\ \sum_{n = 0}^{\infty}\frac{1}{(2n + 1)(2x + 1)^{2n + 1}}. k=1nk2, k=1k21, n=0(2n+1)(2x+1)2n+11.

代码:

syms k n x;
s1=symsum(k^2,k,1,n);
s2=symsum(k^(-2),k,1,inf);
s3=symsum(1/(2*n+1)/(2*x+1)^(2*n+1),n,0,inf);
s1=simplify(s1)
s2=simplify(s2)
s3=simplify(s3)

输出:

s1 = n   ( 2   n + 1 )   ( n + 1 ) 6 \frac{n\,(2\, n + 1)\,(n + 1)}{6} 6n(2n+1)(n+1)

s2 = π 2 6 \frac{\pi^{2}}{6} 6π2

s3 = a t a n h ( 1 2 x + 1 )  if  1 < ∥ 2 x + 1 ∥ atanh(\frac{1}{2x + 1}) \text{ if }1 < \|2x + 1\| atanh(2x+11) if 1<∥2x+1∥

5(课本习题6)

  ∂ 3 ∂ x 2 ∂ y sin ⁡ ( x 2 y z ) ∥ x = 1 , y = 1 , z = 3 \left. \ \frac{\partial^{3}}{\partial x^{2}\partial y}\sin\left( x^{2}y z \right) \right\|_{x = 1,y = 1,z = 3}  x2y3sin(x2yz) x=1,y=1,z=3.

代码:

syms x y z;
s=sin(x^2*y*z);
s=diff(s,x,2);
s=diff(s,y,1);
s=subs(s,{x,y,z},{1,1,3})

输出:

s = l o g ( x + x 2 + 1 ) log(x + \sqrt{x^{2} + 1}) log(x+x2+1 )

6(课本习题7)

(Taylor展开)求下列函数在 x = 0 x = 0 x=0的Taylor幂级数展开式(n=8):

e x , ln ⁡ ( 1 + x ) , sin ⁡ x , e^{x}, \ln{(1 + x)}, \sin x, ex,ln(1+x),sinx,

ln ⁡ ( x + 1 + x 2 ) , 1 x 2 − 3 x + 2 . \ln{(x + \sqrt{1 + x^{2}})}, \frac{1}{x^{2} - 3x + 2}. ln(x+1+x2 ),x23x+21.

输出:

syms x
f1 = exp(x);
f2 = log(1+x);
f3 = sin(x);
f4 = log(x+sqrt(1+x^2));
f5 = 1/(x^2-3*x+2);
f = [f1 f2 f3 f4 f5];
for i=1:length(f)
    taylor(f(i), x, 'Order', 9, 'ExpansionPoint', 0)
end

输出:

ans =
x 8 40320 + x 7 5040 + x 6 720 + x 5 120 + x 4 24 + x 3 6 + x 2 2 + x + 1 \frac{x^{8}}{40320} + \frac{x^{7}}{5040} + \frac{x^{6}}{720} + \frac{x^{5}}{120} + \frac{x^{4}}{24} + \frac{x^{3}}{6} + \frac{x^{2}}{2} + x + 1 40320x8+5040x7+720x6+120x5+24x4+6x3+2x2+x+1

ans =
− x 8 8 + x 7 7 − x 6 6 + x 5 5 − x 4 4 + x 3 3 − x 2 2 + x - \frac{x^{8}}{8} + \frac{x^{7}}{7} - \frac{x^{6}}{6} + \frac{x^{5}}{5} - \frac{x^{4}}{4} + \frac{x^{3}}{3} - \frac{x^{2}}{2} + x 8x8+7x76x6+5x54x4+3x32x2+x

ans = − x 7 5040 + x 5 120 − x 3 6 + x - \frac{x^{7}}{5040} + \frac{x^{5}}{120} - \frac{x^{3}}{6} + x 5040x7+120x56x3+x

ans =
− 5   x 7 112 + 3   x 5 40 − x 3 6 + x - \frac{5\, x^{7}}{112} + \frac{3\, x^{5}}{40} - \frac{x^{3}}{6} + x 1125x7+403x56x3+x

ans =
511   x 8 512 + 255   x 7 256 + 127   x 6 128 + 63   x 5 64 + 31   x 4 32 + 15   x 3 16 + 7   x 2 8 + 3   x 4 + 1 2 \frac{511\, x^{8}}{512} + \frac{255\, x^{7}}{256} + \frac{127\, x^{6}}{128} + \frac{63\, x^{5}}{64} + \frac{31\, x^{4}}{32} + \frac{15\, x^{3}}{16} + \frac{7\, x^{2}}{8} + \frac{3\, x}{4} + \frac{1}{2} 512511x8+256255x7+128127x6+6463x5+3231x4+1615x3+87x2+43x+21

7(课本习题9)

计算下列不定积分并用diff验证:

∫ e 2 x ( tan ⁡ x + 1 ) 2 d x , ∫ e 2 y e y + 2 d y ,   ∫ x 2 a 2 − x 2 d x , \int e^{2x}(\tan x+1)^2dx,\int\frac{e^{2y}}{e^y+2}dy,\:\int\frac{x^2}{\sqrt{a^2-x^2}}dx, e2x(tanx+1)2dx,ey+2e2ydy,a2x2 x2dx,

∫ e x − 2 d x ,   ∫ d x x ( ln ⁡ x + a + ln ⁡ x + b )   ( a ≠ b ) . \int e^{x^{-2}}dx,\:\int\frac{dx}{x(\sqrt{\ln x+a}+\sqrt{\ln x+b})}\:(a\neq b). ex2dx,x(lnx+a +lnx+b )dx(a=b).

代码:


function intf(f,symbol)
    fi = int(f,symbol)
    s = simplify(diff(fi));
    if (f / s == 1)
        fprintf('经验证,运算结果正确。')
    end
end


% 7.1
syms x;
f1 = exp(2*x)*(tan(x)+1)^2;
intf(f1,x);

% 7.2
syms y;
f2 = exp(2*y)/(exp(y)+2);
intf(f2,y)


% 7.3
syms x a;
f3 = x^2/sqrt(a^2-x^2);
intf(f3,x)

% 7.4
syms x;
f4 = exp(x^(-2));
intf(f4,x)

% 7.5
syms x;
syms a b;
assume(a ~= b);
f5 = 1/x/(sqrt(log(x)+a)+sqrt(log(x)+b));
intf(f5,x)

输出:

fi = e 2   x   tan ⁡ ( x ) e^{2\, x}\,\tan(x) e2xtan(x)
经验证,运算结果正确。

fi = e y − 2   log ⁡ ( e y + 2 ) e^{y} - 2\,\log(e^{y} + 2) ey2log(ey+2)

fi =
a 2   a t a n ( x a 2 − x 2 ) 2 − x   a 2 − x 2 2 \frac{a^{2}\, atan(\frac{x}{\sqrt{a^{2} - x^{2}}})}{2} - \frac{x\,\sqrt{a^{2} - x^{2}}}{2} 2a2atan(a2x2 x)2xa2x2

经验证,运算结果正确。

fi = x   expint ( 3 2 , − 1 x 2 ) 2 \frac{x\,\text{expint}(\frac{3}{2}, - \frac{1}{x^{2}})}{2} 2xexpint(23,x21)

fi =
a + log ⁡ ( x )   ( 2   a 3   a − 3   b + 2   log ⁡ ( x ) 3   a − 3   b ) − b + log ⁡ ( x )   ( 2   b 3   a − 3   b + 2   log ⁡ ( x ) 3   a − 3   b ) \sqrt{a + \log(x)}\,\left( \frac{2\, a}{3\, a - 3\, b} + \frac{2\,\log(x)}{3\, a - 3\, b} \right) - \sqrt{b + \log(x)}\,\left( \frac{2\, b}{3\, a - 3\, b} + \frac{2\,\log(x)}{3\, a - 3\, b} \right) a+log(x) (3a3b2a+3a3b2log(x))b+log(x) (3a3b2b+3a3b2log(x))

8(课本习题10)

计算积分 I ( x ) = ∫ − x x ( x − y ) 3 sin ⁡ ( x + 2 y ) d y I(x) = \int_{- x}^{x}{(x - y)^{3}\sin{(x + 2y)}}dy I(x)=xx(xy)3sin(x+2y)dy.

代码:

syms x y;
f=(x-y)^3*sin(x+2*y);
Ix=simplify(int(f,y,-x,x))

输出:

Ix =
4   x 3   c o s ( x ) − 3   x 2   s i n ( x ) + 3   c o s ( x ) 2   s i n ( x ) 2 − 3   x   c o s ( x ) 2 4\, x^{3}\, cos(x) - 3\, x^{2}\, sin(x) + \frac{3\,{cos(x)}^{2}\, sin(x)}{2} - \frac{3\, x\, cos(x)}{2} 4x3cos(x)3x2sin(x)+23cos(x)2sin(x)23xcos(x)

9(课本习题12)

用solve和vpasolve求解:

(1) x 2 + x + 1 x^{2} + x + 1 x2+x+1;

(2) 3 x 5 − 4 x 3 + 2 x − 1 3x^{5} - 4x^{3} + 2x - 1 3x54x3+2x1;

(3) 5 x 23 − 6 x 7 + 8 x 6 − 5 x 2 5x^{23} - 6x^{7} + 8x^{6} - 5x^{2} 5x236x7+8x65x2;

(4) { a = 0.7 sin ⁡ a + 0.2 cos ⁡ b b = 0.7 cos ⁡ a − 0.2 sin ⁡ b \begin{cases}a=0.7\sin a+0.2\cos b\\b=0.7\cos a-0.2\sin b\end{cases} {a=0.7sina+0.2cosbb=0.7cosa0.2sinb

代码:

syms x;
f1 = x^2+x+1;
f2 = 3*x^5-4*x^3+2*x-1;
f3 = 5*x^23-6*x^7+8*x^6-5*x^2;
syms a b;
f4_1 = a-0.7*sin(a)-0.2*cos(b);
f4_2 = b-0.7*cos(a)+0.2*sin(b);

ans1 = solve(f1)
ans1_vpa = vpasolve(f1)
ans2 = solve(f2)
ans2_vpa = vpasolve(f2)
ans3 = solve(f3)
ans3_vpa = vpasolve(f3)
ans4=solve(f4_1,f4_2);
a = ans4.a, b = ans4.b
ans4_vpa = vpasolve([f4_1,f4_2],[a,b]);
a = ans4_vpa.a, b = ans4_vpa.b

输出:

ans1 =

- (3^(1/2)*1i)/2 - 1/2

(3^(1/2)*1i)/2 - 1/2

ans1_vpa =

- 0.5 - 0.86602540378443864676372317075294i

- 0.5 + 0.86602540378443864676372317075294i

ans2 =

1

root(z^4 + z^3 - z^2/3 - z/3 + 1/3, z, 1)

root(z^4 + z^3 - z^2/3 - z/3 + 1/3, z, 2)

root(z^4 + z^3 - z^2/3 - z/3 + 1/3, z, 3)

root(z^4 + z^3 - z^2/3 - z/3 + 1/3, z, 4)

ans2_vpa =

1.0

- 0.94789546187456058989982247394741 +
0.38447007122004299382156325898354i

b =

0.50791971903684924497183722688768

10(课本习题13)

用dsolve求解:

(1) y ′ = x + y ,   y ( 0 ) = 1 y^{'} = x + y,\ y(0) = 1 y=x+y, y(0)=1

(2) − x ′ = 2 x + 3 y ,   y ′ = 2 x + y ,   x ( 0 ) = − 2.7 ,   y ( 0 ) = 2.8 - x^{'} = 2x + 3y,\ y^{'} = 2x + y,\ x(0) = - 2.7,\ y(0) = 2.8 x=2x+3y, y=2x+y, x(0)=2.7, y(0)=2.8

(3) y ′ ′ − 0.01 y ′ 2 + 2 y = sin ⁡ t ,   y ( 0 ) = 1 ,   y ′ ( 0 ) = 0 y^{''} - 0.01y^{'2} + 2y = \sin t,\ y(0) = 1,\ y^{'}(0) = 0 y′′0.01y2+2y=sint, y(0)=1, y(0)=0

(4) 2 x ′ ′ ( t ) − 5 x ′ ( t ) − 3 x ( t ) = 90 e 2 t ,   x ( 0 ) = 2 ,   x ′ ( 0 ) = 1 2x^{''}(t) - 5x^{'}(t) - 3x(t) = 90e^{2t},\ x(0) = 2,\ x^{'}(0) = 1 2x′′(t)5x(t)3x(t)=90e2t, x(0)=2, x(0)=1

(5) x ′ ′ = − 2 x ′ t + 2 x t 2 + 10 cos ⁡ ln ⁡ t t 2 ,   x ( 1 ) = 1 ,   x ( 3 ) = 3. x^{''} = - \frac{2x^{'}}{t} + \frac{2x}{t^{2}} + \frac{10\cos{\ln t}}{t^{2}},\ x(1) = 1,\ x(3) = 3. x′′=t2x+t22x+t210coslnt, x(1)=1, x(3)=3.

代码:

% 10.1
syms y(x)
Dy = diff(y);
eqn = Dy == x + y;
cond = y(0) == 1;
S = dsolve(eqn, cond)

% 10.2
syms x(t) y(t)
eqn1 = diff(x, t) == -2*x - 3*y;
eqn2 = diff(y, t) == 2*x + y;
eqns = [eqn1, eqn2];
cond1 = x(0) == -2.7;
cond2 = y(0) == 2.8;
conds = [cond1, cond2];
S = dsolve(eqns, conds);
Sx = S.x, Sy = S.y

% 10.3 (解不出)
syms y(t)
eqn = diff(y, t, t) - 0.01*(diff(y, t))^2 + 2*y == sin(t);
cond1 = y(0) == 1;
Dy = diff(y);
cond2 = Dy(0) == 0;
conds = [cond1, cond2];
S = dsolve(eqn, conds)

% 10.4
syms x(t)
eqn = 2*diff(x, t, t) - 5*diff(x, t) - 3*x == 90*exp(2*t);
cond1 = x(0) == 2;
Dx = diff(x);
cond2 = Dx(0) == 1;
conds = [cond1, cond2];
S = dsolve(eqn, conds)

% 10.5
syms x(t)
eqn = diff(x, t, t) == -(2*diff(x, t))/t + 2*x/t^2 + (10*cos(log(t)))/t^2;
cond1 = x(1) == 1;
cond2 = x(3) == 3;
conds = [cond1, cond2];
S = dsolve(eqn, conds)

输出:

S = 2   e x − x − 1 2\, e^{x} - x - 1 2exx1

Sx =

4   15   ( 3   e − t 2   σ 1 4 − 15   e − t 2   σ 2 4 ) 25 − 21   e − t 2   σ 2 10 − 7   15   e − t 2   σ 1 10 w h e r e   σ 1 = sin ⁡ ( 15   t 2 )   σ 2 = cos ⁡ ( 15   t 2 ) \begin{array}{r} \frac{4\,\sqrt{15}\,\left( \frac{3\, e^{- \frac{t}{2}}\,\sigma_{1}}{4} - \frac{\sqrt{15}\, e^{- \frac{t}{2}}\,\sigma_{2}}{4} \right)}{25} - \frac{21\, e^{- \frac{t}{2}}\,\sigma_{2}}{10} - \frac{7\,\sqrt{15}\, e^{- \frac{t}{2}}\,\sigma_{1}}{10} \\ \\ where \\ \\ \ \sigma_{1} = \sin\left( \frac{\sqrt{15}\, t}{2} \right) \\ \\ \ \sigma_{2} = \cos\left( \frac{\sqrt{15}\, t}{2} \right) \end{array} 25415 (43e2tσ1415 e2tσ2)1021e2tσ210715 e2tσ1where σ1=sin(215 t) σ2=cos(215 t)

Sy =
14   e − t 2   cos ⁡ ( 15   t 2 ) 5 − 4   15   e − t 2   sin ⁡ ( 15   t 2 ) 25 \frac{14\, e^{- \frac{t}{2}}\,\cos(\frac{\sqrt{15}\, t}{2})}{5} - \frac{4\,\sqrt{15}\, e^{- \frac{t}{2}}\,\sin(\frac{\sqrt{15}\, t}{2})}{25} 514e2tcos(215 t)25415 e2tsin(215 t)

警告: Unable to find symbolic solution.

S = [ empty sym ]

S =
2   e − t 2   ( 47   e 7   t 2 − 63   e 5   t 2 + 23 ) 7 \frac{2\, e^{- \frac{t}{2}}\,\left( 47\, e^{\frac{7\, t}{2}} - 63\, e^{\frac{5\, t}{2}} + 23 \right)}{7} 72e2t(47e27t63e25t+23)

S = t 3   ( 27   10   σ 1 26 + 69 26 ) 3 − 10   t 2   cos ⁡ ( a t a n ( 1 3 ) + log ⁡ ( t ) ) t 2 − 9   10   σ 1 26 − 81 26 t 2 w h e r e   σ 1 = cos ⁡ ( a t a n ( 1 3 ) + log ⁡ ( 3 ) ) \begin{array}{r} \frac{\frac{t^{3}\,\left( \frac{27\,\sqrt{10}\,\sigma_{1}}{26} + \frac{69}{26} \right)}{3} - \sqrt{10}\, t^{2}\,\cos(atan(\frac{1}{3}) + \log(t))}{t^{2}} - \frac{\frac{9\,\sqrt{10}\,\sigma_{1}}{26} - \frac{81}{26}}{t^{2}} \\ \\ where \\ \\ \ \sigma_{1} = \cos(atan(\frac{1}{3}) + \log(3)) \end{array} t23t3(262710 σ1+2669)10 t2cos(atan(31)+log(t))t226910 σ12681where σ1=cos(atan(31)+log(3))

11

计算导数: y = 1 + sin ⁡ x 1 − cos ⁡ x y = \frac{1 + \sin x}{1 - \cos x} y=1cosx1+sinx, y = [ arcsin ⁡ x arccos ⁡ x arctan ⁡ x a r c c o t   x ] y = \begin{bmatrix} \arcsin x & \arccos x \\ \arctan x & arccot \, x \end{bmatrix} y=[arcsinxarctanxarccosxarccotx].

代码:

% 对于函数 y = (1 + sin(x))/(1 - cos(x))
syms x;
y1 = (1 + sin(x))/(1 - cos(x));
y_prime_1 = diff(y1, x)

% 对于向量函数 y = [arcsin(x), arccos(x), arctan(x), arccot(x)]
y2 = [asin(x), acos(x); atan(x), acot(x)];
y_prime_2 = diff(y2, x)

输出:

y_prime_1 = − cos ⁡ ( x ) cos ⁡ ( x ) − 1 − sin ⁡ ( x )   ( sin ⁡ ( x ) + 1 ) ( cos ⁡ ( x ) − 1 ) 2 - \frac{\cos(x)}{\cos(x) - 1} - \frac{\sin(x)\,\left( \sin(x) + 1 \right)}{\left( \cos(x) - 1 \right)^{2}} cos(x)1cos(x)(cos(x)1)2sin(x)(sin(x)+1)

y_prime_2 = ( 1 1 − x 2 − 1 1 − x 2 1 x 2 + 1 − 1 x 2 + 1 ) (\begin{matrix} \frac{1}{\sqrt{1 - x^{2}}} & - \frac{1}{\sqrt{1 - x^{2}}} \\ \frac{1}{x^{2} + 1} & - \frac{1}{x^{2} + 1}\end{matrix}) (1x2 1x2+111x2 1x2+11)

12

计算下列定积分:

∫ 0 π 4 x 1 + cos ⁡ 2 x d x ,   ∫ 0 1 x ( 1 − x 4 ) 3 2 d x \int_{0}^{\frac{\pi}{4}}\frac{x}{1 + \cos{2x}}dx,\ \int_{0}^{1}{x\left( 1 - x^{4} \right)^{\frac{3}{2}}}dx 04π1+cos2xxdx, 01x(1x4)23dx

代码:

syms x;
f1 = x / (1 + cos(2*x));
int(f1, 0, pi/4)

f2 = x * (1 - x^4)^(3/2);
int(f2, 0, 1)

输出:

ans = π 8 − log ⁡ ( 2 ) 4 \frac{\pi}{8} - \frac{\log(2)}{4} 8π4log(2)

ans = 3   π 32 \frac{3\,\pi}{32} 323π

求点赞。


网站公告

今日签到

点亮在社区的每一天
去签到