1
$\begingroup$

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?

$\endgroup$
5
  • 4
    $\begingroup$ 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? $\endgroup$
    – cormullion
    Dec 16, 2013 at 14:37
  • 1
    $\begingroup$ Works for me with Solve[f[x] == g[x], x, Reals]. $\endgroup$
    – m_goldberg
    Dec 16, 2013 at 14:51
  • 2
    $\begingroup$ 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. $\endgroup$ Dec 16, 2013 at 14:59
  • $\begingroup$ FYI you can just integrate the thing without explicitly finding the roots.. Integrate[Abs[f[x] - g[x]], {x, 0, 2 Pi}] // N $\endgroup$
    – george2079
    Dec 16, 2013 at 16:43
  • $\begingroup$ @george2079, I wrote this answer with little more explanation. $\endgroup$
    – carlosayam
    Dec 16, 2013 at 22:10

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.