code for diagrams
look inputs an expression in x, a number w, a range [a,b], and an increment deltax - it then plots onthe interval [a,b] the expression and the tangent line at the point w and the chord from point on the graph above w to that above w+deltax.
> look:=proc (f, w, deltax, range) local P1, P2, P3, pointsplot, line1, line2, line3, line4, fplot, fw, chordslope, chord, chordplot, tanslope, tanline, tanplot, txt1, txt2; P1 := [w, subs(x = w,f)];fw:=P1[2]; P2 := [w+deltax, subs(x = w+deltax,f)]; P3 := P1-P2; pointsplot := plot({P1, P2},style = POINT,thickness = 3,color = black); line1 := plot([[P1[1], 0], P1],linestyle = 3); line2 := plot([P1, [0, P1[2]]],linestyle = 3); line3 := plot([[P2[1], 0], P2],linestyle = 3); line4 := plot([P2, [0, P2[2]]],linestyle = 3); fplot := plot(f,x = range[1] .. range[2],thickness = 1,color = blue); fw := subs(x = w,f); chordslope := P3[2]/P3[1]; chord := (x-P1[1])*chordslope+P1[2]; chordplot := plot(chord,x = range[1] .. range[2],color = green); tanslope := subs(x = w,diff(f,x)); tanline := (x-P1[1])*tanslope+P1[2]; tanplot := plot(tanline,x = range[1] .. range[2],color = black); txt1 := plots[textplot]([.7*range[2], subs(x = .7*range[2],chord), ` CHORD`],align = RIGHT,font = [TIMES, BOLD, 14],color = green); txt2 := plots[textplot]([.8*range[2], subs(x = .8*range[2],tanline), ` TANGENT`],align = RIGHT,color = brown); plots[display]([pointsplot, txt1, txt2, fplot, chordplot, tanplot, line1, line2, line3, line4],scaling = constrained,title = convert(Delta_x = deltax,string),xtickmarks = [0, range[1], w, (w+deltax),range[2]],ytickmarks = [0,evalf(P1[2]),evalf(P2[2])],titlefont = [TIMES, BOLD, 18],axesfont = [TIMES, BOLD, 16]) end:
>
> f:=sqrt(625-x^2): fw:=subs(x=w,f): look(f,7,10,[0,30]):