Function Repository Resource:

AreaBetweenCurvesIntegral

Source Notebook

Compute the integral describing the area between two plane curves

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["AreaBetweenCurvesIntegral"][{f,g},{x,xmin,xmax}]

returns an Inactive integral representing the area of the enclosed region between the functions f(x) and g(x) over the interval xmin<x<xmax.

Details and Options

ResourceFunction["AreaBetweenCurvesIntegral"] works with real‐valued functions over the Cartesian coordinate system.
The area between f(x) and g(x) is defined as .
When f(x)g(x), the area between the two curves is .
When f(x) and g(x) only meet at x=xmin and x=xmax, the area is taken to be that of the enclosed region.
When f(x) and g(x) do not meet at x=xmin or x=xmax, the boundary of the enclosed region will contain vertical line segments joining the curves.
When f(x) and g(x) intersect for some xmin<x<xmax, the area will be that of multiple enclosed regions.
The following option can be given:
Assumptions$Assumptionsassumptions on parameters

Examples

Basic Examples (2) 

Compute an integral representing the area between two curves:

In[1]:=
area = ResourceFunction[
  "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{x, x^2}, {x, 0, 1}]
Out[1]=
In[2]:=
Plot[{x, x^2}, {x, 0, 1}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[2]=

Activate the integral to compute the area:

In[3]:=
Activate[area]
Out[3]=

Scope (4) 

Find the area of the region enclosed by two curves:

In[4]:=
area = ResourceFunction[
  "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{x^2 - 1, 1 - x^2}, {x, -1, 1}]
Out[4]=
In[5]:=
Activate[area]
Out[5]=
In[6]:=
Plot[{x^2 - 1, 1 - x^2}, {x, -1, 1}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[6]=

Where the curves do not meet:

In[7]:=
ResourceFunction[
 "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Sin[2 x]/2 + 2, Cos[x]/2 - 1}, {x, 0, 2 \[Pi]}]
Out[7]=
In[8]:=
Plot[{Sin[2 x]/2 + 2, Cos[x]/2 - 1}, {x, 0, 2 \[Pi]}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[8]=

With multiple enclosed regions, the integrand will use Abs to return a positive area:

In[9]:=
ResourceFunction[
 "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{x/2, x^2}, {x, -1/2, 1/2}]
Out[9]=
In[10]:=
Plot[{x/2, x^2}, {x, -1/2, 1/2}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[10]=

Between curves containing parameters:

In[11]:=
ResourceFunction[
 "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{a x, x^3}, {x, 0, 1}]
Out[11]=

Options (2) 

Assumptions

The result may be conditioned on parameters:

In[12]:=
ResourceFunction[
 "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Sqrt[a x^2], x}, {x, -1, 1}]
Out[12]=

Make an assumption about the parameter to then evaluate the area:

In[13]:=
area = ResourceFunction[
  "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Sqrt[a x^2], x}, {x, -1, 1}, Assumptions -> a > 1]
Out[13]=
In[14]:=
Activate[area]
Out[14]=

Applications (2) 

Compute the area of a disk:

In[15]:=
area = ResourceFunction[
  "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{Sqrt[1 - x^2], -Sqrt[1 - x^2]}, {x, -1, 1}]
Out[15]=
In[16]:=
Activate[area]
Out[16]=
In[17]:=
Plot[{Sqrt[1 - x^2], -Sqrt[1 - x^2]}, {x, -1, 1}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[17]=

Cavalieri's principle states that the area between two curves does not change when each curve is shifted by the same amount:

In[18]:=
f = 1 - x^2;
g = x^2 - 1;
In[19]:=
h = Sin[(x - 5)^2];
In[20]:=
ResourceFunction[
 "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{f, g}, {x, -1, 1}]
Out[20]=
In[21]:=
ResourceFunction[
 "AreaBetweenCurvesIntegral", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][{f - h, g - h}, {x, -1, 1}]
Out[21]=
In[22]:=
Plot[{f - #, g - #}, {x, -1, 1}, Filling -> {1 -> {2}}] & /@ {0, h}
Out[22]=

Properties and Relations (1) 

Use resource function AreaBetweenCurves to compute the area directly:

In[23]:=
ResourceFunction["AreaBetweenCurves"][{Sin[x], Cos[x]}, {x, 0, Pi}]
Out[23]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 2.0.0 – 23 March 2023
  • 1.0.0 – 11 May 2020

Related Resources

Author Notes

To view underlying source code, evaluate the following:

In[1]:=
SystemOpen[
 FileNameJoin[
  ReplacePart[
   FileNameSplit[FindFile["ResourceFunctionHelpers`"]], -1 -> "AreaBetweenCurves.wl"]]]

License Information