3
$\begingroup$

I'm trying to solve and approximate the area between the two graphs. Right now, my functions are stored as

f[x_] := 3 Sin[x]
g[x_] := x - 1

and then I tried to integrate by evaluating

Integrate[Abs[f[x] - g[x]], x]

Instead of getting an answer, I just get the exact same thing I inputted

Integrate[Abs[f[x] - g[x]], x]

How do I fix this?

$\endgroup$
1
  • $\begingroup$ You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$
    – Michael E2
    Commented Apr 12, 2019 at 2:35

3 Answers 3

4
$\begingroup$

Use Assumptions:

Integrate[Abs[f[x] - g[x]], x, Assumptions -> x \[Element] Reals]

Mathematica graphics

Or try RealAbs instead of Abs:

Integrate[RealAbs[f[x] - g[x]], x]

Mathematica graphics

(They are equivalent antiderivatives.)

To get the area between the graphs, you need also to solve for the points of intersection.

area = Integrate[
 Abs[f[x] - g[x]], {x, Sequence @@ MinMax[x /. Solve[f[x] == g[x], x, Reals]]}]

Mathematica graphics

The area is approximately:

N[area]
(*  5.57475  *)
$\endgroup$
1
  • $\begingroup$ RealAbs is awesome to know about! :O $\endgroup$
    – Kagaratsch
    Commented Apr 12, 2019 at 2:40
2
$\begingroup$

You need to add assumptions, like this

 Integrate[Abs[f[x] - g[x]], x, Assumptions :> Element[x, Reals]]

Mathematica graphics

$\endgroup$
0
$\begingroup$

Assuming your functions

f[x_] := 3 Sin[x] 
g[x_] := x - 1

are real valued, you can use square root of square to parametrize the absolute value. This then gives:

Integrate[Sqrt[(f[x] - g[x])^2], x]

(((-2 + x) x + 6 Cos[x]) Sqrt[(-1 + x - 3 Sin[x])^2])/(2 (-1 + x - 3 Sin[x]))

$\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.