Function Repository Resource:

AreaBetweenCurves

Source Notebook

Find the area between two plane curves

Contributed by: Wolfram|Alpha Math Team

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

finds the area of the enclosed region between the functions f(x) and g(x) over the interval xmin < x < xmax.

Details

ResourceFunction["AreaBetweenCurves"] 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 (1) 

Find the area between two curves:

In[1]:=
ResourceFunction["AreaBetweenCurves"][{x, x^2}, {x, 0, 1}]
Out[1]=
In[2]:=
Plot[{x, x^2}, {x, 0, 1}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[2]=

Scope (4) 

Find the area of the region enclosed by two curves:

In[3]:=
ResourceFunction["AreaBetweenCurves"][{x^2 - 1, 1 - x^2}, {x, -1, 1}]
Out[3]=
In[4]:=
Plot[{x^2 - 1, 1 - x^2}, {x, -1, 1}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[4]=

Where the curves do not meet:

In[5]:=
ResourceFunction[
 "AreaBetweenCurves"][{Sin[2 x]/2 + 2, Cos[x]/2 - 1}, {x, 0, 2 \[Pi]}]
Out[5]=
In[6]:=
Plot[{Sin[2 x]/2 + 2, Cos[x]/2 - 1}, {x, 0, 2 \[Pi]}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[6]=

With multiple enclosed regions:

In[7]:=
ResourceFunction["AreaBetweenCurves"][{x/2, x^2}, {x, -1/2, 1/2}]
Out[7]=
In[8]:=
Plot[{x/2, x^2}, {x, -1/2, 1/2}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[8]=

Between curves containing parameters:

In[9]:=
ResourceFunction["AreaBetweenCurves"][{a x, x^3}, {x, 0, 1}]
Out[9]=

Generalizations and Extensions (3) 

Find the area over an unbounded interval:

In[10]:=
ResourceFunction[
 "AreaBetweenCurves"][{1/(x^2 + 2 x + 2), -1/(x + 2)^2}, {x, 1, \[Infinity]}]
Out[10]=
In[11]:=
Plot[{1/(x^2 + 2 x + 2), -1/(x + 2)^2}, {x, 1, 6}, Filling -> {1 -> {2}}]
Out[11]=

Curves with discontinuities over intervals:

In[12]:=
ResourceFunction[
 "AreaBetweenCurves"][{ArcCot[x]/2, Sin[4 x]/4}, {x, -1, 1}]
Out[12]=
In[13]:=
Plot[{ArcCot[x]/2, Sin[4 x]/4}, {x, -1, 1}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[13]=

With singularities:

In[14]:=
ResourceFunction["AreaBetweenCurves"][{1/Sqrt[Abs[x]], x}, {x, -1, 1}]
Out[14]=
In[15]:=
Plot[{1/Sqrt[Abs[x]], x^2}, {x, -1, 1}, Filling -> {1 -> {2}}]
Out[15]=

Options (2) 

Assumptions

The result may be conditioned on parameters:

In[16]:=
ResourceFunction["AreaBetweenCurves"][{Sqrt[a x^2], x}, {x, -1, 1}]
Out[16]=

Make an assumption about the parameter:

In[17]:=
ResourceFunction["AreaBetweenCurves"][{Sqrt[a x^2], x}, {x, -1, 1}, Assumptions -> a > 1]
Out[17]=

Applications (3) 

Compute the area of a disk:

In[18]:=
ResourceFunction[
 "AreaBetweenCurves"][{Sqrt[1 - x^2], -Sqrt[1 - x^2]}, {x, -1, 1}]
Out[18]=
In[19]:=
Plot[{Sqrt[1 - x^2], -Sqrt[1 - x^2]}, {x, -1, 1}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[19]=

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

In[20]:=
f = 1 - x^2;
g = x^2 - 1;
In[21]:=
h = Sin[(x - 5)^2];
In[22]:=
ResourceFunction["AreaBetweenCurves"][{f, g}, {x, -1, 1}]
Out[22]=
In[23]:=
ResourceFunction["AreaBetweenCurves"][{f - h, g - h}, {x, -1, 1}]
Out[23]=
In[24]:=
Plot[{f - #, g - #}, {x, -1, 1}, Filling -> {1 -> {2}}] & /@ {0, h}
Out[24]=

The population of a region is currently growing at a rate of 35.208 ⅇ0.0083 t hundred people per year. It is thought that a large spike in employment opportunities can drop the growth rate to 24.098 ⅇ0.0071 t hundred people per year over the next five years. Find how many fewer people will be born if such a spike occurs:

In[25]:=
100 ResourceFunction[
  "AreaBetweenCurves"][{35.208 Exp[0.0083 t], 24.098 Exp[0.0071 t]}, {t, 0, 5}]
Out[25]=

Properties and Relations (5) 

Area is always non-negative:

In[26]:=
ResourceFunction["AreaBetweenCurves"][{0, x}, {x, -1, 1}]
Out[26]=

The order in which the curves are specified does not matter:

In[27]:=
ResourceFunction["AreaBetweenCurves"][{0, x}, {x, -1, 1}] == ResourceFunction["AreaBetweenCurves"][{x, 0}, {x, -1, 1}]
Out[27]=

Find the area of multiple enclosed regions:

In[28]:=
ResourceFunction[
 "AreaBetweenCurves"][{Sin[x], Cos[x]}, {x, \[Pi]/4, 5 \[Pi]/4}]
Out[28]=

Sum over each enclosed region instead:

In[29]:=
ResourceFunction[
  "AreaBetweenCurves"][{Sin[x], Cos[x]}, {x, \[Pi]/4, 3 \[Pi]/4}] + ResourceFunction[
  "AreaBetweenCurves"][{Sin[x], Cos[x]}, {x, 3 \[Pi]/4, 5 \[Pi]/4}]
Out[29]=
In[30]:=
Plot[{Sin[x], Cos[x]}, {x, \[Pi]/4, 9 \[Pi]/4}, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[30]=

The area between two curves is the integral of the absolute value of their difference:

In[31]:=
ResourceFunction["AreaBetweenCurves"][{x^3, x^4}, {x, -1, 1}]
Out[31]=
In[32]:=
Integrate[Abs[x^4 - x^3], {x, -1, 1}]
Out[32]=

Possible Issues (2) 

The integral defining the area between two curves may not converge:

In[33]:=
funcs = {x^2, 1/x^2};
range = {x, -1, 1};
Plot[funcs, range]
Out[34]=

In such cases, AreaBetweenCurves throws a message:

In[35]:=
ResourceFunction["AreaBetweenCurves"][funcs, range]
Out[35]=

Functions must be real-valued over the entire range of integration. Here is imaginary for x>1:

In[36]:=
funcs = {Sqrt[1 - x^2], 1 - x};
range = {x, 0, 2};
Plot[funcs, range, AspectRatio -> Automatic, Filling -> {1 -> {2}}]
Out[37]=

AreaBetweenCurves throws a message to warn the user:

In[38]:=
ResourceFunction["AreaBetweenCurves"][funcs, range]
Out[38]=

Restricting the domain of integration yields a result:

In[39]:=
ResourceFunction["AreaBetweenCurves"][funcs, {x, 0, 1}]
Out[39]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 5.3.2 – 22 March 2023
  • 5.3.1 – 22 March 2023
  • 5.3.0 – 12 May 2021

Related Resources

License Information