Chapter 1
15 min read
Section 1 of 353

What is a Function? Visualizing Input-Output Relationships

Mathematical Functions - The Building Blocks

Learning Objectives

After this section you will be able to:

  1. State what a function is in plain English, then in precise mathematics, and explain why both definitions agree.
  2. Read the notation y=f(x)y = f(x) and identify the input, the rule, and the output without confusion.
  3. Apply the vertical line test to decide whether any given curve is a function.
  4. Find the domain and range of a function from its formula or its graph.
  5. Translate between three representations: formula, table of values, and graph.
  6. Implement a function in plain Python and in NumPy, and verify the function property in code.

The Problem Functions Were Invented to Solve

How does the position of a thrown ball depend on time? How does the area of a circle depend on its radius? How does my electricity bill depend on the kilowatt-hours I used last month?

Every quantity in science, engineering, economics, and machine learning is tied to other quantities by some rule of dependence. The ball's height depends on time. The circle's area depends on the radius. A neural network's loss depends on its weights. Before we can do calculus on any of these, we need a precise way to write “output depends on input” as mathematics. That precise object is called a function.

Why we cannot skip this

A derivative is the rate at which a function's output changes when its input changes. An integral is the accumulated effect of a function over an interval. Both ideas presume that “the output” is unambiguous for every input. That single requirement — one input, one output — is what makes a relationship a function, and it is the bedrock everything else in this book is built on.


Intuition: The Function Machine

Picture a machine with a single slot on the left for the input and a single chute on the right for the output. Drop a number in the slot; the machine grinds for a moment, then spits exactly one number out the chute. Drop the same number in again and the machine returns the same number — every time, forever, without exception. That is what a function is.

The machine's personality is its rule. One machine might square its input. Another might subtract four, then halve. A third might look up a value in a giant table. We do not care how the machine works internally — only that it is deterministic: same input, same output, always.

Two intuitions, one idea

Mathematicians use four mental pictures interchangeably for the same concept. They all mean exactly the same thing.

  • The machine. Drop in xx, out comes f(x)f(x).
  • The arrow. f:XYf : X \to Y; the arrow says “send each point of XX to a point of YY.”
  • The table. A two-column list of pairs (input, output) with no repeated inputs.
  • The curve. The graph of y=f(x)y = f(x) in the plane, where every vertical line meets the curve in at most one point.

Interactive — The Function Machine

Pick a rule, then drag the slider. The green dot is your input xx sliding along the horizontal axis. The indigo dot rides on the curve, and the amber dot reads off the output y=f(x)y = f(x) on the vertical axis. The green and amber strips show the domain (allowed inputs) and range (reachable outputs).

Loading function-machine visualization…

Things to try

  1. Pick Parabola. Drag xx from -3 to +3. Notice x=2x = -2 and x=+2x = +2 give the same output. Two different inputs can share an output — that is allowed.
  2. Pick Square root. Try to drag below x=0x = 0. The dot turns red and the rule refuses — there is no real 1\sqrt{-1}. The domain has a hard wall.
  3. Pick Reciprocal. Drag toward x=0x = 0. The output blasts off to ±\pm\infty. The rule is undefined exactly at zero — the domain has a hole there.
  4. Pick Sine. Notice the output bar never leaves [1,1][-1, 1] no matter how far you slide xx. The range is bounded even though the domain is all of R\mathbb{R}.

The Formal Definition

Definition (function)

Let XX and YY be sets. A function f:XYf : X \to Y is a rule that assigns, to each element xXx \in X, exactly one element f(x)Yf(x) \in Y.

Three words in that sentence are doing all the work. Strike any one of them and the definition collapses.

  • each. The rule must produce an answer for every input in the declared domain — no skipped inputs.
  • exactly one. The rule must produce one answer per input — never two, never an “either-or.”
  • element of Y. The output must live in a declared target set YY (called the codomain). For the calculus we will do this term, the codomain is almost always R\mathbb{R} — the real numbers.

Vocabulary you will see again and again:

Symbol / PhraseMeans
xthe input (a.k.a. argument, independent variable)
fthe rule (the function itself, NOT a number)
f(x)the output produced when the rule is applied to x
y = f(x)names the output y so we can plot it on a vertical axis
X (domain)the set of ALLOWED inputs
Y (codomain)the set the outputs are declared to live in
f(X) (range / image)the set of outputs ACTUALLY produced

f and f(x) are different things

ff is the function (the rule, the machine, the arrow). f(x)f(x) is the number that comes out when you feed xx in. Saying “the function f(x)f(x)” is sloppy but common; it really means “the function whose value at the generic input xx is f(x)f(x).”


Three Equivalent Views of a Function

The same function can be described in three completely different languages. A skilled calculus student can flip between them effortlessly — each one makes some questions easy and other questions hard.

View 1 — The formula

The compact, algebraic description:

f(x)=x24f(x) = x^{2} - 4

Tells you the rule in five symbols. Best for computation and for proving things. Useless if you don't know algebra.

View 2 — The table

A finite list of (input, output) pairs:

xf(x) = x² − 4
−35
−20
−1−3
0−4
1−3
20
35

Tells you the function's behaviour at a handful of points. Best for hand calculations and spotting patterns (notice the symmetry around x=0x = 0). Useless if you need information at a point not in the table.

View 3 — The graph

The set of all points (x,f(x))(x, f(x)) drawn in the plane. For our example this is a parabola opening upward, sliding down to its lowest point at (0,4)(0, -4) and crossing the x-axis at (±2,0)(\pm 2, 0). The Function Machine visualiser above is one such graph.

The graph is the most visual view — you see the whole shape at a glance. It is also where calculus lives: derivatives are the slopes of tangent lines to graphs, integrals are areas under graphs. The graph is the bridge between algebra and geometry.

The three are interchangeable

Given any one of the three (formula, table, graph), you can in principle recover the other two: tabulate the formula, plot the table, read coordinates off the graph. Different problems favour different views — and learning to switch quickly is half of what it means to be fluent in calculus.


The Vertical Line Test

Suppose someone draws a curve in the plane and asks “is this the graph of a function?” The formal check would be: for every input x0x_0, is there exactly one output paired with it? That phrasing is awkward to apply visually.

Here is the geometric reformulation. Fix any vertical line x=x0x = x_0. The points on the curve that share this x-coordinate are exactly the outputs the curve assigns to x0x_0. The function rule demands at most one output per input. So:

Vertical Line Test

A curve in the plane is the graph of a function (of xx) if and only if every vertical line meets the curve in at most one point.

Why “at most” and not “exactly”? Because a vertical line at an x0x_0 outside the domain hits the curve zero times — and zero is fine. The forbidden situation is two or more.

The classic counter-example: the circle

Consider x2+y2=1x^{2} + y^{2} = 1, the unit circle. At x=0x = 0 the equation gives y2=1y^{2} = 1, so y=±1y = \pm 1. Two outputs for one input. The circle is not a function of xx. It is a beautiful curve — it is just not a function.

Don't throw curves away

Non-functions are not bad math. The circle, the sideways parabola, and many parametric curves are essential objects. They simply need richer tools (parametric equations, implicit differentiation, multivariable functions) to be handled with calculus. We will get there — but the cleanest case, and the one we start with, is the single-output function.

Interactive — Vertical Line Test

Pick a curve from the gallery, then drag the dashed vertical line. The orange dots are the intersection points. If you ever see two or more orange dots on the same vertical line, the curve fails the test.

Loading vertical-line test…

Domain and Range

Two halves of a function's identity:

  • Domain. The set of inputs the rule is defined on. For f(x)=xf(x) = \sqrt{x} the domain is [0,)[0, \infty); negative inputs have no real square root. For f(x)=1/xf(x) = 1/x the domain is R{0}\mathbb{R} \setminus \{0\}; zero would require dividing by zero.
  • Range. The set of outputs the rule actually produces. For f(x)=x2f(x) = x^{2} the range is [0,)[0, \infty); squaring can never be negative. For f(x)=sin(x)f(x) = \sin(x) the range is [1,1][-1, 1]; sine is bounded.

Finding the domain is usually a hunt for forbidden moves:

OperationForbidden when
division a/bdenominator b = 0
square root √u (over the reals)u < 0
log u (over the reals)u ≤ 0
tan uu = π/2 + kπ
arcsin u, arccos uu outside [−1, 1]

For each constraint you find, exclude the offending inputs. Whatever remains is the domain.

Quick worked drill

Find the domain of g(x)=x1x3g(x) = \dfrac{\sqrt{x - 1}}{x - 3}.

  1. The square root needs x10x - 1 \geq 0, i.e. x1x \geq 1.
  2. The denominator needs x30x - 3 \neq 0, i.e. x3x \neq 3.
  3. Combine: [1,3)(3,)[1, 3) \cup (3, \infty). Every input x1x \geq 1 works except x=3x = 3.

Worked Example — Tracing a Function by Hand

Before we trust any plot or any script, let us trace one function from formula to table to graph using nothing but a pencil.

Click to expand — full hand trace of f(x)=x24f(x) = x^{2} - 4
Step 1 — Read the rule out loud.

Take the input, square it, then subtract four.” The instructions are unambiguous; we will do exactly that for every input we choose.

Step 2 — Pick seven test inputs.

Spread them out so we see the function's personality. Symmetric inputs around zero will reveal symmetry (or its absence). We choose x{3,2,1,0,1,2,3}x \in \{-3, -2, -1, 0, 1, 2, 3\}.

Step 3 — Apply the rule to each input.

f(3)=(3)24=94=5f(-3) = (-3)^{2} - 4 = 9 - 4 = 5

f(2)=(2)24=44=0f(-2) = (-2)^{2} - 4 = 4 - 4 = 0

f(1)=(1)24=14=3f(-1) = (-1)^{2} - 4 = 1 - 4 = -3

f(0)=024=04=4f(0)\, = 0^{2} - 4 = 0 - 4 = -4

f(1)=124=14=3f(1)\, = 1^{2} - 4 = 1 - 4 = -3

f(2)=224=44=0f(2)\, = 2^{2} - 4 = 4 - 4 = 0

f(3)=324=94=5f(3)\, = 3^{2} - 4 = 9 - 4 = 5

Look at the column of outputs: 5, 0, −3, −4, −3, 0, 5. It is a palindrome — that is the algebraic fingerprint of an even function (one for which f(x)=f(x)f(-x) = f(x)). The graph will be symmetric about the y-axis.

Step 4 — Find the special points.

x-intercepts are where f(x)=0f(x) = 0. From our table that is x=2x = -2 and x=2x = 2 (the table doesn't miss them because we were lucky in our choices, but algebraically we'd solve x24=0x^{2} - 4 = 0 giving the same answers).

The y-intercept is f(0)=4f(0) = -4.

The vertex (lowest point of an upward parabola) sits at the symmetric centre of the x-intercepts — here x=0x = 0 — and has y-value f(0)=4f(0) = -4.

Step 5 — Sketch.

Plot the seven points, plus the vertex (0,4)(0, -4). Connect them with a smooth upward-opening parabola. You have just hand-drawn the graph of ff. Compare it to the indigo curve in the Function Machine visualiser above — they are the same shape.

Step 6 — Read off domain and range.

Squaring and subtracting are defined everywhere, so the domain is R\mathbb{R}. The minimum output is 4-4 (at the vertex), and there is no maximum because we can square arbitrarily large numbers. The range is [4,)[-4, \infty).

Step 7 — Sanity-check the function property.

Look at the table: every xx appears exactly once on the left, with one number on the right. The vertical line test (every vertical line meets the parabola once) confirms it geometrically. We have a function.


Python: Building a Function from Scratch

Mathematics and code mean almost the same thing here: a Python def is a function in our sense, and calling it with f(3) is exactly applying the rule. The snippet below defines f(x)=x24f(x) = x^{2} - 4, evaluates it at four inputs, prints a table, and verifies the function property with assert statements. Click any line to see the actual values flowing through it.

Plain Python — define, evaluate, and verify the rule
🐍function_basics.py
1def f(x) — declare the rule

Tells Python: from now on, the name f refers to the rule below. The single parameter x is the placeholder for the input the caller will supply later. NOTE: defining the rule does NOT compute anything yet — Python just stores the recipe.

EXECUTION STATE
⬇ input parameter: x = A symbol — when someone later calls f(5), the body runs with x bound to 5. Inside the body, x behaves like a normal variable.
⬆ once defined, f is = <function f at 0x...> — a Python object that REMEMBERS the rule and can be called with f(...) later.
2Docstring — what the rule does

Triple-quoted string immediately after the def line. Python attaches it to the function as f.__doc__. Good docstrings state two things: (a) what the rule computes, and (b) which inputs are allowed (the domain). Here every real x is allowed.

3return x * x - 4 — execute the rule

When f is called, Python evaluates this expression with the supplied x, then sends the result back to the caller. The function body is just one line — the value of x*x - 4 IS f(x).

EXECUTION STATE
x * x = Python multiplies x by itself. At x = -2 this is (-2)*(-2) = 4. At x = 0 it's 0. At x = 1.5 it's 2.25. At x = 3 it's 9.
x * x - 4 = Then subtract 4. So f(-2) = 4 - 4 = 0; f(0) = 0 - 4 = -4; f(1.5) = 2.25 - 4 = -1.75; f(3) = 9 - 4 = 5.
⬆ return value = A Python float (or int if x is an int — at x = 3, Python returns the int 5).
6inputs = [-2, 0, 1.5, 3] — pick test points

A Python list of four numbers we will feed to f one at a time. We chose them to expose interesting behaviour: a negative root (-2), the y-intercept input (0), a non-integer (1.5), and a larger positive (3).

EXECUTION STATE
⬆ inputs = [-2, 0, 1.5, 3] — four floats/ints, length 4
8print header row

f-string that prints a column header. {'x':>6} means 'right-align the literal string x inside a 6-character field'. This is cosmetics; it just makes the printed table align cleanly.

EXECUTION STATE
⬆ printed = x f(x)
9print divider row

Prints a line of 18 dashes. Pure formatting — no math happens here. Helpful for the human eye.

EXECUTION STATE
⬆ printed = ------------------
10for x in inputs — iterate over the four test points

Python's for-loop. On each pass, the variable x is assigned the next element of inputs, and the indented body runs. The loop body will run exactly 4 times.

LOOP TRACE · 4 iterations
Iteration 1 — x = -2
x = -2
f(x) = x*x - 4 = 4 - 4 = 0
printed row = -2 0.000
Iteration 2 — x = 0
x = 0
f(x) = x*x - 4 = 0 - 4 = -4
printed row = 0 -4.000
Iteration 3 — x = 1.5
x = 1.5
f(x) = x*x - 4 = 2.25 - 4 = -1.75
printed row = 1.5 -1.750
Iteration 4 — x = 3
x = 3
f(x) = x*x - 4 = 9 - 4 = 5
printed row = 3 5.000
11y = f(x) — apply the rule

Calls the function we defined on line 1 with the current loop value of x and stores the result in a new name y. This is the moment Python actually runs the rule x*x - 4. The pair (x, y) is one point on the graph of f.

EXECUTION STATE
f(x) call = Python sets the inner parameter to the caller's x, runs the body, returns the value.
⬆ y = Pure number — the output of the rule for THIS x.
12print formatted row

Pretty-prints the (x, f(x)) pair. {x:>6} reserves 6 columns for x; {y:>8.3f} reserves 8 columns for y and rounds to 3 decimals. Same format on every iteration so the columns line up.

15assert f(3) == f(3) == f(3) — determinism check

The FIRST defining property of a function: same input → same output, every single time. Calling f(3) repeatedly must yield identical results. If it didn't, f would not qualify as a function at all (it would be some random-output gadget). Python's assert raises AssertionError if the condition is False; here it passes silently.

EXECUTION STATE
f(3) on each call = 9 - 4 = 5 → 5 == 5 == 5 → True
16assert f(-2) == f(2) — sharing outputs is OK

Critical clarification of the function rule. Different inputs ARE allowed to share an output. Here both -2 and 2 produce 0 because squaring kills the sign. This does NOT violate the function rule — that rule forbids one input producing two outputs, not two inputs sharing one output.

EXECUTION STATE
f(-2) = (-2)*(-2) - 4 = 4 - 4 = 0
f(2) = 2*2 - 4 = 4 - 4 = 0
f(-2) == f(2) = 0 == 0 → True (assert passes)
17assert f(2) != 100 — the output is determined

Sanity check that f(2) is the SINGLE value 0, not some range or wishful number like 100. Combined with the previous two asserts, this nails down: 'each input produces exactly one output, and that output is whatever the rule computes — no surprises.'

EXECUTION STATE
f(2) = 0
f(2) != 100 = 0 != 100 → True (assert passes)
20print(f"f(1e6) = ...") — no domain walls

Drives home that the domain of THIS function is all real numbers — even a million is fine. Many functions you'll meet later (sqrt, 1/x, log) have forbidden inputs; this one doesn't. The number 1e6 is Python shorthand for 1,000,000.

EXECUTION STATE
f(1e6) = (1e6)*(1e6) - 4 = 1e12 - 4 ≈ 1,000,000,000,000
⬆ printed = f(1e6) = 1000000000000 (domain has no walls)
7 lines without explanation
1def f(x):
2    """The rule: square the input, subtract 4. Domain = all real numbers."""
3    return x * x - 4
4
5# Probe the rule at four inputs we picked by hand.
6inputs = [-2, 0, 1.5, 3]
7
8print(f"{'x':>6}  {'f(x)':>8}")
9print("-" * 18)
10for x in inputs:
11    y = f(x)
12    print(f"{x:>6}  {y:>8.3f}")
13
14# Sanity-check the FUNCTION property: same input -> same output, every time.
15assert f(3) == f(3) == f(3)              # determinism
16assert f(-2) == f(2)                     # different inputs MAY share an output
17assert f(2) != 100                       # but the output is determined
18
19# Forbidden? Not for THIS rule -- every real number is allowed.
20print(f"\nf(1e6) = {f(1e6):.0f}  (domain has no walls)")

Running this prints a four-row table that matches our hand trace, and the three asserts pass silently. Silence is the loudest possible confirmation: every property a function is supposed to have, this code has.


NumPy: Vectorised Evaluation

Plain Python needs a for-loop to evaluate ff at many points. NumPy lets us apply the same rule to a thousand inputs in a single line — and the speedup is the foundation of every scientific-computing library you will use later (NumPy, PyTorch, JAX, TensorFlow, scikit-learn).

The key insight is that the same source code we wrote above keeps working. We never touch the function definition — only the input becomes a vector. NumPy quietly broadcasts the rule over every element.

NumPy — broadcast the rule across an entire array
🐍function_vectorised.py
1import numpy as np — load the array library

NumPy is Python's de-facto numerical library. It introduces a new type, np.ndarray, that stores a block of numbers and supports vectorised arithmetic — operations that act on every element at once, in C, without a Python-level for-loop. Everything we wrote before with one number now works with thousands at the same speed.

EXECUTION STATE
np = The conventional alias for numpy. np.array(...), np.linspace(...), etc.
3def f(x) — re-declare the rule

Exactly the same rule as before. Crucially, we do NOT need to write a special vectorised version: Python lets x be either a single number or a NumPy array, and the arithmetic operators below adapt automatically.

5return x * x - 4 — vector-aware return

If x is a number, this is one multiplication and one subtraction. If x is an array, NumPy multiplies element-wise (x * x means each entry squared) and then subtracts 4 from EVERY entry. The same source code, two completely different runtime behaviours, picked by NumPy at call time.

EXECUTION STATE
if x is a scalar (e.g. 3) = 3 * 3 = 9, then 9 - 4 = 5. One number out.
if x is an array (e.g. [-3, 0, 3]) = [9, 0, 9], then [5, -4, 5]. Array out, same shape.
8xs = np.linspace(-3, 3, 9)

np.linspace(start, stop, n) builds n evenly-spaced numbers in the closed interval [start, stop]. Here we get 9 inputs from -3 to +3 inclusive, with step (3 - (-3)) / (9 - 1) = 0.75.

EXECUTION STATE
step size = (3 - (-3)) / (9 - 1) = 6 / 8 = 0.75
⬆ xs = array([-3. , -2.25, -1.5 , -0.75, 0. , 0.75, 1.5 , 2.25, 3. ])
9print("xs =", xs)

Echoes the 9 inputs so we can see what NumPy built. Useful sanity check before we apply f.

EXECUTION STATE
⬆ stdout = xs = [-3. -2.25 -1.5 -0.75 0. 0.75 1.5 2.25 3. ]
12ys = f(xs) — one call, 9 outputs

We call our function ONCE, passing the entire array. NumPy broadcasts: it computes xs * xs (element-wise square) and then subtracts 4 from every element. There is no visible loop, but conceptually 9 evaluations of the rule happen.

EXECUTION STATE
xs * xs = [9.0, 5.0625, 2.25, 0.5625, 0.0, 0.5625, 2.25, 5.0625, 9.0]
⬆ ys = xs*xs - 4 = [5.0, 1.0625, -1.75, -3.4375, -4.0, -3.4375, -1.75, 1.0625, 5.0]
13print("ys =", ys)

Echoes the 9 outputs. Notice the symmetry: ys[0] == ys[8], ys[1] == ys[7], etc. That's the parabola folding over the y-axis. The same input shapes always produce the same output shapes.

16ys_again = f(xs) — call the rule a second time

We feed the same input again. By the function rule, we must get back EXACTLY the same outputs. NumPy is purely arithmetic — no randomness, no hidden state — so this MUST hold.

EXECUTION STATE
⬆ ys_again = [5.0, 1.0625, -1.75, -3.4375, -4.0, -3.4375, -1.75, 1.0625, 5.0] (identical)
17np.array_equal(ys, ys_again) — verify

Helper that returns True iff the two arrays have the same shape AND every element matches. If this ever printed False, we'd have a non-deterministic 'function' — i.e. not a function at all. Pure-arithmetic NumPy guarantees True.

EXECUTION STATE
⬆ printed = deterministic? True
20for i, j in [(0, 8), (1, 7), (2, 6)] — symmetry probes

Three pairs of indices. The list (0, 8) pairs the LEFTMOST and RIGHTMOST elements of xs. Similarly (1, 7) and (2, 6) move one step inward. Because f(x) = x² - 4 is even (f(-x) = f(x)), each pair must show the same y.

LOOP TRACE · 3 iterations
Iteration 1 — (i, j) = (0, 8)
xs[0] = -3.00
xs[8] = +3.00
ys[0] = 5.00
ys[8] = 5.00 (matches!)
printed = f(-3.00) = 5.00 f(+3.00) = 5.00
Iteration 2 — (i, j) = (1, 7)
xs[1] = -2.25
xs[7] = +2.25
ys[1] = 1.0625
ys[7] = 1.0625 (matches!)
printed = f(-2.25) = 1.06 f(+2.25) = 1.06
Iteration 3 — (i, j) = (2, 6)
xs[2] = -1.50
xs[6] = +1.50
ys[2] = -1.75
ys[6] = -1.75 (matches!)
printed = f(-1.50) = -1.75 f(+1.50) = -1.75
21print(f"f({xs[i]...}) = ...")

Pretty-prints both members of the pair side by side. The +.2f format forces a sign so we can SEE that xs[i] and xs[j] are negatives of each other. The matching y's confirm: different inputs sharing an output is perfectly legal — that's what the parabola does at every height except y = -4 (the bottom).

10 lines without explanation
1import numpy as np
2
3def f(x):
4    """Same rule as before, but x can now be a NumPy array."""
5    return x * x - 4
6
7# Build 9 evenly-spaced inputs from -3 to 3 in ONE shot.
8xs = np.linspace(-3, 3, 9)
9print("xs =", xs)
10
11# Apply f to ALL 9 inputs at once -- NumPy broadcasts the rule.
12ys = f(xs)
13print("ys =", ys)
14
15# Confirm the function property element-wise: same xs => same ys
16ys_again = f(xs)
17print("deterministic?", np.array_equal(ys, ys_again))
18
19# Find which x's give the SAME y (the parabola is symmetric).
20for i, j in [(0, 8), (1, 7), (2, 6)]:
21    print(f"f({xs[i]:+.2f}) = {ys[i]:.2f}   f({xs[j]:+.2f}) = {ys[j]:.2f}")

The same idea powers deep learning

When a neural network applies its activation function to a tensor of shape (B,H,W,C)(B, H, W, C), it is doing exactly what we just did — applying one rule to every element of a giant array. PyTorch and JAX are NumPy with extra superpowers (GPU execution, automatic differentiation), but the conceptual model is identical. Mastering “a function applied to a tensor” in NumPy is mastering it everywhere.


Why This Matters for Calculus

Every concept in the chapters ahead is a question about a function:

  • Limits (Chapter 2) ask: what value is the output f(x)f(x) approaching as the input xx approaches some target?
  • Continuity (Chapter 3) asks: can the graph of ff be drawn without lifting the pencil?
  • Derivatives (Chapter 4) ask: how fast is the output changing per unit change in input?
  • Integrals (Chapter 8) ask: what is the total accumulation of ff over an interval?
  • Differential equations (Chapters 19+) ask: which function ff satisfies a given equation relating ff and its derivatives?

Without a precise notion of function, none of those questions can even be stated. With it, the whole edifice of calculus becomes a careful study of how outputs respond to inputs — sometimes locally (limits, derivatives), sometimes globally (integrals, equations). The same word — function — supports both.


Common Pitfalls

  • Confusing ff with f(x)f(x). ff is the rule; f(x)f(x) is a specific output. Writing “differentiate ff” means differentiate the rule; writing “the value f(3)f(3)” means a single number.
  • Allowing two outputs for one input. The expression y=±xy = \pm\sqrt{x} is not a function — for x=4x = 4 it returns both +2+2 and 2-2. To get an honest function you must pick a sign: y=+xy = +\sqrt{x} or y=xy = -\sqrt{x}, but not both.
  • Forgetting to state the domain. A formula alone is not a function — it is a function once you commit to a domain. Writing “the function 1/x1/x” quietly means “on R{0}\mathbb{R} \setminus \{0\}.” Always know what set your inputs live in.
  • Treating the graph as the function instead of as a picture of the function. The graph is a visual aid; the rule is the real object. Two functions with different rules can have visually similar graphs (e.g. x2x^{2} vs. a narrow gaussian near zero) — only the rule disambiguates.
  • Confusing range with codomain. The codomain is where outputs are declared to live (often R\mathbb{R}). The range is which of those values actually appear. For sin\sin, codomain R\mathbb{R}, range [1,1][-1, 1]. The distinction matters when we discuss invertibility.

Summary

  • A function f:XYf : X \to Y is a deterministic rule sending each input xXx \in X to exactly one output f(x)Yf(x) \in Y.
  • Functions live in three interchangeable forms: a formula, a table of (input, output) pairs, and a graph in the plane.
  • The vertical line test: a curve is a function of xx iff every vertical line crosses it in at most one point.
  • The domain is the set of allowed inputs; the range is the set of outputs the rule actually produces.
  • Two different inputs may share an output (e.g. f(2)=f(2)=0f(-2) = f(2) = 0) — but a single input may not have two outputs.
  • A Python def (or a NumPy expression) implements a function literally — and the function property (same input → same output) is automatically true for pure arithmetic code.

What's next

§1.2 introduces linear functions — the simplest non-trivial functions, and the ones that hold the seed of the derivative idea. From there we will climb through polynomials, exponentials, logarithms, and trigonometric functions before the limit machinery of Chapter 2 sets calculus in motion.

Loading comments...