(1) 创建一个新笔记本，添加一个写着 "第一次作业" 的新标题单元.
(2) 突出选中单词 第一次 并将文本改成蓝色黑体.
(3) 将光标放在标题单元之下并使用单元插入助手来创建含有 "计算练习" 文本的新章节单元.
(4) 在笔记本底部添加一个写着 "解方程" 的节单元.
(5) 在节单元之下，创建一个自由格式输入单元来求解方程12x+24=0.
(6) 使用自由格式输入计算n 的和，其中n 从 1 到 10.
(7) 使用自由格式输入, 让 Mathematica 把第 100 个质数和第 108 个质数相乘.
(8) 判断 611 是否大于3^6.
(9) 使用自由格式输入绘制sin x+cosy的图形, 使用函数建议去除图像中的网格.

第一次作业

计算练习

解方程

Plot3D[Sin[x]+Cos[y],{x,-6.3`,6.3`},{y,-6.3`,6.3`},Mesh->None]

习题1

1. (4)

N[Log[1+E^(-2)],10]

1. (6)

N[Sqrt[Abs[Log[Sin[35Degree]]]],10]

1. (8)

N[Tan[ArcTan[Sqrt[2]/2]+I Sin[Sqrt[2]/3]],10]

2.

GCD[861,1638,2415]

3.

LCM[48,105,120]

4.

Binomial[10,3]

Binomial[12,5]

Binomial[15,7]

7.

T1 =Table[2i-1,{i,50}]

Apply[Plus,T1]

Apply[Times,T1]

T2=Table[i^2,{i,10}]

Apply[Plus, T2]

Apply[Times, T2]

T3=Table[1/(2i),{i,50}]

Apply[Plus, T3]

Apply[Times, T3]

Range[1,99]

T4=Select[%,PrimeQ]

Apply[Plus, T4]

Apply[Times, T4]

13.

T=RandomInteger[{100,200},60]

Sort[T]

Sort[T,Greater]

14.

(1) s<m<t

(2) x≤-10||x≥10

(3)-3<x≤6&& (y<-2||y≥7)

习题2

1. (3)

Expand[x(y-z)+y(z-x)+z(x-y)]

1. (4)

Expand[(2x^2-1)(x-4)-(x^2+3)(2x-5)]

2. (2)

A=Simplify[(y-2)(y^2-6y-9)-y(y^2-2y-15)]

A/.{y->1/2}

3. (4)

Factor[x^3-6x^2+11x-6]

3. (7)

Factor[3a*x+4b*y+4a*y+3b*x]

4. (1)

Cancel[(x^2+y^2-z^2+2x*y)/(x^2-y^2+z^2-2x*z)]

5. (2)

Simplify[1/(x+1)-(x+3)/(x^2-1)*(x^2-2x+1)/(x^2+4x+3)]

5. (4)

RootReduce[(2Sqrt[2]+3Sqrt[3])/(3Sqrt[2]-2Sqrt[3])]

6. (3)

Solve[a*b*x^2+(a^4+b^4)x+a^3b^3==0,x]

6. (6)

Solve[x^2+2x*y+y^2==9&&(x-y)^2-3(x-y)-10==0,{x,y}]

6. (7)

Solve[Sqrt[3]x+Sqrt[3]y==Sqrt[7]&&Sqrt[6]x-Sqrt[7]y==Sqrt[5],{x,y}]

7. (1)

Sum[k^3,{k,1,n}]

8. (2)

RSolve[a[n+1]==a[n]/x+y,a[n],n]

8. (4)

RSolve[{a[n+1]-a[n]==n^2,a[0]==1},a[n],n]

习题3

1. (2)

Limit[x/(x-1)-1/Log[x],x->1]

1. (4)

Limit[(1+1/x^2)^x,x->Infinity]

1. (5)

Limit[Sqrt[n-Sqrt[n]]-Sqrt[n],n->Infinity]

2. (3)

D[CubeRoot[1+CubeRoot[1+CubeRoot[x]]],x]

2. (5)

D[E^x+E^(E^x),x]

2. (8)

D[Log[Cos[ArcTan[(E^x-E^(-x))/2]]],x]

3. (3)

FullSimplify[D[1/(1-x^2),{x,60}]]

3. (4)

D[(1+x)/Sqrt[1-x],{x,60}]

4. (2)

Integrate[(x+1)/Sqrt[x],x]

4. (4)

Integrate[(2x^2-5)/(x^4-5x^2+6),x]

4. (6)

Integrate[(E^(2x)+1)/(E^x+1),x]

4. (8)

Integrate[x*y*z(1-x-y),x,y,z]

5. (2)

Integrate[Sqrt[E^x-1],{x,0,Log[2]}]

5. (4)

Integrate[x^2/Sqrt[x^2+a^2],{x,0,a}]

5. (6)

Integrate[(Sqrt[4x+1]/2+1)/x,{x,0,1}]

5. (8)

Integrate[x*y^2,{x,0,1},{y,x^2,x}]

5. (10)

Integrate[x*y*z,{x,0,1},{y,0,x},{z,0,x+y}]

5. (12)

Integrate[x*Sqrt[y]Boole[x^2≤y&&y≤Sqrt[x]],{x,0,1},{y,0,1}]

6.

y[x_]:=a*Cosh[x/a]
Integrate[Sqrt[1+D[y[x],x]^2],{x,-a,a}]

7. (1)

Series[E^(x^2),{x,0,5}]

7. (3)

Series[Log[Sqrt[(1+x)/(1-x)]],{x,0,5}]

7. (5)

Series[Cos[x]Cos[y],{x,0,5},{y,0,5}]

8. (2)

Clear["Global`*"]

DSolve[y'[x]==y[x]^2-2/x^2,y[x],x]

8. (4)

DSolve[y''''[x]==y[x],y[x],x]

8.  (6)

DSolve[{y'[x]==y[x]+x,y[0]==1},y[x],x]

8. (8)

DSolve[{x'[t]==2x[t]-y[t]+z[t],y'[t]==2x[t]+2y[t]-z[t],z'[t]==x[t]+2y[t]-z[t]},{x[t],y[t],z[t]},t]

9. (2)

DSolve[(x^2+y^2)D[u[x,y],x]+6x*y*D[u[x,y],y]==0,u[x,y],{x,y}]

9. (4)

DSolve[x^2D[u[x,y],x]-y^2D[u[x,y],y]==u[x,y],u[x,y],{x,y}]

习题4

1. (2)

Det[{{1+a,1,1,1},{1,1-a,1,1},{1,1,1+b,1},{1,1,1,1-b}}]

1 (4)

Det[Table[(i+j-1)^98,{i,100},{j,100}]]

3

a={{1,0,-1},{0,2,3}};
b={{2,-1,4},{1,0,-2},{0,3,1}};
c={{0,2},{-1,0},{3,1}};

MatrixForm[a.b]
MatrixForm[a.c]
MatrixForm[c.a]
MatrixForm[b.b]

4 (1)

a1={1,-2,1};
a2={0,3,-1};
a3={2,-1,3};

Det[{a1,a2,a3}]==0

4 (2)

a1={-2,1,1};
a2={1,-1,1};
a3={-5,3,1};

Det[{a1,a2,a3}]==0

5

a1={1,-1,1,-1};
a2={0,1,-1,1};
a3={0,0,1,-1};
a4={0,0,0,1};
b={1,1,1,1};

LinearSolve[Transpose[{a1,a2,a3,a4}],b]

7

a1={1,0,0,0};
a2={0,1,0,0};
a3={0,0,1,0};
a4={0,0,0,1};
b1={1,1,1,1};
b2={1,1,-1,-1};
b3={1,-1,1,-1};
b4={1,-1,-1,1};

MatrixForm[LinearSolve[Transpose[{b1,b2,b3,b4}],Transpose[{a1,a2,a3,a4}]]]

8 (2)

MatrixRank[{{1,1,-3,-4,1},{3,-1,1,4,3},{1,5,-9,-8,1}}]

9 (3)

Inverse[Table[If[i==j,x,If[Abs[i-j]==1,1,0]],{i,10},{j,10}]]

9 (4)

MatrixForm[Inverse[Table[If[i≤j,j-i+1,0],{i,10},{j,10}]]]

10 (1)

A={{1,-2,1,1},{1,-2,1,-1},{1,-2,1,5}};

LinearSolve[A,{1,-1,5}]

NullSpace[A]

{0,0,0,1}+x{-1,0,1,0}+y{2,1,0,0}

11

a1={1,-1};
a2={1,1};
b1={2,0};
b2={-1,1};

A=LinearSolve[Transpose[{a1,a2}],Transpose[{b1,b2}]]

MatrixForm[Inverse[A].{{2,3},{0,1}}.A]

12 (3)

Eigensystem[{{1,1,1,1},{1,1,-1,-1},{1,-1,1,-1},{1,1,-1,1}}]

13 (2)

Q={{1,1,1},{1,2,3},{1,3,6}};

f[x_]:=x<=0
Select[Eigenvalues[Q],f]

14 (1)

JordanDecomposition[{{2,-1,1},{2,2,-1},{1,2,-1}}]

习题5

1. (1)

p[x_]=InterpolatingPolynomial[{{-1,3},{0,0.5},{0.5,0},{1,1}},x]

p[0.25]

p[0.75]

1. (2)

p[x_]=InterpolatingPolynomial[{{-1,1.5},{0,0},{0.5,0},{1,0.5}},x]

p[-0.25]

p[0.25]

2.

data={{-1,0.22},{-0.5,0.8},{0,2},{0.25,2.5},{0.75,3.8},{1,4.2}};

Fit[data,{1,x},x]

Fit[data,{1,x,x^2},x]

3.

data={{19,19},{23,28.5},{30,47},{35,68.2},{40,90}};

Fit[data,{1,x^2},x]

6. (1)

FindMinimum[Sin[x]Cos[x],{x,0.5}]

6. (2)

FindMinimum[Sin[x*y]Exp[x^2],{{x,0.2},{y,0.3}}]

7.(1)

Rasterize[Plot[Cos[3x]+2Cos[x],{x,0,2Pi}]]

FindRoot[Cos[3x]+2Cos[x],{x,1}]

FindRoot[Cos[3x]+2Cos[x],{x,1.5}]

FindRoot[Cos[3x]+2Cos[x],{x,2}]

故解为以上三个数及其相反数加2k π，k为整数。

7. (2)

Rasterize[Plot[Sin[x]^4-Cos[x]^4-Cos[x]-Sin[x],{x,0,2Pi}]]

FindRoot[Sin[x]^4-Cos[x]^4-Cos[x]-Sin[x],{x,1.6}]

FindRoot[Sin[x]^4-Cos[x]^4-Cos[x]-Sin[x],{x,2.2}]

FindRoot[Sin[x]^4-Cos[x]^4-Cos[x]-Sin[x],{x,3.2}]

FindRoot[Sin[x]^4-Cos[x]^4-Cos[x]-Sin[x],{x,5.4}]

故解为以上四个数加2k π，k为整数。

7. (3)

Rasterize[[Plot[Sin[x+Pi/4]Sin[x-Pi/12]-1/2,{x,0,Pi}]]]

FindRoot[Sin[x+Pi/4]Sin[x-Pi/12]-1/2,{x,0.8}]

FindRoot[Sin[x+Pi/4]Sin[x-Pi/12]-1/2,{x,1.8}]

故解为以上两个数加k π，k为整数。

7. (4)

Rasterize[Plot[6Sin[x]^2+3Sin[x]Cos[x]-5Cos[x]^2-2,{x,0,Pi}]]

FindRoot[6Sin[x]^2+3Sin[x]Cos[x]-5Cos[x]^2-2,{x,0.5}]

FindRoot[6Sin[x]^2+3Sin[x]Cos[x]-5Cos[x]^2-2,{x,2}]

故解为以上两个数加k π，k为整数。

11. (1)

LinearProgramming[{-3,-2},{{-1,2},{3,2},{1,-1}},{{4,-1},{14,-1},{3,-1}}]

{4,1}.{3,2}

11. (2)

LinearProgramming[{2,3,4},{{1,2,-1},{1,1,-1},{0,1,2}},{10,60,12},{0,0,1}]

{{1,2,-1},{1,1,-1},{0,1,2}}.{51,10,1}

故取不到最小值。

12. (1)

sol=NDSolve[{y''[x]+y[x]==Cos[x],y[0]==0,y'[0]==0},y,{x,0,20}]

Rasterize[Plot[Evaluate[y[x]/.sol],{x,0,20}]]

12. (2)

sol=NDSolve[{D[u[t,x],t]==D[u[t,x],{x,2}],u[0,x]==0,u[t,0]==Sin[t],u[t,5]==0},u,{t,0,10},{x,0,5}]

Rasterize[Plot3D[Evaluate[u[t,x]/.sol],{t,0,10},{x,0,5}]]

习题6

1. (1)

Rasterize[Plot[1+x+x^3,{x,-100,100},AxesLabel->{"x","y"},Axes->{False,True}]]

1. (2)

Rasterize[Plot[(x-1)(x-2)^2,{x,-70,70},Mesh->Full,MeshStyle->{Red, Blue},MeshShading->{Black}]]

1. (3)

Rasterize[Plot[x+Sin[x],{x,-10,10},Method->{"AxesInFront" -> True},AspectRatio->1/2]]

1. (4)

Rasterize[Plot[x^2Sin[x^2],{x,-60,60},Filling->Bottom,PlotStyle->Gray]]

2. (1)

y[x_]:=x^2(x-1)/(x+1)^2;
Rasterize[Plot[{y[x],y'[x]},{x,-100,100}]]

2. (2)

y[x_]:=Sin[x]/(1+x^2);
Rasterize[Plot[{y[x],y'[x]},{x,-90,90}]]

3. (1)

Rasterize[ParametricPlot[{(t+1)^2/4,(t-1)^2/4},{t,-6,6}]]

3. (2)

Rasterize[ParametricPlot[{Cos[2t],Cos[3t]},{t,-Pi,Pi}]]

3. (3)

Rasterize[ParametricPlot[{t*Log[t],Log[t]/t},{t,0,6Pi}]]

4. (1)

Rasterize[Plot3D[E^(-x^2-y^2),{x,-3,3},{y,-3,3}]]

4. (2)

Rasterize[Plot3D[Sin[x+Cos[y]],{x,-6,6},{y,-6,6}]]

4. (3)

Rasterize[Plot3D[(x^2-y^2)/(x^3+y^3),{x,-10,10},{y,-10,10}]]

5. (1)

Rasterize[Plot3D[x/(E^(x^2+y^2)),{x,-2,2},{y,-2,2},RegionFunction->Function[{x,y,z},2<x^2+y^2<3]]]

5. (2)

Rasterize[Plot3D[1/(y^2-x^3+3x-3),{x,-3,3},{y,-3,3},RegionFunction->Function[{x,y,z},0<Mod[x^2+y^2,2]<1]]]

6. (1)

Rasterize[ParametricPlot3D[{Sin[t],Cos[t],t/3},{t,0,15}]]

6. (2)

Rasterize[ParametricPlot3D[{u*Sin[t],u*Cos[t],t/3},{t,0,15},{u,-1,1}]]

6. (3)

Rasterize[ParametricPlot3D[{Sin[a]Cos[b],Sin[a]Sin[b],Cos[a]},{a,0,Pi/2},{b,0,2Pi}]]

6. (4)

Rasterize[ParametricPlot3D[{Sin[a]Cos[b],Sin[a]Sin[b],Cos[a]},{a,0,Pi},{b,Pi/2,3Pi/2}]]

7.

ContourPlot[Sin[x*Cos[y]],{x,-10,10},{y,-5,5}]

Rasterize[DensityPlot[Sin[x*Cos[y]],{x,-10,10},{y,-5,5}]]

8.

list = {1.2,3.3,2.2,5.5,7.7,9.9};
Rasterize[BarChart[list]]

PieChart[list]

9.

Rasterize[Graphics[RegularPolygon[5]]]
Rasterize[Graphics[RegularPolygon[8]]]

10. (1)

Rasterize[PolarPlot[{Sqrt[Cos[2θ]],-Sqrt[Cos[2θ]]},{θ,-Pi/2,Pi/2}]]

10. (2)

Rasterize[PolarPlot[1-Cos[θ],{θ,0,2Pi}]]

第6章-图表、图与动画

Rasterize[RectangleChart[{{1,1},{2,1},{3,2},{2,2},{5,1}},ChartStyle->Thickness[.5],ChartElementFunction->"FadingRectangle"]]

Rasterize[RectangleChart3D[{{{2,3,3},{1,2,2},{1,1,1}},{{1,3,2},{2,1,1}}},ChartLabels->Placed[{"X1","X2","X3"},Center]]]

Rasterize[SectorChart[{{1,2},{2,1},{3,1}},SectorOrigin->{Automatic,1},ChartStyle->"Pastel"]]

Rasterize[SectorChart3D[{{2,2,3},{2,1,2},{1,2,1}},ChartStyle->"DarkRainbow",ChartLegends->{"a","b","c"}]]

Rasterize[Histogram[RandomVariate[NormalDistribution[0,1],200],Automatic,"Probability"]]

Rasterize[Histogram3D[RandomVariate[NormalDistribution[0,1],{100,2}],10,ChartElements->Graphics3D[Cylinder[]]]]

Rasterize[RegionPlot[x^2+y^3<2,{x,-2,2},{y,-2,2},ColorFunction->"SunsetColors",BoundaryStyle->None]]

Rasterize[RegionPlot3D[x^2+y^3-z^2>0,{x,-2,2},{y,-2,2},{z,-2,2},PlotPoints->35,PlotRange->All]]

Rasterize[VectorPlot[{y,-x^2},{x,-3,3},{y,-3,3},StreamPoints->10,StreamScale->Full]]

Rasterize[VectorPlot3D[{x,-y,z},{x,0,1},{y,0,1},{z,0,1},VectorColorFunction->Hue,VectorScale->{Automatic,Scaled[0.3]}]]

Rasterize[StreamPlot[{-x^2+y,y^3},{x,0,1},{y,0,2},StreamStyle->Yellow,FrameStyle->LightGray,Background->Black]]

Rasterize[StreamPlot[{-y^3-x^2,x+y},{x,0,1},{y,-1,1},BoundaryStyle->None,FrameLabel->{x,y}]]

Rasterize[MatrixPlot[{{1,0,2},{3,0,2},{4,6,0}},ColorFunction->"Monochrome",Background->LightBlue]]

Rasterize[MatrixPlot[{{1,10,1},{100,0,1},{-10,0,-1}},PlotRange->{-1,1},ClippingStyle->{Green,Yellow}]]

Rasterize[TreePlot[KaryTree[9,2],PlotStyle->Directive[PointSize[Large],Red]]]

Rasterize[TreePlot[Flatten[Table[{i-> 2i+j-1},{j,2},{i,2^7-1}]],Center,LayerSizeFunction->(#1 &)]]

Rasterize[GraphPlot[{{0,1,1,1,0},{1,0,1,0,1},{1,1,0,0,1},{1,0,0,1,1},{0,1,1,1,0}},GraphLayout->{"CircularMultipartiteEmbedding", "VertexPartition"->{2,1,2}}]]

Rasterize[GraphPlot[{1->2,2->3,3->4,4->1,2->4},DirectedEdges-> True,PlotStyle->Directive[PointSize[Large],Gray]]]

Animate[Plot[t*x^3-t*x+1,{x,-3,3}],{t,-1,1,0.1}]

Animate[Expand[(x+1)^t],{t,1,10,1}]

ListAnimate[Table[Plot[Sin[n x],{x,0,10}],{n,5}]]

ListAnimate[Range[10],AnimationRate->{0.5,1},AnimationRunning->False]

习题7

1.

DeriOut[f_]:={f[x],D[f[x],x],D[f[x],{x,2}]}

(#1^2)&//DeriOut

3.

DiagUp[n_]:=Table[(i==j)*i,{i,n},{j,n}]/.{True->1,False->0}

MatrixForm[DiagUp[4]]

5.

MatrixA[n_]:=Table[If[j≥i,j-i,j],{i,n},{j,n}]

MatrixForm[MatrixA[4]]

6.

SeqCount[A_]:=If[Length[A]==1,0,Count[Sign[A-A[[1]]],1]+SeqCount[Rest[A]]]

SeqCount[{1,2,4,5,3}]

InvCount[A_]:=If[Length[A]==1,0,Count[Sign[A-A[[1]]],-1]+InvCount[Rest[A]]]

InvCount[{1,2,4,5,3}]

7.

DrawPolygon[n_]:=Graphics[RegularPolygon[n]]

Rasterize[DrawPolygon[4]]

10.

BasicOperate[A_,row_,type_,param_]:=
If[row,
If[type==1,Table[If[i==param[[1]],A[[i]]*param[[2]],A[[i]]],{i,Length[A]}],
If[type==2,Table[If[i==param[[1]],A[[param[[2]]]],If[i==param[[2]],A[[param[[1]]]],A[[i]]]],{i,Length[A]}],
Table[If[i==param[[1]],A[[i]]+param[[3]]*A[[param[[2]]]],A[[i]]],{i,Length[A]}]]],Transpose[BasicOperate[Transpose[A],True,type,param]]];

A={{1,2,3},{4,5,6},{7,8,9}}

MatrixForm[BasicOperate[A,True,3,{3,1,-2}]]

MatrixForm[BasicOperate[A,False,2,{1,2}]]

MatrixForm[BasicOperate[A,False,1,{3,0.5}]]

习题8

1.

Map[Print,Partition[Flatten[{Select[Table[i,{i,100,1000}],Mod[#,3]==0||Mod[#,11]==0&],Table[Null,4]}],5]];

2.

f[A_]:=A//.{a___,x_,b___,x_,c___}:>{a,x,b,c}

f[{1,2,3,41,2,34,123,21,21,2,12,2,2,2,3,3,4,4,4,2,1,1,1}]

4.

pol[x_]:=x^3-2x^2+7x+4;res[0]=-1;res[1]=1;
res[n_]:=(res[n]=(res[n-2]*pol[res[n-1]]-res[n-1]*pol[res[n-2]])/(pol[res[n-1]]-pol[res[n-2]]));
(*用res[n]=进行记忆，避免重复计算*)
Module[{n},n=2;While[Abs[res[n]-res[n-1]]>10^(-16),n++];N[res[n]]]

6.

f[x_]:=Switch[True,x≤-20,Sin[x],20≤x,Cos[x],True,x^2];
A=RandomReal[{-100,100},30];
Rasterize[ListPlot[Map[{#,f[#]}&,A]]]

9.

Eigensystem[RandomReal[{-10,10},{4,4}]]

12.

L2[A_]:=Sqrt[Max[Eigenvalues[Transpose[A].A]]];
L2[{{1,2,3},{4,5,6}}]

16.

Newton[f_,x0_,n_]:=If[n==0,x0,N[(x-f[x]/D[f[x],x])/.x->Newton[f,x0,n-1]]];
Newton[#^2-2&,1,100]

18.

StarZero[n_]:=MatrixForm[Table[If[OddQ[Min[{i,j,n-i+1,n-j+1}]],"*",0],{i,n},{j,n}]]

StarZero[7]