Mathematica100例题共14页文档.docx
- 文档编号:23537143
- 上传时间:2023-05-18
- 格式:DOCX
- 页数:18
- 大小:20.41KB
Mathematica100例题共14页文档.docx
《Mathematica100例题共14页文档.docx》由会员分享,可在线阅读,更多相关《Mathematica100例题共14页文档.docx(18页珍藏版)》请在冰豆网上搜索。
Mathematica100例题共14页文档
利用mathematica计算二重积分
问题:
曲面z=12-2x^2-2y^2,z=x^2+y^2+3所围成的几何体的体积
先作图:
< debll=InequalityPlot3D[12-2x^2-2y^2-z>=0x^2+y^2+3-z<=0,{x},{y},{z},Axes->True]; < Shadow[debll,XShadowFalse,YShadowFalse] 得到 得到 .0992******** 幂函数作图 1. f[x_,n_]: =x^n; a[n_]: =Plot[x^n,{x,0,2},PlotStyleRGBColor[0.2n,0.8,1-0.1n]]; A=Array[a,5]; Show[A,AxesTrue,AxesLabel{"x","y"},AspectRatioAutomatica] 2 f[n_]: =x^n;f/@{1,2,3,4}; Plot[Evaluate[f/@{1,2,3,4}],{x,0,1}] 3. f[n_]: =x^n;f[{1,2,3,4}]; Plot[Evaluate[f[{1,2,3,4}]],{x,0,1}] 4. Plot[Evaluate[Table[x^i,{i,6}]],{x,0,2}] 5. Clear[f]; f[n_]: =x^n; Plot[Evaluate[Map[f,{1,2,3,4,5,6}]],{x,0,2}] 6. Plot[Evaluate[x^Range[6]],{x,0,2}] Sin函数多次迭代 1. Plot[{Nest[Sin,x,10],Nest[Sin,x,50],Nest[Sin,x,100]},{x,0,4Pi},PlotStyle{RGBColor[1,0,0],RGBColor[0,1,0],RGBColor[0,0,1]}] 2. Plot[{Nest[Sin,x,100],Nest[Sin,x,500],Nest[Sin,x,1000]},{x,0,4Pi},PlotStyle{RGBColor[1,0,0],RGBColor[0,1,0],RGBColor[0,0,1]}] 冒泡排序 bubble[x_List]: =x//.{p___,a_,b_,q___}/;b>a->{p,b,a,q} bubble[{9,7,1,6,11,21}] 钢管切割 For[i=0,i<3,i++, For[j=0,j<4,j++, For[k=0,k<=4,k++, If[7.4-2.9i-2.1j-1.5k<1.5&&7.4-2.9i-2.1j-1.5k0,Print[{i,"",j,"",k,"",7.4-2.9i-2.1j-1.5k}] 工资序列 1. Clear[x,b,c] c={10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01}; (*Input[x];*) Print["工资序列"] x={58.58,47.35,95.62,88.88} b=Table[0,{i,1,Length[x]},{j,1,10}]; For[k=1,kLength[x],k++, b[[k,1]]=Floor[x[[k]]/10]; For[i=2,i<10,i++, b[[k,i]]=Floor[(x[[k]]-Take[b[[k]],i-1].Take[c,i-1])/c[[i]]] b[[k,10]]=(x[[k]]-Take[b[[k]],9].Take[c,9])/c[[10]] Print["结果"] Print["10元","5元","2元","1元","5角","2角""1角","5分","2分","1分"] b//MatrixForm Print["合计: "] Print["10元","5元","2元","1元","5角","2角""1角","5分","2分","1分"] Plus@@b 2.提示输入 Clear[x,b,c] c={10,5,2,1,0.5,0.2,0.1,0.05,0.02,0.01}; Print["工资序列"] Input[x] m=Length[x]; b=Table[0,{i,1,m},{j,1,10}]; For[k=1,km,k++, b[[k,1]]=Floor@(x[[k]]/10); For[i=2,i<10,i++, b[[k,i]]=Floor[(x[[k]]-Take[b[[k]],i-1].Take[c,i-1])/c[[i]]] b[[k,10]]=(x[[k]]-Take[b[[k]],9].Take[c,9])/c[[10]] Print["结果"] Print["10元","5元","2元","1元","5角","2角""1角","5分","2分","1分"] b//MatrixForm Print["合计: "] Print["10元","5元","2元","1元","5角","2角""1角","5分","2分","1分"] Plus@@b 3.输入输出 表格输出 templist1={1,2,3}; templist2={4,5,6}; templist3={7,8,9}; FrameBox[ TableForm[{templist1,templist2,templist3},TableDirections{Row,Column},TableAlignmentsCenter,TableHeadings{{"a","b","c"},None}] ]//DisplayForm 读入数据、站点实测数据 ReadList["M: \\cumcmall\\C2019Data\\FORECAST\\f7292_dis2.txt",Number] data1=ReadList["M: \\cumcmall\\C2019Data\\MEASURING\\020618.SIX",{Number,Number,Number,Number,Number,Number,Number}]; a=Table[0,{i,91},{j,3}]; For[i=0,i<91,i++;a[[i,1]]=data1[[i,2]];a[[i,2]]=data1[[i,3]]; If[data1[[i,4]]<0.1,0; a[[i,3]]=data1[[i,4]]] a; ListPlot3D[a] ListContourPlot[a] 追踪 < y[t_]: =0.5*t; x[t_]: =100-02*t; For[i=1,i<50,i++, Show[ Graphics[Line[{{0,0},{0,100},{100,100},{100,0},{0,0}}]], Graphics[{Arrow[{x[i],0},{0,y[i]}]}],Graphics[ Text["敌",{0,y[i+1]}], Text["変",{x[i+3],0}], {PointSize[.025],RGBColor[1,0,0],Point[{x[i],0}]}, {PointSize[.025],RGBColor[0,1,0],Point[{0,y[i]}]} PlotRangeAll AxesTrue 截断切割(数组应用) 1. F[L_]: =Which[Max[L[[4]],L[[5]],L[[6]],L[[7]],L[[8]]/r,L[[9]]/r]L[[8]]/r, L+{0,0,-L[[8]],0,0,0,0,-L[[8]],0,r*L[[1]]*L[[2]]}, Max[L[[4]],L[[5]],L[[6]],L[[7]],L[[8]]/r,L[[9]]/r]L[[9]]/r, L+{0,0,-L[[9]],0,0,0,0,0,-L[[9]],r*L[[1]]*L[[2]]}, Max[L[[4]],L[[5]],L[[6]],L[[7]],L[[8]]/r,L[[9]]/r]L[[6]], L+{0,-L[[6]],0,0,0,-L[[6]],0,0,0,L[[1]]*L[[3]]}, Max[L[[4]],L[[5]],L[[6]],L[[7]],L[[8]]/r,L[[9]]/r]L[[7]], L+{0,-L[[7]],0,0,0,0,-L[[7]],0,0,L[[1]]*L[[3]]}, Max[L[[4]],L[[5]],L[[6]],L[[7]],L[[8]]/r,L[[9]]/r]L[[4]], L+{-L[[4]],0,0,-L[[4]],0,0,0,0,0,L[[2]]*L[[3]]}, Max[L[[4]],L[[5]],L[[6]],L[[7]],L[[8]]/r,L[[9]]/r]L[[5]], L+{-L[[5]],0,0,0,-L[[5]],0,0,0,0,L[[2]]*L[[3]]}, True,0]; L={10,14.5,10,6,1,7,5.5,0,6,145.};r=1; F[L] 2. NestList[F,L,6] 煤矸石 旋转体 1. Clear[f,x,t,y,z,i,s]; f[x_]=Sin[t]+1.5; For[i=1,i<=20,i++, ParametricPlot3D[{f[t]Cos[s],f[t]Sin[s],t},{t,0,2Pi}, {s,0,2Pii/20}, PlotRange->{{-2.5,2.5},{-2.5,2.5},{0,6}}, AxesLabel->{x,y,z}]] 2. 柱面 Clear[x,y,i,z,t1,t2]; y=Sin[x]; Do[t1=ParametricPlot3D[{x,y,z},{z,-0.01,0}, {x,-Pi,Pi},DisplayFunction->Identity]; t2=ParametricPlot3D[{x,y,z},{z,0,5}, {x,-Pi,-Pi+2Pi*i/20},PlotRange->{{-Pi,Pi},{-1,1},{0,5}}, DisplayFunction->Identity]; Show[t1,t2,DisplayFunction->$DisplayFunction, Boxed->False,AxesLabel->{x,y,z}, LightSources->{{{-Pi,0,23},RGBColor[0,1,0]}}], {i,1,21,2}] 定积分动画 Clear[f,x,y,a,b,m,tt1,g1,g2,g3,i,x1,x2]; f[x_]=1/x^2;a=1.;b=15.;m=100;tt1={}; g1=Plot[f[x],{x,a,b},PlotStyle->{RGBColor[1,0,0]}, DisplayFunction->Identity]; g2=ParametricPlot[{a,t},{t,0,f[a]}, PlotStyle->{RGBColor[1,0,0]},DisplayFunction->Identity]; g3=ParametricPlot[{b,t},{t,0,f[b]}, PlotStyle->{RGBColor[1,0,0]},DisplayFunction->Identity]; For[i=0,i tt1=Append[tt1,Graphics[{RGBColor[0,1,0], Rectangle[{x1,0},{x2,f[x2]}]}]]; Show[tt1,g1,g2,g3,DisplayFunction->$DisplayFunction, PlotLabel->{____: "[1",x2"]",____: 1-1/x1}, PlotRange->{{0,15},{0,1}}, AxesLabel->{x,y},Axes->True]] 幂级数 Clear[f,g,x,y,k,n]; f[x_]=Sin[x]; g[x_]=Sum[((-1)^(k-1))x^(2k-1)/(2k-1)! {k,1,n}]; Do[Plot[{f[x],g[x]},{x,-4Pi,4Pi}, PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,0]}, PlotRange->{{-4Pi,4Pi},{-2,2}}, AxesLabel->{x,y},PlotLabel->{n"____________"}], {n,1,10}] 牛顿 Clear[a,b,f,x,i,j,n,m,t1,t2]; a=0;b=1.;f[x_]=3x^2; < t1=Table[Sum[f[a+(b-a)i/j]/j,{i,1,j}],{j,1,61}]; t2=Table[Sum[f[a+(b-a)i/j]/j,{i,0,j-1}],{j,2,62}]; Do[Show[ListPlot[Take[t1,n], Prolog->AbsolutePointSize[2], DisplayFunction->Identity], ListPlot[Take[t2,n], Prolog->AbsolutePointSize[2], PlotStyle->RGBColor[0,0,1], DisplayFunction->Identity], Plot[1,{m,0,60},PlotStyle->RGBColor[0,1,0], DisplayFunction->Identity], DisplayFunction->$DisplayFunction, PlotRange->{{0,60},{0,2}}, AxesLabel->{_____,______}], {n,1,60,2}] 切线 Clear[f,j,x,h,y,a]; f[x_]=x^4+x^2;a=1.6 For[j=1,j<=20,j*=1.1;h=1/j; Plot[{f[x],f[a]+f'[a](x-a), f[a]+(f[a+h]-f[a])/h(x-a)},{x,1,3}, AspectRatio->1,PlotRange->{{1,3},{0,40}}, PlotStyle->{RGBColor[0,0,1],RGBColor[0,1,0], RGBColor[1,0,0]},AxesLabel->{x,y}]] fourer级数 Clear[f,x,y,n,b,k]; f[x_]=Which[-2Pi<=x<-Pi,1,-Pi<=x<0,-1,0<=x Pi<=x<=2Pi,-1]; b[n_]=(1-(-1)^n)2/n/Pi; Do[Plot[{f[x],Sum[b[n]Sin[nx],{n,1,k}]},{x,-2Pi,2Pi}, PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,0]}, PlotRange->{{-2Pi,2Pi},{-1.5,1.5}}, AxesLabel->{x,y},PlotLabel->{k"____________"}], {k,1,61,10}] 级数和 Clear[m,j,i,t1,t2,t3,n] m=100; t1=Table[Sum[1/j^(1/2),{j,1,i}]//N,{i,1,m}]; t2=Table[Sum[1/j,{j,1,i}]//N,{i,1,m}]; t3=Table[Sum[1/j^2,{j,1,i}]//N,{i,1,m}]; Do[Show[ListPlot[Take[t1,n], DisplayFunction->Identity, PlotStyle->RGBColor[1,0,0]], ListPlot[Take[t2,n], PlotStyle->RGBColor[0,1,0], DisplayFunction->Identity], ListPlot[Take[t3,n], PlotStyle->RGBColor[0,0,1], DisplayFunction->Identity], DisplayFunction->$DisplayFunction, PlotRange->{{0,m},{0,20}}, Prolog->PointSize[.014], AxesLabel->{__________,__________}], {n,1,m,5}] 二重积分的实验 Clear[f,x,y,a,b,c,d,s,fz,xyz,gg,i,m,n,j,k,h, pp1,pp2,step,fg,bc]; fg=16;bc=2;t=Table[p[i],{i,1,fg}]; Do[p[i]=0,{i,1,fg}]; f[x_,y_]=1-(x^2+y^2)/4;a=-1;b=1;c=-1;d=1;s=0; Do[step=2/h; m=(b-a)/step;n=(d-c)/step;gg={}; xyz=Flatten[Table[{x,y,f[x,y]}//N,{x,a,b,step}, {y,c,d,step}],1]; Do[k=(j-1)m; Do[fz=(xyz[[i+j-1+k,3]]+xyz[[i+j+k,3]] +xyz[[i+j+m+k,3]]+xyz[[i+j+m+k+1,3]])/4; pp1={xyz[[i+j-1+k,1]],xyz[[i+j-1+k,2]],0}; pp2={xyz[[i+j+m+k+1,1]],xyz[[i+j+m+k+1,2]],fz}; p[h]+=step^2fz; gg=Append[gg,Graphics3D[Cuboid[pp1,pp2]]],{i,1,m} ],{j,1,n}]; Show[gg,PlotRange->{{a,b},{c,d},{0,1}}, PlotLabel->{______: p[h]}],{h,1,fg,bc}] 导数 Clear[f,x,g,n,y,i]; f[x_]=x^2;g[x_]=x^5+x;n=30; Do[Show[Plot[{f[x],f[0]-(f[0-(1-i/n)]-f[0])/(1-i/n)(x-0)}, {x,-1,0},DisplayFunction->Identity, PlotStyle->{RGBColor[0,0,1],RGBColor[0,1,0]}], Plot[{g[x],g[0]+(g[0+(1-i/n)]-g[0])/(1-i/n)(x-0)}, {x,0,1},DisplayFunction->Identity, PlotStyle->{RGBColor[0,0,1],RGBColor[1,0,0]}], DisplayFunction->$DisplayFunction, AxesLabel->{x,y}],{i,0,29,2}] 及时接车的模拟 Print["RND1","***","RND2","***","x","***","t2","***","RND3","***","t1","***","RND4","***","t3","***","T[i]"]; Do[RND3=N[Random[],3]; t1=Which[0 RND1=N[Random[],3]; RND2=N[Random[],3]; x=N[Sqrt[-2*Log[RND1]]*Cos[2*Pi*RND2],3]; t2=N[2*x+30,3]; RND4=N[Random[],3]; t3=Which[0 T[i]=If[t1+t2>t3,1,0]; Print[RND1,"***",RND2,"***",x,"***",t2,"***",RND3,"***",t1,"***",RND4,"***",t3,"***","T[",i,"]=",T[i]],{i,1,50}]; P=N[Sum[T[i],{i,50}]/50,4]*100; Print["TheProbabilityofmeetingis: ",P,"%"] 欧拉常数 TableForm[Table[{n,N[Sum[1/i,{i,1,n}]-Log[n+1]],N[1/n]},{n,1,1000}]] 解不等式 < InequalitySolve[x(x^2-2)(x^2-3)>0,x] 动态规划 Clear[X,U,V,x,y,z]; X=Table[x[i],{i,5}]; U=Table[u[i],{i,5}]; V=Table[v[i],{i,5}]; v[6]=0; f[x_,y_,z_]: =5y+4(x-y)+z; g[x_,y_]: =0.9x-0.1y; k=5; While[k>=1, xh=f[x[k],u[k],v[k+1]]/.x[k+1]->g[x[k],u[k]]; If[D[xh,u[k]]>0, u[k]=x[k]; v[k]=xh/.u[k]->x[k], u[k]=0; v[k]=xh/.u[k]->0; k--; x[1]=1000; i=2; While[i5, x[i]=N[0.9x[i-1]-0.1u[i-1]]; i++; Print["X=",X] Print["U=",U] Print["X-U=",X-U] Print["MAXPRICE=",V[[1]]] 四人追逐三人多人 1 t=10;dt=0.02;v=1;n=t/dt;robit={{{0,10}},{{10,10}},{{10,0}},{{0,0}}}; For[i=1,in,i++,For[j=1,j4,j++,xx1=robit[[j,i,1]];yy1=robit[[j,i,2]]; If[j4,xx2=robit[[j+1,i,1]];yy2=robit[[j+1,i,2]],xx2=robit[[1,i,1]];yy2=robit[[1,i,2]]]; dd=Sqrt[(xx2-xx1)^2+(yy2-yy1)^2]//N; xx1=xx1+v*dt*(xx2-xx1)/dd;yy1=yy1+v*dt*(yy2-yy1)/dd; robit[[j]]=Append[robit[[j]],{xx1,yy1}]]]; g1=ListPlot[robit[[1]],PlotJoin
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Mathematica100 例题 14 文档