Sample problems from Section 2.1
MAT129
Andy Long

(* p. 110--, #3, 11, 13, 29, 45, 51 *)

(* #3 *)
f[x_]:=4x-x^2;
m=f'[1]
P1=Plot[f[x],{x,0,2}];
P2=Plot[m*(x-1)+f[1],{x,0,2}];
P3=ListPlot[{{1,3}}];
Show[P1,P2,P3]

(* #11 *)
f[x_]:=Piecewise[{
{3x,x<1},
{3,x<2},
{3-2(x-2),x<3},
{1,x<4},
{x-3,x≥4}
}]
Plot[{f[x],f'[x]},{x,0,6}]

(* #13 *)
f[x_]:=40x-16x^2;
a=2;
m=f'[a]
P1=Plot[f[x],{x,a-1,a+1}];
P2=Plot[m*(x-a)+f[a],{x,a-1,a+1}];
P3=ListPlot[{{a,f[a]}}];
Show[P1,P2,P3]

(* #29 *)
Clear[a]
f[t_]:=(2t+1)/(t+3);
m=Together[f'[a]]

(* #45 *)
f[x_]:=5000+10x+.05x^2;
Plot[f[x],{x,90,110}] (* it's fairly linear in the vicinity of 100 *)
a=100;
m1=(f[a+5]-f[a])/5
m2=(f[a+1]-f[a])/1
m=f'[a]
P1=Plot[f[x],{x,a-1,a+6}];
P2=Plot[m*(x-a)+f[a],{x,a-1,a+6}];
P3=ListPlot[{{a,f[a]},{a+1,f[a+1]},{a+5,f[a+5]}}];
Show[P1,P2,P3]

(* #51: I might use the secant line joining the two neighboring points (8,12) and (24,8) to create a good approximation to the slope of the tangent line at T=16: *)
slope=(8-12)/(24-8)