Even and Odd Functions
Some functions are mirror images of themselves, and that symmetry can make an integral half the work, or no work at all. This lesson shows how to recognise even and odd functions and how to use them on symmetric intervals like .
Definitions
| Type | Rule | Graph | Examples |
|---|---|---|---|
| Even | mirror symmetric about the y-axis | , , , , | |
| Odd | symmetric under a half-turn about the origin | , , , , | |
| Neither | none of the above | , , |
For polynomials the names fit: only even powers means even, only odd powers means odd. A constant term counts as an even power ().
Products follow sign-like rules, with even as and odd as :
So () is even, and () is odd.
The integration shortcuts
On an interval symmetric around 0:
For an odd function the area on the left is the same size as the area on the right but has the opposite sign, so they cancel. For an even function both halves are equal, so compute one and double it.
import sympy as sp
x = sp.symbols("x")
def kind(f):
if sp.simplify(f.subs(x, -x) - f) == 0:
return "even"
if sp.simplify(f.subs(x, -x) + f) == 0:
return "odd"
return "neither"
for f in [x**4 - 3 * x**2, x**3 * sp.cos(x), x * sp.sin(x), sp.exp(x)]:
print(f"{str(f):16} {kind(f):8}")
print(sp.integrate(x**4 - 3 * x**2, (x, -2, 2)), "=", 2 * sp.integrate(x**4 - 3 * x**2, (x, 0, 2)))
print(sp.integrate(x**3 * sp.cos(x), (x, -sp.pi, sp.pi)))x**4 - 3*x**2 even
x**3*cos(x) odd
x*sin(x) even
exp(x) neither
-16/5 = -16/5
0
Note: The shortcuts only work on intervals symmetric about zero. , not 0.
Every function splits into even + odd
Any function can be written as an even part plus an odd part:
For these are and . On only the even part contributes to the integral.
import sympy as sp
x = sp.symbols("x")
f = sp.exp(x)
even = (f + f.subs(x, -x)) / 2
odd = (f - f.subs(x, -x)) / 2
print("even part = cosh x ?", sp.simplify(even - sp.cosh(x)) == 0)
print("odd part = sinh x ?", sp.simplify(odd - sp.sinh(x)) == 0)
print("∫_-1^1 e^x dx =", sp.integrate(f, (x, -1, 1)))
print("2∫_0^1 cosh x dx =", sp.simplify(2 * sp.integrate(sp.cosh(x), (x, 0, 1))).rewrite(sp.exp))even part = cosh x ? True
odd part = sinh x ? True
∫_-1^1 e^x dx = E - exp(-1)
2∫_0^1 cosh x dx = E - exp(-1)
SymPy prints E for the number , so both lines say .
In software
- Fourier analysis and audio: a signal splits into cosine (even) and sine (odd) parts. Many of the integrals that compute Fourier coefficients vanish by symmetry, for example for all whole numbers , because the integrand is odd. This is why sine and cosine components can be measured separately.
- Statistics: the standard normal density is even, so its mean is zero (odd integrand) and .
- Numerical code: integrating an even function over with half the samples on halves the cost. For an odd function, a numerical result that is not tiny reveals a bug or rounding error.
- Graphics: mirror-symmetric meshes and kernels (blur filters are even) let code store and compute only half.
import numpy as np
from scipy.integrate import quad
odd = lambda x: x**3 * np.cos(x)
val, err = quad(odd, -np.pi, np.pi)
print(f"numerical ∫ odd = {val:.1e}")
m, n = 3, 5
val, _ = quad(lambda x: np.sin(m * x) * np.cos(n * x), -np.pi, np.pi)
print(f"∫ sin(3x)cos(5x) = {abs(val):.1e}")numerical ∫ odd = 0.0e+00
∫ sin(3x)cos(5x) = 0.0e+00
Exercises
Exercise 1: Classify
Is each function even, odd, or neither? a) , b) , c) , d) .
Answer
a) odd, b) even, c) neither, d) even.
Solution
Exercise 2: Zero without integrating
Evaluate .
Answer
0
Solution
Every term is an odd power, so the integrand is odd and the interval is symmetric. The integral is 0.
Exercise 3: Mixed integrand
Evaluate .
Answer
2
Solution
Exercise 4: A numerical symmetry checker
Write symmetry(f) that samples points x in [0.1, 3] and returns "even", "odd" or "neither" (using a tolerance of 1e-12). Test it on cos, tan and exp.
Answer
cos even, tan odd, exp neither
Solution
import math
def symmetry(f, tol=1e-12):
xs = [0.1 + 0.29 * i for i in range(11)]
if all(abs(f(-x) - f(x)) < tol for x in xs):
return "even"
if all(abs(f(-x) + f(x)) < tol for x in xs):
return "odd"
return "neither"
for f in [math.cos, math.tan, math.exp]:
print(f.__name__, symmetry(f))cos even
tan odd
exp neither
A sampled check can only disprove symmetry for sure; passing it is strong evidence, not a proof.
Test yourself
What is ?
- 0
- It cannot be computed
Which function is even?
If is even and , what is ?
- 0
- 7
- 3.5
- 14