input mp-tool; %prologues:=0; %pi numeric pi; pi:=3.14159; %cos function for radian input def cos(expr x)= cosd(180/pi*x) enddef; %sin function for radian input def sin(expr x)= sind(180/pi*x) enddef; %xtick marks def xtick(expr p)= draw ((0,-2pt)--(0,2pt)) shifted p; enddef; %ytick marks def ytick(expr p)= draw ((-2pt,0)--(2pt,0)) shifted p; enddef; %opendot vardef open(expr pos)= path p; p:=fullcircle scaled 3pt; p:=p shifted pos; fill p withcolor white; draw p withcolor red; enddef; beginfig(1); %Define function to be drawn def f(expr x)= x*(x+2)*(x-2) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(xmin,f(xmin)); for x=xmin step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %Clip function path draw p; clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic withcolor blue; %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); endfig; beginfig(2); %Define function to be drawn def f(expr x)= x*(x+2)*(x-2) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(xmin,f(xmin)); for x=xmin step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %Clip function path draw p withcolor blue; %Highlight parts of the path that are above the axis p:=(-2,f(-2)); for x = -2 step dx until 0: p:=p--(x,f(x)); endfor; p:=p--(0,f(0)); p:=p xscaled ux yscaled uy; draw p withcolor red withpen pencircle scaled 1pt; p:=(2,f(2)); for x = 2 step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); p:=p xscaled ux yscaled uy; draw p withcolor red withpen pencircle scaled 1pt; %Draw open circles open((-2*ux,0)); open((0,0)); open((2*ux,0)); clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic; %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); endfig; beginfig(3); %Define function to be drawn def f(expr x)= exp(x) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(xmin,f(xmin)); for x=xmin step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %Clip function path draw p withcolor blue; %reflect p about x-axis draw (p reflectedabout ((0,0),(1,0))) withcolor red; clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic; %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); %label first curve label.rt(btex $y=e^x$ etex, (2ux,5uy)); %label second curve label.rt(btex $y=e^{-x}$ etex, (2ux,-5uy)); endfig; beginfig(4); %Define function to be drawn def f(expr x)= exp(x) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(xmin,f(xmin)); for x=xmin step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %Clip function path draw p reflectedabout ((0,0),(1,0)) shifted (0,1uy) withcolor blue; clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic; %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); %ytick marks for k=xmin step 1 until xmax: ytick((0,k*uy)) endfor; %label xticks label.lft(btex $-5$ etex, (0,ymin*uy)); label.lft(btex $5$ etex, (0,ymax*uy)); %draw in the asymptote draw (xmin*ux,1uy)--(xmax*ux,1uy) withcolor red dashed evenly; endfig; beginfig(5); %Define function to be drawn def f(expr x)= ln(x-2) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(2.01,f(2.01)); for x=2.01 step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %draw the function draw p withcolor blue; %clip clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic; %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); %draw the asymptote draw (2ux,ymin*uy)--(2ux,ymax*uy) dashed evenly withcolor red; %plot key point drawdot (3ux,0) withpen pencircle scaled 2pt; %label key point pic:=thelabel.ulft(btex $(3,0)$ etex, (3ux,0)); unfill bbox pic; draw pic; endfig; beginfig(6); %initialize scale numeric u; 10u=2in; %draw axes path xaxis,yaxis; xaxis:=(-5u,0)--(5u,0); yaxis:=(0,-5u)--(0,5u); drawdblarrow xaxis scaled 1.1; drawdblarrow yaxis scaled 1.1; label.rt(btex $x$ etex, (1.1*u*xmax,0)); label.top(btex $y$ etex, (0,1.1*u*ymax)); %tickmarks for k=-5u step 1u until 5u: xtick((k,0)); ytick((0,k)); endfor; %define and plot ellipse path p; p:=fullcircle xscaled 2u yscaled 6u; draw p shifted (1u,-2u) withcolor blue; %Label the center drawdot (1u,-2u) withpen pencircle scaled 2pt; %direction of motion drawarrow (2u,-2u)--((2u,-2u)+10*down) withpen pencircle scaled 1pt withcolor red; endfig; beginfig(7); %Define function to be drawn def f(expr x)= sqrt(x) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(0,f(0)); for x=0 step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %draw the function draw p withcolor blue; %reflect the function across x-axis draw p reflectedabout ((0,0),(1,0)) withcolor red; %clip clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic; %label the graphs label.top(btex $y=\sqrt{x}$ etex, (5ux,3uy)); label.bot(btex $y=-\sqrt{x}$ etex, (5ux,-3uy)); %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); %ytick marks for k=xmin step 1 until xmax: ytick((0,k*ux)) endfor; %label xticks label.lft(btex $-5$ etex, (0,ymin*ux)); label.lft(btex $5$ etex, (0,ymax*ux)); endfig; beginfig(8); %Define function to be drawn def f(expr x)= -sqrt(x+2) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(-2,f(-2)); for x=-2 step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %draw the function draw p withcolor blue; %clip clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic; %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); %ytick marks for k=xmin step 1 until xmax: ytick((0,k*ux)) endfor; %label xticks label.lft(btex $-5$ etex, (0,ymin*ux)); label.lft(btex $5$ etex, (0,ymax*ux)); endfig; beginfig(9); %Define function to be drawn def f(expr x)= -sqrt(x+2) enddef; %Declare and initialize viewing window numeric xmin, xmax, ymin, ymax; xmin=-5; xmax=5; ymin=-5; ymax=5; %Declare and initialize scaling variables numeric ux, uy; (xmax-xmin)*ux=2in; (ymax-ymin)*uy=2in; %Declare and initialize clipping boundary path q; q:=(xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle; q:=q xscaled ux yscaled uy; %Declare and initialize number of plotted points numeric N; N:=200; %Declare and calculate plotting increment delta x numeric dx; dx:=(xmax-xmin)/N; %Declare and create function path path p; p:=(-2,f(-2)); for x=-2 step dx until xmax: p:=p--(x,f(x)); endfor; p:=p--(xmax,f(xmax)); %Scale function path p:=p xscaled ux yscaled uy; %draw the function draw p withcolor blue; %draw the line y=x draw (-5u,-5u)--(5u,5u) withcolor black; %draw the reflection draw p reflectedabout ((0,0),(1,1)) withcolor red; %clip clip currentpicture to q; %Save and clear the function path picture pic; pic:=currentpicture; clearit; %Draw and label coordinate axes drawdblarrow (1.1xmin*ux,0)--(1.1xmax*ux,0); label.rt(btex $x$ etex,(1.1xmax*ux,0)); drawdblarrow (0,1.1ymin*uy)--(0,1.1ymax*uy); label.top(btex $y$ etex,(0,1.1ymax*uy)); %Superimpose function plot draw pic; %xtick marks for k=xmin step 1 until xmax: xtick((k*ux,0)) endfor; %label xticks label.bot(btex $-5$ etex, (xmin*ux,0)); label.bot(btex $5$ etex, (xmax*ux,0)); %ytick marks for k=xmin step 1 until xmax: ytick((0,k*ux)) endfor; %label xticks label.lft(btex $-5$ etex, (0,ymin*ux)); label.lft(btex $5$ etex, (0,ymax*ux)); %Label f label.bot(btex $f$ etex, (5ux,-3uy)); %label f^-1 label.lft(btex $f^{-1}$ etex, (-3ux,5uy)); %label y=x label.urt(btex $y=x$ etex, (5u,5u)); endfig; beginfig(10); %initialize scale numeric u; 10u=2in; %axes drawdblarrow (-3.1u,0)--(7.1u,0); drawdblarrow (0,-5.1u)--(0,5.1u); endfig; end