Int 3 for Programmers

Functions, transformations, composition and inverses

12 / 396
Contents

Contents

Int 3 for Programmers

0 of 396 complete

8 min read

Symmetry, and how to test for it

Even and odd functions, seen on the graph and proved from the equation.

Some graphs look the same in a mirror placed on the vertical axis. Others look the same after being turned upside down through the origin. Both kinds of symmetry can be checked without drawing anything, by comparing what the rule does to an input and to its negative.

Run this and read the two output columns against each other.

Try CodePython

Change the rule to x * x * x and run it again, then to x * x + x. Three rules, three different relationships between the columns.

For x2x^2 the two columns are identical. For x3x^3 each entry in the second column is the negative of the first. For x2+xx^2 + x there is no relationship at all: 6 against 2, 12 against 6.

Those three cases have names. A function is even if f(−x)=f(x)f(-x) = f(x) for every input. A function is odd if f(−x)=−f(x)f(-x) = -f(x) for every input. A function with neither property is neither, which is the commonest case.

even: f(−x)=f(x)odd: f(−x)=−f(x)\text{even: } f(-x) = f(x) \qquad\qquad \text{odd: } f(-x) = -f(x)
Both must hold for every input in the domain, not merely for the one you tried.

On a graph, even means symmetric about the vertical axis: fold the paper along that axis and the halves match. Odd means symmetric about the origin: turn the paper half a turn about the origin and the graph lands on itself.

Both symmetries can be checked one point at a time. If (2,5)(2, 5) is on the graph of an even function, then (−2,5)(-2, 5) is on it too: same height, opposite side. If it is on the graph of an odd function, then (−2,−5)(-2, -5) is on it instead: opposite side and opposite height. An odd function whose domain includes 0 must pass through the origin, because f(0)=−f(0)f(0) = -f(0) forces f(0)f(0) to be 0.

Most functions are neither, and saying so is a complete answer rather than a failure to find something. Shifting a graph left or right destroys both properties, and so does adding a constant to an odd function.

The words are not describing whether the powers are even or odd numbers, but for a rule made only of powers of xx that happens to line up, which is where the names came from. x2x^2, x4x^4 and ∣x∣|x| are even. xx, x3x^3 and x5x^5 are odd. Mixing an even power with an odd one, as in x2+xx^2 + x, usually destroys both properties.

Testing without a graph

A sample of inputs can only ever suggest an answer, so an exam wants the algebra. The method is to substitute −x-x into the rule and simplify, then compare the result with f(x)f(x) and with −f(x)-f(x). Let the machine do the sampling first so you know what you are aiming to prove.

Try CodePython

Add a line testing lambda x: 5 and predict the answer before running it. A flat line is symmetric about the vertical axis.

One worked example in full. Decide whether f(x)=x3−4xf(x) = x^3 - 4x is even, odd or neither.

  1. Substitute −x-x everywhere: f(−x)=(−x)3−4(−x)f(-x) = (-x)^3 - 4(-x).
  2. Simplify each term: (−x)3=−x3(-x)^3 = -x^3, and −4(−x)=+4x-4(-x) = +4x.
  3. So f(−x)=−x3+4xf(-x) = -x^3 + 4x.
  4. Compare with f(x)=x3−4xf(x) = x^3 - 4x. They are not equal, so it is not even.
  5. Compare with −f(x)=−(x3−4x)=−x3+4x-f(x) = -(x^3 - 4x) = -x^3 + 4x. That is exactly what f(−x)f(-x) came to.
  6. So the function is odd.
ff is odd and f(3)=−7f(3) = -7. What is f(−3)f(-3)?

7. Odd means f(−x)=−f(x)f(-x) = -f(x), so f(−3)=−f(3)=−(−7)=7f(-3) = -f(3) = -(-7) = 7. If ff had been even instead, the answer would have been -7, the same value again.

Check yourself

Which of these is even?

Classify f(x)=x4−2x2f(x) = x^4 - 2x^2 as even, odd or neither, showing the substitution.

Even. Substituting: f(−x)=(−x)4−2(−x)2f(-x) = (-x)^4 - 2(-x)^2. Now (−x)4=x4(-x)^4 = x^4, because four minus signs multiply to a plus, and (−x)2=x2(-x)^2 = x^2 for the same reason with two. So f(−x)=x4−2x2f(-x) = x^4 - 2x^2, which is exactly f(x)f(x), and the even test is satisfied.

Classify f(x)=x2+xf(x) = x^2 + x as even, odd or neither, showing the substitution.

Neither. Substituting: f(−x)=(−x)2+(−x)=x2−xf(-x) = (-x)^2 + (-x) = x^2 - x. Compare with f(x)=x2+xf(x) = x^2 + x: not equal, so not even. Compare with −f(x)=−x2−x-f(x) = -x^2 - x: not equal either, so not odd. One term kept its sign and the other flipped, and that mixture is what leaves a function in the neither box.

Check yourself

Which of these is odd?

Check yourself

f(x)=(x−2)2f(x) = (x - 2)^2. Which description is right?

All lessons in Int 3 for Programmers