Suppose we want to find the area enclosed by the graphs of f[x_]:=Sin[x] and g[x_]:=Cos[2*x] on the interval 0 <= x <= Pi/2. Let’s first define the functions. Notice that Mathematica is case-sensitive, so it is IMPORTANT that you match cases, i.e., you have to use “Sin” and not “sin” or “SIN”.

f[x_]:=Sin[x]

g[x_]:=Cos[2*x]

Now let’s plot the function. Be very careful to distinguish between braces and brackets. The first argument is the function list in braces, the second is the independent variable (x) and its range, enclosed in braces, and the third is a PlotRange option that indicates the range of the outputs.

Plot[{f[x],g[x]},{x,-0,Pi/2},PlotRange->{-2,2}]

Now let’s try to use the Solve command to find the exact solutions. Incidentally, if you want approximate solutions, you can use the NSolve command. We’ll talk more about that later.

Solve[f[x]==g[x],x]

Notice that it only provides three (exact) solutions, though there are in fact infinitely many. By looking at the graph above, we know that Pi/6 is the one we want. Finally we can integrate the absolute value of the difference of the two functions on the interval to find the area between the curves:

Integrate[Abs[f[x]-g[x]],{x,0,Pi/2}]

or we can write the area between the curves as a sum of two integrals where the integrands are each positive. Either way, we get the same answer.  You can use these ideas and commands to do #41 on p. 427 as part of your homework.

Integrate[g[x]-f[x],{x,0,Pi/6}]+Integrate[f[x]-g[x],{x,Pi/6,Pi/2}]