实验1利用定义计算积分(x2a 程序 Clear[f, x]; fIx]: =2; a=0; b=l; n=20 Array,{641}];x[0}=a For[k=1,k<=6,k++,xn]=b,s=0 Do[x[iF=(i+ Random*(b-a)n, i,l, n-11 For[i=o, i<n, i++, delxi=x[i+1l-x; c=x[+delxi*Random[ s-S+fc]*deli] Print[n=, n, s= s]; n=n*2 实验2从图形上观察 的积分和与定积分的关系 inxdx 程序: Clear[i,n, a, b]: Clear[f, c, d, x, s] regularpartition[a b_ n]: =P-Block 1, Table[N[a+(b-a)i/n]i randompartition P=Union[Table[Random[Real, Na], N[bn-1 Na] N[b sf, c, d, x, choice: 1]: -If[c<=x<=d, f[(I-choice)*+choice*d riemann f, a, b,n, choice: 1: -N(b-a)*Sumf[(l-choice) *(a+ choice*(a+i*(b-a)/n)], 1, n/n]; arbitraryriemann[f_, P, choice: 1]: = Blockli Sum[(Unionn[Plllit1ll-UnionINIPIl[D* f(l-choice)*Union[N[p][]+choice*Union[N[P][i+1]],{,1 Abs[NIntegratefx]x, a, b)-riemann[f, a, b, b, choice]I ear[f, P, choice: 1]: =BlockRx) Abs[[f[x],x, Min[N[Pll, Max[N[Pl]-arbitraryriemar viewapproxlf, P, choice: 1:( one=Block(), Plot[fx]x, Min[N[Pl-0. 1, Max[N[P]1+0.1) Display Function->Identity l two=Block[i, x, Plot[ReleaselTable[s[f, Union[N[P[il, Union choice],i,Length[P]-1x, Min[N[P]1-0. 1, Max[N[P+.1,P >AlLPlot Points ->50, Display Function->ldentity l1 Block), Showtwo, one, PlotLabel-> ToString Length[P]-1]>"分化最大分化" ToStringINnorm
实验1 利用定义计算积分 程序: Clear[f,x];f[x_]:=x^2;a=0;b=1;n=20; Array[x,{641}];x[0]=a; For[k=1,k<=6,k++,x[n]=b;s=0; Do[x[i]=(i+Random[])*(b-a)/n,{i,1,n-1}]; For[i=0,i<n,i++,delxi=x[i+1]-x[i];c=x[i]+delxi*Random[]; s=s+f[c]*delxi]; Print["n=",n,"s=",s];n=n*2] 实验2 从图形上观察 的积分和与定积分的关系 程序: Clear[i,n,a,b];Clear[f,c,d,x,s]; regularpartition[a_,b_,n_]:=P=Block[{i},Table[N[a+(b-a)i/n],{i, randompartition[a_,b_,n_]:= P=Union[Table[Random[Real,{N[a],N[b]}],{n-1}],{N[a],N[b]} s[f_,c_,d_,x_,choice_:1]:=If[c<=x<=d,f[(1-choice)*c+choice*d] riemann[f_,a_,b_,n_,choice_:1]:=N[(b-a)*Sum[f[(1-choice)*(a+ choice*(a+i*(b-a)/n)],{i,1,n}]/n]; arbitraryriemann[f_,P_,choice:1]:=Block[{i}, Sum[(Union[N[P]][[i+1]]-Union[N[P]][[i]])* f[(1-choice)*Union[N[p]][[i]]+choice*Union[N[P]][[i+1]]],{i,1, er[f_,a_,b_,n_,choice_:1]:= Abs[NIntegrate[f[x],{x,a,b}]-riemann[f,a,b,b,choice]]; ear[f_,P_,choice_:1]:=Block[{x}, Abs[NIntegrate[f[x],{x,Min[N[P]],Max[N[P]]}]-arbitraryrieman viewapprox[f_,P_,choice_:1]:=( one=Block[{x},Plot[f[x],{x,Min[N[P]]-0.1,Max[N[P]]+0.1}, DisplayFunction->Identity]]; two=Block[{i,x},Plot[Release[Table[s[f,Union[N[P]][[i]],Union choice],{i,Length[P]-1}]],{x,Min[N[P]]-0.1,Max[N[P]]+0.1},Pl >All,PlotPoints ->50,DisplayFunction->Identity]]; Block[{x},Show[two,one,PlotLabel-> ToString[Length[P]-1]<>"分化最大分化"<>ToString[N[norm[P
All, Display Function->DIsplay FunctionD) Dolviewapprox[Sin, regularpartition[O, Pi, 2/n],0.5,n, 2,61 viewapprox[Sin, randompartition[O, P1, 16], 1] Dolviewapprox[Arc Tan, randompartition[o, Pi, 2'n,1,n, 2,6) 结果 t.- arbitraryriemarn[ain,(0,0.7853981.5708,2.5619;3.14159)0.51]=0,配误,误相∞ ann [sin;{0,0.396990.7853981.17a1,1.57081.96252.35619;z.7489,214159}0.5】 0,4
All,DisplayFunction->$DisplayFunction]]); Do[viewapprox[Sin,regularpartition[0,Pi,2^n],0.5],{n,2,6}]; viewapprox[Sin,randompartition[0,Pi,16],1]; Do[viewapprox[ArcTan,randompartition[0,Pi,2^n],1],{n,2,6}]; 结果:
0.589049:0.785396;0.981741.171;1.37445:1.57修:1.767151.6352.159,2.35619;2.55 0,8 0.6 0,唾 1.5 2。5 0.981741.079921.1711.27627,1.374451.4?62,1.57061.668971.767151.86532:1.962 0.6 04 1.5
L,1.2271;1.t76271.32536;1.37445,1.2353:1.47t62;1.521n1,1.570:1.619;1.65897,1 25 9:1.362161.44331.種67;1.35522.00317,2.472.34137;2.496;2.693362.7了 实验3画出变上限函数 f()=l tedt 及函数 f(x)=x 程序: fl[x]: =Integrate[t*Exp[t 2],t,0, x] f2 x]: =x*Explx/] gl=Plot[fl[x](x,0, 3 Plotstyle->RGBColor[1,0,011 g2=Plot[f2[x]x,0, 3), Plotstyle->RGBColor[0,0, 1 Showlgl, g2]
实验3 画出变上限函数 及函数 程序: f1[x_]:=Integrate[t*Exp[t^2],{t,0,x}]; f2[x_]:=x*Exp[x^2]; g1=Plot[f1[x],{x,0,3},PlotStyle->RGBColor[1,0,0]]; g2=Plot[f2[x],{x,0,3},PlotStyle->RGBColor[0,0,1]]; Show[g1,g2]; 结果:
250自 1000 实验4画出变上限函数 tsint dt 及其导函数的图形 程序 fI[x]: =Integratet*Sin[t2,t,O,XI f2 x]: = EvaluateDflx], xJI gl=Plot[fl[x],x, 0, 3), Plotstyle->RGBColor[1, 0,01 g2=Plotf2[]( x, 0, 3), Plotstyle->RGBColor[0, 0, 11] Showlgl, g2 结果
实验4 画出变上限函数 及其导函数的图形 程序: f1[x_]:=Integrate[t*Sin[t^2],{t,0,x}]; f2[x_]:=Evaluate[D[f1[x],x]]; g1=Plot[f1[x],{x,0,3},PlotStyle->RGBColor[1,0,0]]; g2=Plot[f2[x],{x,0,3},PlotStyle->RGBColor[0,0,1]]; Show[g1,g2]; 结果: