实验1考察函数f(x)=e在x=0处的增量比 程序 Clear[f]; f[x]: =Exp(x] d2=0;dl=l.eror=0.000001 X0=0: 1=0: m=l/error While[ abs[d2-dI perror h=1/10 1; d 2=dl d1=N[(x0+h]-fxOD/h, 201 i=i+l;Pint"h="N[h],"增量比",dl 结果: =1.增量比1.7182818284590452354 h=0.1增量比1.0517091807564762481 h=0,01增量比1.00501 h=0,001增量比1,0005 h=0.0001增量比1.0000500016667083342 h=0.00001增量比1.0000050000166667083 实验2考察函数 f(x)=e在,0处的导数 程序 Clear[f]; f[x ]=Exp(x]: x0=0; fl= Table[(xO+1^2]-xO])*^2,{1,50}]/N f2= Table[(-fx0-1/^2]+xO])*^2,{i,50}]/N p1=List Plot[fl, Display Function->Identity]; p2=ListPlot f2, Display Function->Identity Showlpl, p2, Display Function->DIsplay Function] 结果 0.996 Clear]; x FExpx Limit[(fh-fo/h, h->0, Direction->+1l Limit[(fth-fOD/h,h->0, Direction->-1 实验3考察函数 f(x)=x+x和=15处函数图形及在该点处的切线、 割线三者之间的关系
实验1 考察函数 在 处的增量比 程序: Clear[f];f[x_]:=Exp[x]; d2=0;d1=1.;error=0.000001; x0=0;i=0;m=1/error; While[Abs[d2-d1]>error, h=1/10^i;d2=d1;d1=N[(f[x0+h]-f[x0])/h,20]; i=i+1;Print["h=",N[h],"增量比",d1]]; 结果: 实验2 考察函数 在 处的导数 程序: Clear[f];f[x_]=Exp[x]; x0=0; f1=Table[(f[x0+1/i^2]-f[x0])*i^2,{i,50}]//N; f2=Table[(-f[x0-1/i^2]+f[x0])*i^2,{i,50}]//N; p1=ListPlot[f1,DisplayFunction->Identity]; p2=ListPlot[f2,DisplayFunction->Identity]; Show[p1,p2,DisplayFunction->$DisplayFunction]; 结果: Clear[f];f[x_]=Exp[x]; Limit[(f[h]-f[0])/h,h->0,Direction->+1] Limit[(f[h]-f[0])/h,h->0,Direction->-1] 实验3 考察函数 在 处函数图形及在该点处的切线、 割线三者之间的关系
程序 Clear[f]; fx]: =x4+x 2: For[i=1,1, PlotRange->1, 31,10, 609) Plotstyle->(RGBColor[1,0,0], RGBColor[0, 1,0] RGBColor[0, 0, 1111; 实验4对函数f(x)=x(x-1)(x-2),观察罗尔定理几何意义 程序 Clear[f]; fx=x*(x-1)*(x-2); gl=Plot[fx],ix-1, 3), PlotStyle->RGBColor[1,0,011 2= Plot[fIx],{x-1,3} NSolve[fIx]==0, x 结果 程序 out:{{x0.42265},{x81.57735} tx上=0.4265]t2[xl1.57735] Pot[{f{x],tl[x]t2[x]},{x-1,3} 结果 实验5对函数f(x)=h(+x)1,观察拉格朗日中值定理几何意 义 程序
程序: Clear[f];f[x_]:=x^4+x^2; For[i=1,i1,PlotRange->{{1,3},{0,60}}, PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,0], RGBColor[0,0,1]}]]; 实验4 对函数 ,观察罗尔定理几何意义 程序: Clear[f];f[x_]=x*(x-1)*(x-2); g1=Plot[f[x],{x,-1,3},PlotStyle->RGBColor[1,0,0]]; g2=Plot[f'[x],{x,-1,3}]; Show[g1,g2]; NSolve[f'[x]==0,x] 结果: 程序: out:{{x®0.42265},{x®1.57735}} t1[x_]=f[0.42265];t2[x_]=f[1.57735]; Plot[{f[x],t1[x],t2[x]},{x,-1,3}]; 结果: 实验5 对函数 ,在区间 观察拉格朗日中值定理几何意 义 程序:
Clear[gl, g2, a, b] fIx =Log[ 1+]; a=0; b=4, g1]:=a]+(tb-fl])*(x-a/(ba) g2[x]: =f[x]-(f[b]-fa](b-a); Plot[(fx]gl[x],x, a, b] 结果 实验6对函数 f()=2x+3x2+3x2-2x2,在区间r321上画出 f(x),f(x),f"(x) 图形,并找出所有驻点、拐点 程序 fx|2x^6+3x^5+3X^3-2x^2 Pot[!x],{x,-3,2}] df[x I =f[x]; ddfx ]=f'Ix Plot[dfx]x, 2, 1: Plot[dfx,{x-0.2,0.5} Plot[ddfs]x-2, 1) Plot[], df[x], ddfx],x, 0.6,0.6) PlotStyle->(RGBColor[1,0,0], RGBColor[0, 1, 0]. RGBColor[0,0,11)] NSolve[df[x]==0, X NSolve[ddf[x]=0, x 结果
Clear[f,g1,g2,a,b];f[x_]=Log[1+x];a=0;b=4; g1[x_]:=f[a]+(f[b]-f[a])*(x-a)/(b-a); g2[x_]:=f'[x]-(f[b]-f[a])/(b-a); Plot[{f[x],g1[x]},{x,a,b}]; 结果: 实验6 对函数 ,在区间 上画出 图形,并找出所有驻点、拐点 程序: f[x_]=2x^6+3x^5+3x^3-2x^2; Plot[f[x],{x,-3,2}]; df[x_]=f'[x];ddf[x_]=f''[x]; Plot[df[x],{x,-2,1}]; Plot[df[x],{x,-0.2,0.5}]; Plot[ddf[x],{x,-2,1}]; Plot[{f[x],df[x],ddf[x]},{x,-0.6,0.6}, PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,0], RGBColor[0,0,1]}]; NSolve[df[x]==0,x] NSolve[ddf[x]==0,x] 结果:
实验7对函数 f(x)=x6-2x3-x4+60x3-150x2-180x-25,在区间 66]出f(x,f(x,/x)图形,并找出所有驻点、拐点 程序 fx|=x^6/2-2x^5-25x^4/2+60x~3-150x^2-180x-2 Pot[{fx],f[x]fx]},{x,-6,6} PlotStyle->( Gray Level[O], Dashing[(0.01)lRGBColor[1,0,01)]; NSolve[f[x==0, x] SOlve[f"{x]=0,×] 结果 6a0 t{x→-4.44315},{x→-0.459096},{x→1.55293-1.82277i},{x→1.55293+1.822771},{x→5.12971}y {x→-3.25388},(x→0969666-0.7769321},(X→0.969666+0,776932立},{→3.98122 实验8对函数 f(x)=2sm2x+3x02x,在区间[0刀上找一点,,使得 在(x,f(x)点处的切线水平 程序: Clear[f]; fx]=2*Sin[2x 2+5x*Cos[x/2] 2/2: Plot[f(x],x, 0, Pi1; Plot[fx], f[x],(x, 0, Pi]; Findrootf[x==0,x, 0.8) FindRoot[[x]=0,x, 1.59 FindRoot[f[x]==0, x, 2) 结果:
实验7 对函数 ,在区间 上画出 图形,并找出所有驻点、拐点 程序: f[x_]=x^6/2-2x^5-25x^4/2+60x^3-150x^2-180x-25; Plot[{f[x],f'[x],f''[x]},{x,-6,6}, PlotStyle->{GrayLevel[0],Dashing[{0.01`}],RGBColor[1,0,0]}]; NSolve[f'[x]==0,x] NSolve[f''[x]==0,x] 结果: 实验8 对函数 ,在区间 上找一点 ,使得 在 点处的切线水平 程序: Clear[f];f[x_]=2*Sin[2x]^2+5x*Cos[x/2]^2/2; Plot[f[x],{x,0,Pi}]; Plot[{f[x],f'[x]},{x,0,Pi}]; FindRoot[f'[x]==0,{x,0.8}] FindRoot[f'[x]==0,{x,1.5}] FindRoot[f'[x]==0,{x,2}] 结果:
x→0.864194}(x→1.62391){x→2.24489} 实验9分析利用泰勒展开式近似计算:-时,和的影响 程序 tsin[x_, a n ]: =Module[ f, u), f-Normal[Series[Sin[t]t, a, n)1 uf/t->X; Return Nu, 1011 a=0; Table[NI(n, tsin [7, a, n), Sin[7]-tsin[7, a,n]]n, 5, 30,)1 n=5, Table Nfa, tsin [7, a, nl, Sin[71-tsin[ 7, a, n],1a, 3, 1091 {5.;89.8917;-89.2347},{10.,37.694x-37.037},(15.,0.0867075,0.570279} 20.,0.647032,0.00995448},(25 56992,-5,6898×10-6),(30,0,656987,-1,.83325×10-81) ((3.,-1.33055,1.98753},{4.,-0.248563,0.905549},{5.,0.584393,0.0725938},(6,0.656793,0.000193336}, (7.,0.656987,0.},(8.,0,658365,-0.00137831},{9,,0.713015,-0.0560288},(10.,0.508515,0.148471} 实验10观察函数 f(r)=sinx 各阶泰勒展开的图形
实验9 分析利用泰勒展开式近似计算 时 和 的影响 程序: tsin[x_,a_,n_]:=Module[{f,u},f=Normal[Series[Sin[t],{t,a,n}]]; u=f/.t->x;Return[N[u,10]]] a=0;Table[N[{n,tsin[7,a,n],Sin[7]-tsin[7,a,n]}],{n,5,30,5}] n=5;Table[N[{a,tsin[7,a,n],Sin[7]-tsin[7,a,n]}],{a,3,10}] 实验10 观察函数 各阶泰勒展开的图形
2 ⊥ 1