Finding the Constant of Integration

Finding the Constant of Integration#

In the integrals so far, we have always had a constant of integration denoted \(+C\) at the end. Consider the functions, \(y=x^2\), \(y=x^2+2\), and \(y=x^2+5\), as shown on the graph below. These all differentiate to \(2x\). So when integrating \(2x\), we don’t know whether the actual answer is \(y=x^2\), \(y=x^2+2\), or \(y=x^2+5\), so we give the general answer of \(y=x^2+C\).

Hide code cell source

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 1000)

fig, ax = plt.subplots()
ax.plot(x, x**2, label='$y=x^2$')
ax.plot(x, x**2 + 2, label='$y=x^2+2$')
ax.plot(x, x**2 + 5, label='$y=x^2+5$')
ax.legend()

plt.show()
../_images/950214692e5c5e529be0c95bf4d75d6dae887872a96ebece53777c383cb3dac1.png

If we are given the gradient of a curve and a point that the curve goes through, we can find the full equation of the curve and therefore, a value for \(C\).

Example

A curve of gradient \(4x^5\) passes through the point (1, 2). What is the full equation of the line?

Solution: We know the gradient is \(4x^5\), meaning \(\frac{dy}{dx}=4x^5\).

  • Hence we have: $y=\int 4x^5;dx

  • Now we can integrate: $y=\frac{4}{6}x^6 + C

  • And simplify the fraction: \(y=\frac{2}{3}x^6 + C\)

We now have an expression for \(y\) in terms of \(x\), however, it has a constant \(C\) in it. Since we know a point (1, 2) that the curve passes through, we can find this constant. So when \(x=1\), we have \(y=2\), substituting this into the equation gives:

\[ 2 = \frac{2}{3} \times 1^6 + C \]

We then rearrange to give \(C\).

\[ C = \frac{4}{3} \]

We now substitute the value of \(C\) into the equation from before to find our answer:

\[ y = \frac{2}{3}x^6 + \frac{4}{3} \]

To perform this in Python, using sympy, first we find the integral of \(4x^5\) and add the constant \(C\).

from sympy import symbols, integrate, solve, Eq

x, C = symbols('x C')

integral = integrate(4 * x**5) + C
integral
\[\displaystyle C + \frac{2 x^{6}}{3}\]

Then we use that \(y=2\) to create the equation with 2 unknowns, \(x\), and \(C\).

y_equals = Eq(integral, 2)
y_equals
\[\displaystyle C + \frac{2 x^{6}}{3} = 2\]

Finally, we rearrange the equation to make \(C\) the subject, and evaluate it for \(x=1\).

solve(y_equals, C)[0].evalf(subs={x: 1})
\[\displaystyle 1.33333333333333\]