Linear Approximation
Calculus I
Andy Long

Approximate Sqrt[15.96]

Clear[f,a,Da,L]
f[x_]:=Sqrt[x]
a=16;
Da=-.04;
L[x_]:=f[a]+f'[a](x-a)
L[15.96]
f[15.96]
f[15.96]-L[15.96]
Plot[{f[x],L[x]},{x,0,20}]
Plot[{f[x],L[x]},{x,a-Da,a+Da}]

#2, p. 187

f[x_]:=Sin[x]
a=Pi/6;
Da=.1;
L[x_]:=f[a]+f'[a](x-a)
L[.5]
f[.5]
Plot[{f[x],L[x]},{x,0,Pi}]
Plot[{f[x],L[x]},{x,a-Da,a+Da}]

(* I define the relative error so that, if the approximation is bigger than f[x], then the error will be positive: *)
rerror[x_]:=(L[x]-f[x])/f[x]
rerror[.5]
perror[x_]:=rerror[x]*100
perror[.5]

#5, p. 187

f[x_]:=Sqrt[1-x]
a=0;
Da=.1;
L[x_]:=f[a]+f'[a](x-a)
Plot[{f[x],L[x]},{x,-.5,.5}]
Plot[{f[x],L[x]},{x,a-Da,a+Da}]

L[.1]
f[.1]
rerror[.1]
perror[.1]
L[.01]
f[.01]
rerror[.01]
perror[.01]

#32, p. 188

area[r_]:=Pi r^2
Plot[{area[r],area[24]+area'[24](r-24)},{r,23,25}]
dy=area'[r]*dx
dx=.2
r=24
dy
area[24+dx]-area[24]
area[24-dx]-area[24]
re= dy/area[24]
pe= 100*re