# Use Mathematica to calculate the area enclosed between two curves

use mathematica

Hence, calculate the exact area enclosed by these curves using Mathematica. $f(x)=x^3$ and $g(x)=x^5 - 2 x^3 - 3 x$

i have got the graph...now I'm stuck with finding the area

-
the interval is not given... –  Ashneel Sep 1 '14 at 0:54
im also unable to figure out from the graph –  Ashneel Sep 1 '14 at 0:55

Here is a different approach based on the awesome new Region functions:

f[x_] := x^3
g[x_] := x^5 - 2 x^3 - 3 x


We solve for the intersections:

sol = x /. NSolve[f[x] == g[x], x, Reals]


{-1.94712297, 0, 1.94712297}

Edit

Here are the regions of interest:

r1 = ImplicitRegion[g[x] > y && f[x] < y, {{x, -1.94712297, 0}, y}];
r2 = ImplicitRegion[g[x] < y && f[x] > y, {{x, 0, 1.94712297}, y}];


And the area is simply:

Area @ RegionUnion[r1, r2]


14.7695075

We can visualize the region to be sure:

RegionPlot[{r1, r2}, PlotRange -> {{-3, 3}, {-8, 8}}]


-
Regarding all solutions using NSolve, numeric intermediate solutions and getting numeric area: Solve works fine, and produces a Root object. All values in this problem can be maintained in abstract, precise form - either Root, or converted to radicals using ToRadicals. And of course, FullSimplify often cleans up overly complicated radicals. –  kirma Sep 2 '14 at 17:28
@kirma, I realize that Solve works fine and gives the exact value, that was what I used first. I just wanted to use NSolve to keep things simple and convey the idea which is the important thing here. –  RunnyKine Sep 2 '14 at 17:30

Here's what the plot looks like:

f[x_] := x^3
g[x_] := x^5 - 2 x^3 - 3 x

Plot[{f[x], g[x]}, {x, -5, 5}, PlotRange -> {-10, 10}]


You first solve for the intersections:

sol = x /. NSolve[f[x] == g[x], x, Reals]

{-1.94712297, 0, 1.94712297}


Now you can find the area by integrating the difference between the curves in the intervals obtained:

Integrate[g[x] - f[x], {x, sol[[1]], sol[[2]]}]


7.38475373

Same goes for the interval from $0$ to $1.9471$, in this region $f(x) > g(x)$

Integrate[f[x] - g[x], {x, sol[[2]], sol[[3]]}]


7.38475373

So the total area is just $2(7.38475373)$

14.7695075

From the graph it's obvious both functions are symmetric and we could have just found the area in one region and multiplied by $2$.

-
f[x_] := x^3
g[x_] := x^5 - 2 x^3 - 3 x
sol = Partition[x /. NSolve[f[x] == g[x], x, Reals], 2, 1]
Tr@(Abs@Integrate[g[x] - f[x], {x, Sequence @@ #}] & /@ sol)

(*14.7695*)

-
Is there an obfuscated Mathematica contest?? :) –  Mark McClure Sep 1 '14 at 9:12
@MarkMcClure ya know: "your programming style mirrors your mind" –  belisarius Sep 1 '14 at 13:28

The exact area - i.e. not a numerical approximation - can be obtained as follows:

f[x_] := x^3;
g[x_] := x^5 - 2 x^3 - 3 x;


Find the points on the real axis where f[x] and g[x] intersect.

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

(* {{x -> 0}, {x -> Root[-3 - 3 #1^2 + #1^4 &, 1]}, {x -> Root[-3 - 3 #1^2 + #1^4 &, 2]}} *)


Compute the area enclosed by integrating Abs[f[x] - g[x]] between the end points.

area = Integrate[Abs[f[x] - g[x]], {x, x /. sol[[2]], x /. sol[[3]]}] // FullSimplify

(* 1/4 (27 + 7 Sqrt[21]) *)


Compute a numerical approximation to the enclosed area.

N[area]

(* 14.7695 *)

-