数学实验1.docx
《数学实验1.docx》由会员分享,可在线阅读,更多相关《数学实验1.docx(10页珍藏版)》请在冰豆网上搜索。
数学实验1
第一次练习题
1.求
的所有根。
(先画图后求解)
>>fplot('[exp(x)-3*x^2,0]',[-5,5]);
>>gridon
>>fsolve('exp(x)-3*x^2',-1)
Equationsolved.
fsolvecompletedbecausethevectoroffunctionvaluesisnearzero
asmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
-0.4590
Optimizationterminated:
first-orderoptimalityislessthanoptions.TolFun.
ans=
-0.4590
fsolve('exp(x)-3*x^2',1)
Equationsolved.
fsolvecompletedbecausethevectoroffunctionvaluesisnearzero
asmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
0.9100
>>fsolve('exp(x)-3*x^2',4)
Equationsolved.
fsolvecompletedbecausethevectoroffunctionvaluesisnearzero
asmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
3.7331
求得此方程的三个根
2.求下列方程的根。
1)
>>p=[1,0,0,0,5,1];r=roots(p)
r=
1.1045+1.0598i
1.1045-1.0598i
-1.0045+1.0609i
-1.0045-1.0609i
-0.1999
2)
>>fsolve('x*sin(x)-1/2',-3)
Equationsolved.
fsolvecompletedbecausethevectoroffunctionvaluesisnearzero
asmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
-2.9726
>>fsolve('x*sin(x)-1/2',-1)
Equationsolved.
fsolvecompletedbecausethevectoroffunctionvaluesisnearzero
asmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
-0.7408
>>fsolve('x*sin(x)-1/2',2)
Equationsolved.
fsolvecompletedbecausethevectoroffunctionvaluesisnearzero
asmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
0.7408
3)
>>fsolve('sin(x)*cos(x)-x^2',0)
Equationsolvedatinitialpoint.
fsolvecompletedbecausethevectoroffunctionvaluesattheinitialpoint
isnearzeroasmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
0
>>fsolve('sin(x)*cos(x)-x^2',1)
Equationsolved.
fsolvecompletedbecausethevectoroffunctionvaluesisnearzero
asmeasuredbythedefaultvalueofthefunctiontolerance,and
theproblemappearsregularasmeasuredbythegradient.
ans=
0.7022
3.求解下列各题:
1)
>>symsx
limit((x-sin(x))/x^3)
ans=
1/6
2)
>>symsx
y=exp(x)*cos(x);g=diff(y,4)
g=
-4*exp(x)*cos(x)
3)
>>vpa(int(exp(x^2),x,0,1/2),17)
ans=
0.54498710418362220
4)
>>int(x^4/(25+4*x^2),x)
ans=
(125*atan((2*x)/5))/32-(25*x)/16+x^3/12
5)
>>taylor(sqrt(1+x),9,x,0)
ans=
-(429*x^8)/32768+(33*x^7)/2048-(21*x^6)/1024+(7*x^5)/256-(5*x^4)/128+x^3/16-x^2/8+x/2+1
6)
>>diff(exp(sin(1/x)),x,3)
ans=
(cos(1/x)*exp(sin(1/x)))/x^6-(6*cos(1/x)*exp(sin(1/x)))/x^4+(6*sin(1/x)*exp(sin(1/x)))/x^5-(6*cos(1/x)^2*exp(sin(1/x)))/x^5-(cos(1/x)^3*exp(sin(1/x)))/x^6+(3*cos(1/x)*sin(1/x)*exp(sin(1/x)))/x^6
>>p=cos(1/x)/x^6*exp(sin(1/x))+6*sin(1/x)/x^5*exp(sin(1/x))+3*sin(1/x)/x^6*cos(1/x)*exp(sin(1/x))-6*cos(1/x)/x^4*exp(sin(1/x))-6*cos(1/x)^2/x^5*exp(sin(1/x))-cos(1/x)^3/x^6*exp(sin(1/x))
p=
(cos(1/x)*exp(sin(1/x)))/x^6-(6*cos(1/x)*exp(sin(1/x)))/x^4+(6*sin(1/x)*exp(sin(1/x)))/x^5-(6*cos(1/x)^2*exp(sin(1/x)))/x^5-(cos(1/x)^3*exp(sin(1/x)))/x^6+(3*cos(1/x)*sin(1/x)*exp(sin(1/x)))/x^6
>>subs(p,x,2)
ans=
-0.5826
4.求矩阵
的逆矩阵
及特征值和特征向量。
>>A=[-2,1,1;0,2,0;-4,1,3]
A=
-211
020
-413
>>inv(A)
ans=
-1.50000.50000.5000
00.50000
-2.00000.50001.0000
>>eig(A)
ans=
-1
2
2
>>[P,D]=eig(A)
P=
-0.7071-0.24250.3015
000.9045
-0.7071-0.97010.3015
D=
-100
020
002
5.已知
分别在下列条件下画出
的图形:
(1)>>fplot('[(1/sqrt(2*pi))*exp(-x^2/2),1/sqrt(2*pi)*exp(-(x+1)^2/2),1/sqrt(2*pi)*exp(-(x-1)^2/2)]',[-10,10])
(2)>>fplot('[(1/sqrt(2*pi))*exp(-x^2/2),1/(sqrt(2*pi)*2)*exp(-x^2/8),1/(sqrt(2*pi)*4)*exp(-x^2/32)]',[-10,10])
6.画下列函数的图形:
(1)
>>ezmesh('u*sin(t)','u*cos(t)','t/4',[0,20,0,2])
(2)
>>ezmesh('sin(x*y)',[0,3,0,3])
(3)
(第6题只要写出程序).
>>ezmesh('sin(t)*(3+cos(u))','cos(t)*(3+cos(u))','sin(u)',[0,2*pi,0,2*pi])