Homework problems from section 1.8:
Andy Long
Calculus I

(* #4: The function is discontinuous at -2, 2, 4, and 6; it is continuous from the right at 
-4 and 2. Everywhere else on the interval (-4,8) it is continuous. 
*)

#21

(* This is the ugly way to create a small circle for the hole in the graph to follow: *)
{m1,m2,m3,m4}=Graphics/@{Circle[{0,0},1],Disk[{0,0},1],Line[{{-0.5,-0.5},{0.5,-0.5},{0.5,0.5},{-0.5,0.5},{-0.5,-0.5}}],Polygon[{{-0.5,-0.5},{0.5,-0.5},{0.5,0.5},{-0.5,0.5}}]};

p1=Plot[Piecewise[{{Cos[x],x<0},{0,x==0},{1-x^2,x>0}}],{x,-1,1}];
p2=ListPlot[{{0,0}},PlotStyle->PointSize[0.025]];p3=ListPlot[{{0,1}},PlotStyle->PointSize[0.05],PlotMarkers->{m1,.05}];
Show[p1,p2,p3]

#44

G=1;
M=1;
R=1;
f[x_]:=Piecewise[{{G M x/R^3,x<R},{G M /x^2,x>=R}}]
Plot[f[x],{x,0,2}]

#47

f[x_]:=(x^4-1)/(x-1)
g[x_]:=(x^2+1)(x+1)
Plot[{f[x],g[x]},{x,0,2}]

f[x_]:=(x^3-x^2-2x)/(x-2)
g[x_]:=x(x+1)
Plot[f[x],{x,1,3}]

f[x_]:=Floor[Sin[x]]
p2=ListPlot[{{Pi,f[Pi]}},PlotStyle->PointSize[0.025]];p1=Plot[f[x],{x,2,5}];
Show[p1,p2]

(* #42:
continuous from the left at 1, 
from the right at 3. *)
P1=Plot[
Piecewise[{{x+1,x≤1},{1/x,x>1&&x<3},{Sqrt[x-3],x≥3}}]
,{x,0,5}, PlotRange->{-1,3}
];
P2=ListPlot[{{1,2},{3,0}},PlotMarkers->{"☺"}];
Show[P1,P2]

(* #56:
a. Since f is continous on the interval (-1,0), and negative at -1 and positive at 0, the function must have a root (where f(x)=0) somewhere between, by the Intermediate Value Theorem.
 *)
f[x_]:=x^5-x^2+2x+3;
a=-1;
b=0;
P1=Plot[f[x],{x,a,b}];
P2=ListPlot[{{a,f[a]},{b,f[b]}},PlotMarkers->{"☺"}];
Show[P1,P2]

a=-.9;
b=-.85;
P1=Plot[f[x],{x,a,b}];
P2=ListPlot[{{a,f[a]},{b,f[b]}},PlotMarkers->{"☺"}];
Show[P1,P2]

(* b. By successive zooming in, we've got an interval where the function has a root on an interval of length .01. 
*)
a=-.875;
b=-.865;
P1=Plot[f[x],{x,a,b}];
P2=ListPlot[{{a,f[a]},{b,f[b]}},PlotMarkers->{"☺"}];
Show[P1,P2]

(* #52, p. 92: notice that we have to create f, in order to use the IVT. Then we should discuss continuity.... *)

f[x_]:=1-x-x^(1/3)
f[0]
f[1]

(* 
Because this function is continuous on the interval (0,1), there must be a root -- a place where f[c]=0; that is, where 1-x-x^(1/3)=0, or rather that x^(1/3)=1-x .
*)

(* #56, p. 92 *)

f[x_]:=x^5-x^2+2x+3
(* Just try some values, that are easy, and try to get a change in sign: *)
f[0]
f[-1]

Plot[f[x],{x,-1,0}]

Plot[f[x],{x,-.875,-.865}]