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\).
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:
We then rearrange to give \(C\).
We now substitute the value of \(C\) into the equation from before to find our answer:
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
Then we use that \(y=2\) to create the equation with 2 unknowns, \(x\), and \(C\).
y_equals = Eq(integral, 2)
y_equals
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})