All concepts

17. Functions and custom symbols

Substitute carefully into custom operators. Composite functions resolve inside-out.

f(g(3)): work inside out3gg(3)=5ff(5)inner machine first, its output feeds the outer one

Core ideas

- A custom symbol is just a recipe: replace each slot with its input, using parentheses around every substituted expression.
- Composites resolve inside-out: for f(g(x)), compute g first, then feed the result to f.
- f(a + b) is almost never f(a) + f(b); compute, never assume nice behavior.
- If the definition has two slots, order matters: a # b and b # a can differ.

Worked example 1

If f(x) = x^2 - 3x, what is f(f(2))?

Show solution

Inside-out. First f(2) = 2^2 - 3(2) = 4 - 6 = -2. Then f(-2) = (-2)^2 - 3(-2) = 4 + 6 = 10. So f(f(2)) = 10. The common trap is squaring -2 to get -4; parentheses around the substituted value prevent that.

Worked example 2

Define a # b = a*b + a + b. What is 2 # (3 # 1)?

Show solution

Resolve the inner symbol first: 3 # 1 = 3*1 + 3 + 1 = 7. Then 2 # 7 = 2*7 + 2 + 7 = 14 + 9 = 23. So 2 # (3 # 1) = 23. Each application is pure substitution into the recipe, one layer at a time.

Practice set

Question 1

The function h is defined as follows: h(n) = n/2 if n is even, and h(n) = 3n + 1 if n is odd. What is the value of h(h(h(5)))?






Question 2

If f(x) = 2x + 1 and g(x) = x^2 for all numbers x, what is the value of f(g(3))?






Question 3

For all numbers a and b with a not equal to b, the operation ◊ is defined by a ◊ b = (a + b)/(a - b). What is the value of (5 ◊ 3) ◊ 2?






Question 4

For all numbers a and b, a # b = a^2 - b. What is the value of 5 # 3?