If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

### Course: Multivariable calculus>Unit 4

Lesson 2: Line integrals for scalar functions (articles)

# Line integrals in a scalar field

Learn how to compute and interpret line integrals, also known as path integrals or curve integrals.

## What we're building to

• In the same way that an ordinary integral ${\int }_{a}^{b}f\left(x\right)dx$ has you walking along the $x$ axis and adding up certain tiny quantities as you go, a line integral ${\int }_{C}f\left(x,y\right)ds$ has you walking on a curve the $xy$-plane, adding up certain quantities depending on the multivariable function $f\left(x,y\right)$.
• If a curve $C$ is parameterized by a vector value function $\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)$ between the values $t=a$ and $t=b$, the line integral is written as follows:
$\begin{array}{r}{\int }_{C}f\phantom{\rule{0.167em}{0ex}}ds={\int }_{a}^{b}f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)\phantom{\rule{0.167em}{0ex}}|{\stackrel{\to }{\mathbf{\text{r}}}}^{\prime }\left(t\right)|dt\end{array}$
• In this case, $f$ is a scalar valued function, so we call this process "line integration in a scalar field", to distinguish from a related idea we'll cover next: line integration in a vector field.

## What is a line integral

In the last article, I introduced some compact notation for an arc length integral:
$\begin{array}{r}{\int }_{C}ds\end{array}$
• The term $ds$ represents a tiny change in length along the curve.
• $C$ is just a name we give to the curve. Putting it at the base of the integral, like this ${\int }_{C}$, is a way to postpone the need to place actual bounds on the integral.
Line integrals extend this idea by placing a multivariable function inside the integral,
$\begin{array}{r}{\int }_{C}f\left(x,y\right)ds\end{array}$
You can think of this integral as saying
"Hey, while you're walking along the curve taking tiny steps of size $ds$, rather than just adding up the sizes of those steps, multiply each step size by the value of the function $f\left(x,y\right)$ at the point where you are standing."
The following animation relates this to the more familiar idea of finding the area under a curve. Imagine a curtain draped under the three-dimensional graph of $f\left(x,y\right)$ along the curve $C$ in the $xy$-plane. The line integral gives the area of that curtain. (The initial image is a colored contour plot of the function $f$).
You imagine the area of that curtain being broken up into infinitely many infinitely thin rectangles. The infinitesimal base of each rectangle is $ds=|{\mathbf{\text{r}}}^{\prime }\left(t\right)|$, the size of a tiny step along the curve. The height of each rectangle is $f\left(x,y\right)$, the height of the graph of $f$ at that point.

## Vector notation for line integrals

At the end of the animation above, the line integral is written like this:
$\begin{array}{r}{\int }_{C}f\phantom{\rule{0.167em}{0ex}}ds={\int }_{a}^{b}f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)\phantom{\rule{0.167em}{0ex}}|{\stackrel{\to }{\mathbf{\text{r}}}}^{\prime }\left(t\right)|dt\end{array}$
Let's break down what each part of this means.

### The parameterization of $C$‍

$\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)$ is some vector-valued function which parameterizes the curve $C$. In two dimensions, it might look something like this:
$\begin{array}{rl}\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)& =\left[\begin{array}{c}x\left(t\right)\\ \\ y\left(t\right)\end{array}\right]\end{array}$
The bounds of the integral, $a$ and $b$, are values for $t$ which determine where the curve starts and ends.
Essentially this means that as the value of $t$ ranges between $a$ and $b$, the tip of the vector $\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)$ traces over the curve $C$.

### Composing $f$‍  with the parameterization

Evaluating $f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)$ means taking the components $x\left(t\right)$ and $y\left(t\right)$ of $\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)$, and plugging them in as the inputs of $f\left(x,y\right)$:
$f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)=f\left(x\left(t\right),y\left(t\right)\right)$
You can think of it this way: A given value of $t$ puts us at some point on the $xy$-plane, expressed as the tip of the vector $\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)$. Then $f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)$ gives the value of the function $f$ at that point on the plane.

### $ds$‍  is the magnitude of the derivative (times $dt$‍ )

The term $ds$, representing a tiny step along the curve, is expanded as $|{\stackrel{\to }{\mathbf{\text{r}}}}^{\prime }\left(t\right)|dt$, the magnitude of the derivative of $\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)$ times $dt$.
Intuitively, this is because the derivative answers the question "what happens if you nudge the input slightly by a value $dt$?" The answer is that the output gets nudged along the vector ${\stackrel{\to }{\mathbf{\text{r}}}}^{\prime }\left(t\right)dt$ in the $xy$-plane. The magnitude of this nudge in the output space gives you the size of a step $ds$ along the curve, as a function of the size of the step in the parameter space $dt$.
You can also see this as the compact vector-notation way of saying $\sqrt{d{x}^{2}+d{y}^{2}}$:
$\begin{array}{rl}|{\stackrel{\to }{\mathbf{\text{r}}}}^{\prime }\left(t\right)|dt& =|\left[\begin{array}{c}{x}^{\prime }\left(t\right)\\ \\ {y}^{\prime }\left(t\right)\end{array}\right]|dt\\ \\ & =\sqrt{\left({x}^{\prime }\left(t\right){\right)}^{2}+\left({y}^{\prime }\left(t\right){\right)}^{2}}dt\\ \\ & =\sqrt{\left({x}^{\prime }\left(t\right){\right)}^{2}d{t}^{2}+\left({y}^{\prime }\left(t\right){\right)}^{2}d{t}^{2}}\\ \\ & =\sqrt{\left({x}^{\prime }\left(t\right)dt{\right)}^{2}+\left({y}^{\prime }\left(t\right)dt{\right)}^{2}}\\ \\ & =\sqrt{\left(dx{\right)}^{2}+\left(dy{\right)}^{2}}\end{array}$
Putting all this together, we get the vector representation of a line integral:
$\begin{array}{r}{\int }_{C}f\phantom{\rule{0.167em}{0ex}}ds={\int }_{a}^{b}f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)\phantom{\rule{0.167em}{0ex}}|{\stackrel{\to }{\mathbf{\text{r}}}}^{\prime }\left(t\right)|dt\end{array}$

## Example 1: Compute a simple line integral

Let $C$ be one quarter of a circle with radius $2$ centered at the origin. The quarter in the first quadrant to be specific.
We can describe this quarter circle parametrically with the following function:
$\begin{array}{rl}\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)& =\left[\begin{array}{c}2\mathrm{cos}\left(t\right)\\ \\ 2\mathrm{sin}\left(t\right)\end{array}\right]\end{array}$
If we let $t$ range from $0$ to $\pi /2$, this traces around $C$.
Now defined the multivariable function $f$ as
$f\left(x,y\right)=x+y$
Our goal is to compute the line integral
$\begin{array}{r}{\int }_{C}f\left(x,y\right)ds\end{array}$
The following video shows what the "curtain" beneath the graph of $f$ along the curve $C$ looks like. The translucent white plane is the graph of $f\left(x,y\right)=x+y$, and the blue surface is the curtain whose area we are computing.

### Step 1: Write $ds$‍  in terms of $dt$‍

Given that the size of a tiny step $ds$ along the curve is given by the magnitude of the derivative of $\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)$ times $dt$,
$ds=|{\stackrel{\to }{\mathbf{\text{r}}}}^{\prime }\left(t\right)|dt$
solve for $ds$ in our example.
For reference, the parameterization of our curve is $\begin{array}{rl}\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)& =\left[\begin{array}{c}2\mathrm{cos}\left(t\right)\\ 2\mathrm{sin}\left(t\right)\end{array}\right]\end{array}$
$ds=$
$dt$

### Step 2: Write $f\left(x,y\right)$‍  in terms of $t$‍

What is $f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)$ in this case?
$f\left(\stackrel{\to }{\mathbf{\text{r}}}\left(t\right)\right)=$

### Step 3: Write the integral completely in terms of $t$‍  and solve

From the previous two steps, our integral becomes
$\begin{array}{r}{\int }_{C}f\left(x,y\right)ds={\int }_{C}\left(2\mathrm{cos}\left(t\right)+2\mathrm{sin}\left(t\right)\right)\phantom{\rule{0.278em}{0ex}}2dt\end{array}$
Since our parameterization of $C$ has $t$ running from $0$ to $\frac{\pi }{2}$, these are the bounds of the integral. Now solve the integral.
$\begin{array}{r}{\int }_{0}^{\pi /2}\left(2\mathrm{cos}\left(t\right)+2\mathrm{sin}\left(t\right)\right)\phantom{\rule{0.278em}{0ex}}2dt\end{array}=$

## Example 2: More intricate practice

In principle, line integration is not too bad once you get the hang of it. You just have to know how to expand the term $ds$, and to rewrite the inputs of the function $f\left(x,y\right)$ in terms of the parameterization. Knowing how to set this up just takes a little practice, which is what we're doing here.
That said, line integrals can be a real pain to actually compute. Most of them end up in a state where you need to plug the integral into a computer to get an answer, but even when the integral is solvable the numbers involved can quickly grow cumbersome.
The following example​ shows how even for relatively simple functions, computing a line integral to its completion can be a very involved problem. You will definitely want to have a pencil and scratch paper ready if you choose to go through this example.
Let $C$ be the curve defined by the function
$\begin{array}{r}\stackrel{\to }{\mathbf{\text{s}}}\left(t\right)=\left[\begin{array}{c}\frac{1}{t}+\frac{1}{5}{t}^{5}\\ \\ {t}^{2}\end{array}\right]\end{array}$
on the interval $1\le t\le 2$.
Let $f$ be the function
$f\left(x,y\right)=x{y}^{2}$
Compute the line integral
$\begin{array}{r}{\int }_{C}f\left(x,y\right)ds\end{array}$

### Step 1: Write $ds$‍  in terms of $dt$‍

$ds=$
$dt$

### Step 2: Replace $f\left(x,y\right)$‍  with $f\left(\stackrel{\to }{\mathbf{\text{s}}}\left(t\right)\right)$‍

What do you get when you plug the components of $\stackrel{\to }{\mathbf{\text{s}}}\left(t\right)$ into $f\left(x,y\right)=x{y}^{2}$?
$f\left(\stackrel{\to }{\mathbf{\text{s}}}\left(t\right)\right)=$

### Step 3: Solve the integral

Plug the answers from the previous two steps into the integral, then solve. Since the curve is defined for $1\le t\le 2$, and our integral is now given with respect to $t$, the bounds of the integral are $1$ and $2$.
(Warning, this gets super ugly to compute, so feel free to put it in a calculator when the time comes.)
$\begin{array}{r}{\int }_{1}^{2}f\left(\stackrel{\to }{\mathbf{\text{s}}}\left(t\right)\right)\phantom{\rule{0.167em}{0ex}}|{\stackrel{\to }{\mathbf{\text{s}}}}^{\prime }\left(t\right)|dt\end{array}=$

Notice, the hard part of this problem is not the new principles of line integration, knowing how to expand $ds$ and all that. What makes it hard is that the complexity of the terms involved quickly blows up.
(Also, if you think this is bad, just wait until we get to surface integrals.)

## Line integrals in a scalar field

In everything written above, the function $f$ is a scalar-valued function, meaning it outputs a number (as opposed to a vector). There is a slight variation on line integrals, where you can integrate a vector-valued function along a curve, which we will cover in the next article.
To distinguish these ideas, everything we just covered is typically called line integration in a scalar field and the alternative is referred to as line integration in a vector field. The term "scalar field" is just another way of thinking about what a multivariable function does: It associates each point in the $xy$-plane with some scalar (i.e. number), so that the entire plane is like a field of numbers just waiting for someone to wander along a path through that field and integrate those values.

## Want to join the conversation?

• The infinitesimal base of each rectangle is ds = |r'(t)|, the size of a tiny step along the curve

Should be ds = |r'(t)|dt ?
• The "ds is the magnitude of the derivative (times dt)" paragraf ends with a little "proof" if you will. This proof ends with sqrt( dx²+ dx²), shouldn't it be sqrt( dx²+ dy²)dt ?
• The article is right, in the 4th-row, you can rewrite as sqrt((dx/dt*dt)^2+(dy/dt*dt)^2)=sqrt(dx^2+dy^2), so it is absolutely not a typo.
• In the Step 1 answer, you've taken the derivative of (1/t) as (-1/t^2), but shouldn't it be ln | t | ?.
(1 vote)
• Integral of 1/t is ln |t| but derivative of 1/t is (-1/t^2).
• Is there any way to do these integrals faster, perhaps a pattern to look for of some sort? What about numerical integration? Thanks!
(1 vote)
• There is no perfect pattern matching scheme, there are always exceptions. But, with time and (lots of) practice you will generate your own "pattern" intuition.

Numerical integration (unless you have already written or purchased the software) is way slower. Developing fast and accurate programs takes a bit of time. Doing numerical integration by hand is way slower (and more boring IMHO) than the method being described in this video.