Properties of the Indefinite Integral
A few simple rules let you break a complicated integral into pieces you already know. This lesson covers those rules, the ones that look natural but are false, and how integration and differentiation undo each other.
Linearity: the two rules you use all the time
The indefinite integral is linear. Constants come out, and sums split:
Both follow from the matching derivative rules: and . Together they mean any polynomial can be integrated term by term:
Only one is needed at the end: the constants of all the pieces add up to a single unknown constant.
Integration and differentiation undo each other
| Rule | In words |
|---|---|
| differentiate an antiderivative and you get the function back exactly | |
| integrate a derivative and you get the function back, up to a constant |
The asymmetry is the : differentiating throws a constant away, so integrating cannot know which one to restore.
import sympy as sp
x = sp.symbols("x")
f = 5 * x**4 - 2 * x**2 + 7
F = sp.integrate(f, x)
print("∫ f dx =", F)
print("d/dx ∫ f dx =", sp.diff(F, x))
g = sp.exp(2 * x) + x**3
print("∫ g' dx =", sp.integrate(sp.diff(g, x), x), " (g =", g, ")")∫ f dx = x**5 - 2*x**3/3 + 7*x
d/dx ∫ f dx = 5*x**4 - 2*x**2 + 7
∫ g' dx = x**3 + exp(2*x) (g = x**3 + exp(2*x) )
SymPy prints x**5 for and exp(2*x) for ; that is just its text format.
What does NOT work
The derivative has a product rule and a quotient rule. The integral has no simple product or quotient rule:
A quick counterexample: , but . Products need other tools, like substitution and integration by parts.
import sympy as sp
x = sp.symbols("x")
f, g = x, sp.cos(x)
right = sp.integrate(f * g, x)
wrong = sp.integrate(f, x) * sp.integrate(g, x)
print("∫ x·cos x dx =", right)
print("(∫ x dx)(∫ cos x dx) =", wrong)
print("difference is zero? ", sp.simplify(right - wrong) == 0)∫ x·cos x dx = x*sin(x) + cos(x)
(∫ x dx)(∫ cos x dx) = x**2*sin(x)/2
difference is zero? False
Tip: When you are unsure whether a manipulation is legal, differentiate your answer. If you do not get the integrand back, the step was wrong.
In software
Linearity is what makes integration easy for computers when a function is stored as a list of coefficients. NumPy's polynomial tools integrate term by term: coefficient of becomes of , and you pass the constant of integration explicitly.
import numpy as np
# 5x^4 - 2x^2 + 7, highest power first
coeffs = np.array([5, 0, -2, 0, 7])
anti = np.polyint(coeffs, k=3) # k is the constant C
print("antiderivative coefficients:", np.round(anti, 4))
print("derivative of it again :", np.polyder(anti))
# the same thing by hand, lowest power first
c = [7, 0, -2, 0, 5]
by_hand = [3] + [ci / (n + 1) for n, ci in enumerate(c)]
print("by hand (lowest power first):", [round(v, 4) for v in by_hand])antiderivative coefficients: [ 1. 0. -0.6667 0. 7. 3. ]
derivative of it again : [ 5. 0. -2. 0. 7.]
by hand (lowest power first): [3, 7.0, 0.0, -0.6667, 0.0, 1.0]
Linearity also explains why an expected value in statistics splits, : an expected value is an integral, so it inherits the same two rules. In code that processes signals, it is why you can integrate (sum) each component of a mixed signal separately and add the results.
Exercises
Exercise 1: Term by term
Find for .
Answer
Solution
Exercise 2: Expand first
Find by expanding, then compare it with . Do they differ?
Answer
. It differs from only by the constant , so both are correct.
Solution
Exercise 3: Spot the false step
A student writes . Show by differentiating that this is wrong.
Answer
The derivative is , not , so the answer is wrong (there is no product rule for integrals).
Solution
The correct result, found later with integration by parts, is .
Exercise 4: Polynomial antiderivative in code
Write a function polyint(c, C) that takes coefficients lowest power first and returns the antiderivative's coefficients. Test it on with .
Answer
[1, 3.0, 1.0, 2.0], i.e. .
Solution
def polyint(c, C=0):
return [C] + [ci / (n + 1) for n, ci in enumerate(c)]
print(polyint([3, 2, 6], C=1))[1, 3.0, 1.0, 2.0]
Test yourself
Which equation is always true?
What is ?
What is ?