Section 5.1
Calculus I
Andy Long

#2, p. 349

(* #2, p. 349 *)
y1[x_]:=2x
y2[x_]:=x^2-4x
Plot[{y1[x],y2[x]},{x,0,6}]
Integrate[(y1[x]-y2[x]),{x,0,6}]

(* Now let's extend the integral back to -2,6: *)
Plot[{y1[x],y2[x]},{x,-2,6}]
(* To calculate the physical (positive) area, we can either use the absolute value, *)
Integrate[Abs[y1[x]-y2[x]],{x,-2,6}]
(* or we can break up the integral, based on which function is on top. For this we need to find the points of intersection, generally: *)
Integrate[(y2[x]-y1[x]),{x,-2,0}]+Integrate[(y1[x]-y2[x]),{x,0,6}]

#3, p. 349

(* #3, p. 349 *)
x1[y_]:=Sqrt[y]
x2[y_]:=y^2-1
(* First, a straightforward integration along the y-axis: *)
Integrate[(x1[y]-x2[y]),{y,0,1}]
(* Notice, however, that it doesn't matter what I call the dummy variable: so I could have simply interchanged the roles of x and y, and proceeded as though my graph had been reflected about the line y=x: *)
Integrate[(x1[x]-x2[x]),{x,0,1}]
Plot[{x1[x],x2[x]},{x,0,1},AspectRatio->2]

(* Now let's integrate along the x-axis -- but we'll have to break the integral into two parts: *)
y1[x_]:=x^2
y2[x_]:=Sqrt[x+1]
Plot[{
Piecewise[{{y2[x],x<0},{1,x≥0}}],
Piecewise[{{0,x<0},{y1[x],x≥0}}]
},
{x,-1,1}
]
Integrate[(y2[x]-0),{x,-1,0}]+Integrate[(1-y1[x]),{x,0,1}]

(* Alternatively, we could just use the piecewise functions directly (Mathematica doesn't care!): *)
Integrate[(Piecewise[{{y2[x],x<0},{1,x≥0}}]-
Piecewise[{{0,x<0},{y1[x],x≥0}}]),{x,-1,1}]

#6, p. 349

(* #6, p. 349*)
f[x_]:=x
g[x_]:=Sin[x]
Plot[{f[x],g[x]},{x, 0, Pi}]
Integrate [f[x]-g[x],{x, Pi/2, Pi}]

#17, p. 349

(* #17: there's nothing special about x and y -- you can certainly interchange them without penalty! *)
f[x_]:=4+x^2
g[x_]:=2x^2
Plot[{f[x],g[x]},{x, -2,2}]
Integrate [f[x]-g[x],{x, -2,2}]

#31, p. 349

(* #31: *)
f[x_]:=Sin[x]
g[x_]:=Cos[2x]
Plot[{f[x],g[x]},{x, 0, Pi/2}]
Simplify[Integrate [Abs[f[x]-g[x]],{x, 0, Pi/2}]]
Solve[f[x]==g[x],x]
Integrate [g[x]-f[x],{x, 0, Pi/6}]+ Integrate [f[x]-g[x],{x, Pi/6, Pi/2}]

#41: the exact area enclosed by the curves y=x^5-6x^3+4x and y=x

#41, p. 349

(* #41, p. 349 *)
y1[x_]:=x^5-6x^3+4x
y2[x_]:=x
roots=Solve[y1[x]==y2[x],x]
solns=x/.roots
N[solns]

Plot[{y1[x],y2[x]},{x,Min[solns],Max[solns]}]

2*(Integrate[Abs[y1[x]-y2[x]],{x,0,Max[solns]}]) (* use symmetry! *)

#46, p. 350

(* #46, p. 350 *)
Clear[t,b,d]
b[t_]:=2200+52.3t+0.74t^2
d[t_]:=1460+28.8t
Plot[{b[x],d[x]},{x,0,10},AxesOrigin->{0,0}]
Integrate [b[x]-d[x],{x, 0, 10}]