SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons

Level 0, Orientation and fluency 0.2 Reading maths Lesson 1 of 4

ConceptLesson 0.2.1 in Level 0, Orientation and fluency. About 15 minutes.

Symbols, sets and function notation

A formula is a sentence

Every symbol in a formula stands for a word or two. Here is the average of nn numbers:

xˉ=x1+x2+⋯+xnn\bar{x} = \frac{x_1 + x_2 + \cdots + x_n}{n}

Read it aloud: "x-bar equals x-one plus x-two, and so on up to x-n, all divided by n." Once you can say a formula, you can write it in code.

SymbolSay itIt means
nn"n"how many values there are
x1x_1"x one" or "x sub one"the first value
xix_i"x i"the value in position ii
⋯\cdots"and so on"the pattern carries on
xˉ\bar{x}"x bar"the average of the xx values

Subscripts are positions

A subscript is a small number or letter written low and to the right. It labels a position in a list: x1x_1 is the first value, x2x_2 the second, and xix_i is "the ii-th one", whichever ii you pick.

Rule: Subscripts

x1,x2,…,xn↕x[0],x[1],…,x[n-1]\begin{gathered} x_1, x_2, \ldots, x_n \\ \updownarrow \\ \texttt{x[0]}, \texttt{x[1]}, \ldots, \texttt{x[n-1]} \end{gathered}

Maths usually counts from 1. Python counts from 0. So x1x_1 is x[0], and xix_i is x[i - 1].

Try it

Take four values: x1=4x_1 = 4, x2=8x_2 = 8, x3=15x_3 = 15, x4=16x_4 = 16.

Their total is 43 and n=4n = 4, so the average is xˉ=43/4=10.75\bar{x} = 43 / 4 = 10.75. The cell checks it and shows the shift by one.

⌘/Ctrl + Enter runs the cell

Sets and membership

A set is a collection of different objects, written inside curly brackets: A={2,3,5,7}A = \{2, 3, 5, 7\}. The objects are its elements. Order does not matter and repeats do not count, so {1,2,2,3}\{1, 2, 2, 3\} is the same set as {3,2,1}\{3, 2, 1\}.

Rule: Membership

x∈Ax∉Ax \in A \qquad x \notin A

x∈Ax \in A says "xx is an element of AA". x∉Ax \notin A says it is not. With A={2,3,5,7}A = \{2, 3, 5, 7\}: 3∈A3 \in A and 4∉A4 \notin A.

A few sets have their own letters, and they appear everywhere:

SymbolNameWhat is in it
N\mathbb{N}natural numbers1,2,3,…1, 2, 3, \ldots (some books start at 0)
Z\mathbb{Z}integers…,−2,−1,0,1,2,…\ldots, -2, -1, 0, 1, 2, \ldots
R\mathbb{R}real numbersevery point on the number line, such as −1.5-1.5, 00, 2\sqrt{2}
[a,b][a, b]closed intervalevery real number from aa to bb, ends included
(a,b)(a, b)open intervalevery real number strictly between aa and bb

Try it

Python has sets too, with the same curly brackets. The keyword in is the symbol ∈\in.

The second print shows that repeats vanish. The last line counts the elements.

⌘/Ctrl + Enter runs the cell

Set-builder notation: "such that"

Listing every element only works for small sets. Set-builder notation describes a set by a rule instead:

{x∈Z:1≤x≤10, x is even}={2,4,6,8,10}\begin{gathered} \{x \in \mathbb{Z} : 1 \le x \le 10,\ x \text{ is even}\} \\ = \{2, 4, 6, 8, 10\} \end{gathered}

Read the colon as "such that": "the set of integers xx such that xx is between 1 and 10 and xx is even". Some books write a vertical bar instead of the colon. It means the same thing.

Rule: Set-builder notation

{x∈A:condition}\{x \in A : \text{condition}\}

Everything in AA that passes the condition. The part before the colon says where to look. The part after says what to keep.

Try it

A Python set comprehension reads almost word for word like set-builder notation.

range(1, 11) gives the integers from 1 to 10, because a range stops just before its second number. x % 2 == 0 tests "x is even".

⌘/Ctrl + Enter runs the cell

"For all" and "there exists"

Two symbols turn a condition into a statement that is true or false about a whole set.

Rule: Quantifiers

∀x∈A, P(x)∃ x∈A:P(x)\begin{gathered} \forall x \in A,\ P(x) \\ \exists\, x \in A : P(x) \end{gathered}

∀\forall reads "for all". The statement is true when every element of AA passes the test PP. ∃\exists reads "there exists". It is true when at least one element passes.

With A={2,3,5,7}A = \{2, 3, 5, 7\}:

  • ∀x∈A, x>1\forall x \in A,\ x > 1 is true. Every element is bigger than 1.
  • ∃ x∈A:x>6\exists\, x \in A : x > 6 is true, because of 7.
  • ∀x∈A, x is odd\forall x \in A,\ x \text{ is odd} is false. The single element 2 is enough to break it.

Try it

Python's all is ∀\forall and any is ∃\exists. Each line checks one statement from the list.

⌘/Ctrl + Enter runs the cell

You will also read the word let. "Let nn be the number of values" gives a name to something, like n = len(x) in Python. "Let r>0r > 0" means "assume rr is positive from here on".

Function notation

A function is a rule that turns each input into exactly one output. The formula f(x)=x2+1f(x) = x^2 + 1 names the rule ff and says what it does to an input xx: square it, then add 1.

Rule: Function notation

f(x)=x2+1f(3)=32+1=10\begin{gathered} f(x) = x^2 + 1 \\ f(3) = 3^2 + 1 = 10 \end{gathered}

f(3)f(3) means "the output of ff when the input is 3". It is not ff times 3. To evaluate, replace every xx in the formula with the input.

The letter inside the brackets is only a placeholder. f(t)=t2+1f(t) = t^2 + 1 is the same function. The input can be an expression too: f(a+1)=(a+1)2+1f(a + 1) = (a + 1)^2 + 1. Keep the brackets when you substitute.

You will also see f:R→Rf: \mathbb{R} \to \mathbb{R}. Read it as "ff takes a real number and gives back a real number". The set before the arrow holds the allowed inputs; outputs land in the set after it. Lesson 1.1.1 returns to this.

Try it

In Python a function is a def. The cell evaluates f(3)f(3) and f(−3)f(-3).

Both give 10: two different inputs may share an output. What a function may not do is give two outputs for one input.

⌘/Ctrl + Enter runs the cell

Common mistakes

Try it

  1. f(a+1)f(a + 1) is not f(a)+1f(a) + 1. With f(x)=x2+1f(x) = x^2 + 1, f(2+1)=f(3)=10f(2 + 1) = f(3) = 10, but f(2)+1=6f(2) + 1 = 6.
  2. A subscript is a label, a superscript is a power. x2x_2 and x2x^2 are different things.
  3. Python counts from 0. The maths x1x_1 is x[0], so the last of nn values is x[n - 1].
  4. Sets have no order and no repeats. {1,2}={2,1}\{1, 2\} = \{2, 1\}, but the Python lists [1, 2] and [2, 1] are different.
⌘/Ctrl + Enter runs the cell
Check yourself
Let A={2,4,6,9}A = \{2, 4, 6, 9\}. Which statement is true?
Check yourself
In Python, x = [4, 8, 15, 16]. Which maths symbol does x[2] stand for?

Symbols and functions

0 of 7 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • xix_i is the value in position ii. Maths counts from 1 and Python from 0, so xix_i is x[i - 1].
  • A set lists different elements in curly brackets. x∈Ax \in A means xx is in AA.
  • {x∈A:condition}\{x \in A : \text{condition}\} means everything in AA that passes the condition. The colon reads "such that".
  • ∀\forall is "for all" (all in Python). ∃\exists is "there exists" (any). One counterexample breaks a "for all".
  • f(3)f(3) is the output of ff at input 3. Substitute with brackets: f(a+1)f(a + 1), not f(a)+1f(a) + 1.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.