Appendix B Algebra
Appendix B Algebra
Appendix B Algebra
Introduction to
Artificial Neural Networks
and Deep Learning
with Applications in Python
Introduction to Artificial
Neural Networks
with Applications in Python
Sebastian Raschka
D RAFT
Last updated: May 31, 2018
B Algebra Basics 4
B.1 Exponents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
B.1.1 Basic Principles . . . . . . . . . . . . . . . . . . . . . . 5
B.1.2 Laws of Exponents . . . . . . . . . . . . . . . . . . . . 5
B.1.3 Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
B.2 Properties of Logarithms . . . . . . . . . . . . . . . . . . . . . 6
B.3 Order of Operations . . . . . . . . . . . . . . . . . . . . . . . 8
B.3.1 Commutative, Associative, and Distributive Laws . . 8
B.3.2 Removing Parentheses and Expanding . . . . . . . . 9
B.3.3 Polynomials . . . . . . . . . . . . . . . . . . . . . . . . 11
B.4 Summation and Products of Sequences . . . . . . . . . . . . 12
B.5 Algebra of Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
B.5.1 Set Notation . . . . . . . . . . . . . . . . . . . . . . . . 12
B.5.2 Set Theory . . . . . . . . . . . . . . . . . . . . . . . . . 13
B.5.3 Interval Notation . . . . . . . . . . . . . . . . . . . . . 14
B.6 Domain and Range of a Function . . . . . . . . . . . . . . . . 15
B.7 Inverse Functions . . . . . . . . . . . . . . . . . . . . . . . . . 16
B.8 Function Transformations . . . . . . . . . . . . . . . . . . . . 18
i
Website
Please visit the GitHub repository to download the code examples accom-
panying this book and other supplementary material.
If you like the content, please consider supporting the work by buy-
ing a copy of the book on Leanpub. Also, I would appreciate hearing
your opinion and feedback about the book, and if you have any ques-
tions about the contents, please don’t hesitate to get in touch with me via
mail@sebastianraschka.com. Happy learning!
Sebastian Raschka
1
About the Author
2
Acknowledgements
I would like to give my special thanks to the readers, who provided feed-
back, caught various typos and errors, and offered suggestions for clarify-
ing my writing.
DRAFT 3
Appendix B
Algebra Basics
B.1 Exponents
Almost every equation or function in computer science and engineering in-
volves exponents. And based on the assumption that the vast majority of
readers have worked with exponents before, this section provides a sum-
mary of the most important concepts in tabular form, which is intended to
serve as a refresher as well as a look-up reference.
1
http://www.wallace.ccfaculty.org/book/book.html
DRAFT 4
APPENDIX B. ALGEBRA BASICS 5
Rule Example
1 x0 = 1 50 = 1
2 x1 = x 51 = 5
3 xn = x · x · x · . . . · x 53 = 5 · 5 · 5 = 125
4 x−n = 1
xn 5−2 = 1 1
= 25
52
√ √
5 x1/2 = x 251/2 = 25 = 5
√ √
6 x1/n = n x 1251/3 = 3 125 = 5
√ √
3
7 xm/n = n xm 1252/3 = 1252 = 25
Law Example
1 xm · xn = xm+n 53 · 52 = 55 = 3125
53
2 xm /xn = xm−n 52
= 51 = 5
n
3 xm = xm·n (52 )3 = 56 = 15, 625
4 (xy)n = xn · y n (2 · 5)2 = 22 · 52 = 100
x n xn 5 2 52 25
5 y = yn 2 = 22
= 4
x −n y n 5 −2 2 2 22 4
6 y = x 2 = 5 = 52
= 25
While derivations of the exponent rules are beyond the scope of this al-
gebra refresher, notice that these rules are all closely related to each other,
and they are based on the basic principles that were presented in the previ-
ous section. For instance, while x0 = 1 may seem a bit unintuitive at first,
DRAFT
APPENDIX B. ALGEBRA BASICS 6
we can demonstrate why this relation is true by applying the second rule
from the Table B.2:
xn
1= = xn−n = x0 . (B.1)
xn
B.1.3 Roots
This section lists the basic concepts and rules regarding roots. The root of a
number x is a number that, if multiplied by itself a certain number of times,
√
equals x. Written in a different form, the equation m x = y is true if and only
if y m = x, where m is the root index and x is the radicand.
Equation Example
√ √ √ √
1 ( x)2 = x2 = x ( 4)2 = 42 = 4
for all positive numbers
√ √ √ √ √ √ √
2 x·y = x· y 36 = 9·4= 9· 4=3·2=6
√ q √
√x
q
x 9 √9 3
3 y = y 16 = 16
= 4
√ √ √ √
4 x + y 6= x+ y 16 + 9 6= 4 + 3
p
x2 + y 2 6= x + y
DRAFT
APPENDIX B. ALGEBRA BASICS 7
Property Example
1 logb 1 = 0 log2 1 = 0
2 logb b = 1 log2 2 = 1
3 logb ba = a log2 23 = 3
4 blogb a = a 2log2 8 = 23 = 8
5 logb (m · n) = logb m + logb n log2 (2 · 4) = log2 2 + log2 4 = 1 + 2 = 3
m 4
6 logb n = logb m − logb n log2 2 = log2 4 − log2 2 = 2 − 1 = 1
7 logb (mp ) = p logb m log2 (23 ) = 3 log2 2 = 3
loga m log10 8
8 logb m = loga b log2 8 = log10 2 =3
Also here, we can derive the different properties from each other. For
example, the last property (row 8) in Table B.4 can be obtained as follows,
starting with the basic properties of logarithms:
logb m = c
(B.4)
bc = m.
loga b loga m
c =
loga b loga b
(B.7)
loga m
c= .
loga b
DRAFT
APPENDIX B. ALGEBRA BASICS 8
loga m
logb m = . (B.8)
loga b
x · y = y · x. (B.10)
For example, 5 + 2 = 2 + 5 and 5 · 2 = 2 · 5.
Per associative law, we can disregard the grouping of numbers in opera-
tions such as addition and multiplication:
(x + y) + z = x + (y + z) (B.11)
DRAFT
APPENDIX B. ALGEBRA BASICS 9
and
(x · y) · z = x · (y · z). (B.12)
For example, (5 + 2) + 3 = 5 + (2 + 3) and (5 · 2) · 3 = 5 · (2 · 3).
The distributive law is extremely useful for multiplying and factoring
algebraic expressions. With respect to multiplication and addition, the dis-
tributive law says that
x · (y + z) = x · y + x · z, (B.13)
for example,
5 · (3 + 2) = 5 · 3 + 5 · 2
= 15 + 10 (B.14)
= 25.
5 · (3 + 2) = 5 · 5
(B.15)
= 25.
3 + (5x − 2y + 4) = 3 + 5x − 2y + 4
(B.16)
= 5x − 2y + 7.
DRAFT
APPENDIX B. ALGEBRA BASICS 10
3 − (5x − 2y + 4) = 3 − (−1)(5x − 2y + 4)
= 3 − 5x + 2y − 4 (B.17)
= −5x + 2y − 1.
5(3x + 7)
(B.18)
= 15x + 35.
Of course, the same is true for division, since division is simply multiplica-
tion by the reciprocal:
1
5/(5x + 10) = (5x + 10)
5 (B.19)
=x+2
For example,
DRAFT
APPENDIX B. ALGEBRA BASICS 11
B.3.3 Polynomials
At the end of the previous section, we multiplied two binomials – binomials
are polynomials with two terms. A polynomial is an expression that contains
multiple terms (poly means "many" in Greek).
Polynomials may consist of constants, variables, and exponents, but
they never divide a term by a variable. Thus, polynomials also have no
√
negative exponents. For example, x = x1/2 is not a polynomial, and
x− 2 = x12 is also not a polynomial. Finally, the following is also not a
polynomial because we cannot simplify it further:
15x2 + 10x + 1 1
= 3x + 2 + . (B.22)
5x 5x
In standard form, we write a polynomial as a combination of monomials
sorted by their degree. For instance, the following polynomial, written in
standard form, has three terms:
DRAFT
APPENDIX B. ALGEBRA BASICS 12
where i is the index of summation, and n is the upper bound of summation. For
a simpler example, consider the following:
n
X
xi = x1 + x2 + ... + xn . (B.28)
i=1
Q
Similarly, we use the Capital Pi Notation, , to express products of sequences
with an index variable more concisely. For example,
n
Y
xi = x1 · x2 · . . . · xn . (B.29)
i=1
DRAFT
APPENDIX B. ALGEBRA BASICS 13
• Union: A ∪ B = {x | x ∈ A or x ∈ B, or both}
• Intersection: A ∩ B = {x | x ∈ A and x ∈ B}
• Difference: A − B = {x | x ∈ A and x ∈
/ B}
• Complement: AC = {x | x ∈
/ A}
Figure B.1 provides a visual summary of these operations, given the two
sets A and B, and the universal set Q – a set which contains all possible
elements, including itself.
DRAFT
APPENDIX B. ALGEBRA BASICS 14
DRAFT
APPENDIX B. ALGEBRA BASICS 15
x 1
f f(x)
1 15
2 3 Codomain
2 13
4
3
6 5
4
8
5
10 7 11
DRAFT
APPENDIX B. ALGEBRA BASICS 16
f −1 ◦ f = f ◦ f −1 = I (B.36)
looks similar to the following equation:
1
x−1 · x = x · x−1 = x · = 1. (B.37)
x
DRAFT
APPENDIX B. ALGEBRA BASICS 17
However, notice that superscript (−1) does not mean that we take the func-
tion f to the power of (−1):
1
f −1 (x) 6= . (B.38)
f (x)
A good example of inverse functions are exponential and logarithmic func-
tions: logarithms are the inverse of exponential functions and vice versa.
For instance, consider the following exponential function
f (x) = bx , (B.39)
where its inverse is the base b logarithm defined as
DRAFT
APPENDIX B. ALGEBRA BASICS 18
DRAFT
APPENDIX B. ALGEBRA BASICS 19
DRAFT
Bibliography
DRAFT 20
Abbreviations and Terms
DRAFT 21
Index
DRAFT
22