# How to find the area between two curves

Find the area between y = 1 - x/π and y = Sin[x].

Here is what I have typed in so far into Mathematica:

Clear[f, g, x]
f[x_] := 1 - x/π
g[x_] := Sin[x]
Plot[{f[x], g[x]}, {x, 0, 2 π},
PlotStyle -> {Red, Blue}, PlotRange -> {-1.2, 1.2}, Filling -> {1 -> {2}}]


The graph worked, so I have that. However, when I try to do the next step, Solve[f[x] = g[x], x], it will not give me the intersects. I have even tried retyping the equations in: Solve[Sin[x] = 1 - x/π, x], but nothing is working. What am I doing wrong?

• Hi Alison. You need to use Pi (not pi), and == (not =). And try specifying Reals for Solve's domain. (Although that might not be the real problem.) And I wonder, section 6.1 of what? Dec 16, 2013 at 14:37
• Works for me with Solve[f[x] == g[x], x, Reals]. Dec 16, 2013 at 14:51
• The real problem is that it is a trancedental equation and no analytical solutions to these types of equations are known in general (though the x=Pi solution can be readily seen here). Try NSolve instead for a numerical solution. Dec 16, 2013 at 14:59
• FYI you can just integrate the thing without explicitly finding the roots.. Integrate[Abs[f[x] - g[x]], {x, 0, 2 Pi}] // N Dec 16, 2013 at 16:43
• @george2079, I wrote this answer with little more explanation. Dec 16, 2013 at 22:10

This

Plot[Abs[f[x] - g[x]], {x, 0, 2 Pi}, Filling->Axis]


should convince you that this measures the high between the two curves (*), regardless of which one is at the top. So, as pointed already by @george2079, use NIntegrate like

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


%= 2.43935

(*) Note that Mathematica has powerful integration mechanisms, but you need to gain insight in what you are doing to unleash its power. Abs is a measure of magnitude in the real line and that's why is being used above.