We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
#Title:’ FTC Squeeze
#Author: Gord Clement, January 2011
Description : Animation to illustrate a key step in the proof of the fundamental theorem of calculus,
# Shows +0 ~ and the absolute maximum and minimum on [x, x +h] converging to x
Usage: No user input required
output = [ J:
Hdefine function with lots of local maxima and minima
ges (X—1)-(8 = 2) (x $1) -(e 2) +10:
plot of function
origplot = plot(g, x =-2.5 .2.5 ,y=5 20, tickmarks = (0, 0], thickness =2, labels
Hplot of vertical line for x
oe)
xplot = plot( {-2.005, y, y=5 15], x=-2.5..2.5 20, linestyle= dash, color = black, labels
[nam
#label for x
xlabel = plots[textplot]([ ~2.005, 15.5, typeset(x) }) :
Hinitalize H
Hi=4:
for i from 0 to.48 do
‘istep through H values
H = H—0.08;
#find absolute max and min values
‘my = minimize(g, x =-2.005 ..-2.005 +H);
My == maximize(g, x =-2.005 ..-2.005 +H);
tiplot for max and min values
minpiot = plot(my, x =-2.005 ..~2.005 +H, color = blue, thickness =2, labels = [", *"
‘maxplot = plot( My, x =~2.005 ..-2.005 + H, color = green, thickness = 2, label
iifind x value corresponding to min
mx == ~0,565; #default to the one x value that numerically slips through the cracks
mxList = evalf (solve(g=my, x) assuming real; #find all possible x values for the min
if (nops( [mxList }) = 1) then
mx = mxList : #if just one, use that value
else
tifind a value in the interval [x,x-+h]
for j from | to nops( [mxList]) do
if (-2.006 < mxList{ j] <-2.004 + H) then
mx i= mxListl jl;
end if
end do;
endif,
tifind x value corresponding to the max
MxList ‘= evalf (solve(g = My, x));
Mx '= - 1.66; #default t0 the one value the numerically slips through the cracks
if (nops( [MxList}) = 1) then
Mx = MxList
else
for jfrom | tonops([MxList]) do
if (-2.006 < MeList[ j] <-2.004 + H) thenMx = MxList[ j);
end if,
end do;
end if,
tiplots to label m and M
text += plots{ textplot]( (mx, 16, typeset(m) ])
Mtext == plots{ textplot]( (Mx, 16.5, typeset(M) ]) :
mplot ‘= plot( (mx, y, y=my..16], x =-2.5 ..2.5, »=5 ..20, linestyle = dash, color = black, labels
Hint.
Mplot = plot( (Mx, y, y= My .16.5 },x=-2.5 .2.5, y= 5.20, linestyle= dash, color = black, labels
=o");
tiplots to label x-th
xhplot = plot{ [ -2.005 +H, y,y=5..17],x=-2.5..2.5, y=5..20, linestyle= dash, color = black,
labels = (",""]);
xhlabel = plots|textplot)( { -2.005 + H, 17.5, typeset(x +h) ) :
put all the pieces together
{fullplot = plots display) [origplot,xplot, minplot, maxplor, xkplot,xlabel, xhlabel, mtext, Mtext,
mplot, Mplot], title= ypeset|
evalf( 4, 3) ) . caption = typeset(""The Maximum value ",
f(M)," is plotted in green. The minimum value ", f(m)," is plotted in blue."), labels = ["",
#add full plot to the list
output = [op output), fullplot]
end do:
Hanimate list
plots|display|{ [op (output) |, insequence = true, view= [ -2.5..2.5, 5..20])