No Bullshit Guide to Mathematics

Ivan Savov

October 25, 2020

Contents

- Concept maps

- Preface

- Introduction

- Chapter 1 Numbers, variables, and equations

- 1.1 Solving equations

- 1.2 Numbers

- 1.3 Number representations

- 1.4 Variables

- 1.5 Functions and their inverses

- Chapter 2 Algebra

- 2.1 Basic rules of algebra

- Chapter 3 Exponents and logarithms

- Chapter 4 Coordinate systems

- Chapter 5 Functions

- Chapter 6 Geometry

- Chapter 7 Vectors

- Chapter 8 Extra topics

- Chapter 9 Practice problems

- End matter

- Answers and solutions

- Notation

- SymPy tutorial

Concept maps

The diagrams below show all the topics and concepts covered in this book.  Topics are shown in rectangular boxes.  Concepts are shown in bubbles with rounded corners.  Note the numerous connections.

Figure 1:   The first chapter of the book covers essential concepts like numbers, number representations, equations, and functions.

Figure 2:   In Chapter 2 we’ll learn about the rules of algebra, which codify what we’re allowed to do with math expressions.

You can annotate the concept maps with your current knowledge of each concept to keep track of your progress.  Add a single dot () next to all concepts you’ve heard of, two dots () next to concepts you think you know, and three dots () next to concepts you’ve used in exercises and problems.  By collecting some dots every week, you’ll be able to move through the material in no time at all.

If you don’t want to mark up your book, you can download a printable version of the concept maps here: bit.ly/mathcmap.

Figure 3:   Visual thinking plays a very important role in mathematics.  In Chapter 4 we’ll learn about the Cartesian plane, which is a two-dimensional coordinate system used to represent points, vectors, and function graphs.  Then in Chapter 6 we’ll learn about the fundamental geometric shapes like triangles, pyramids, cones, circles, ellipses, parabolas, and hyperbolas.  We’ll also dedicate several sections to familiarizing ourselves with trigonometry, trigonometric functions, and trigonometric identities.

Figure 4:   In Chapter 7, we’ll use our algebra and geometry skills to learn about vectors and vector operations.  In Chapter 8, we’ll discuss math applications and formal math methods like proofs.

Preface

Why this book?

Math is a beautiful subject with many practical applications.  Yet many people feel uncomfortable around math.  Some even claim to “hate” math and try to avoid the subject.  Countless adults are living with math phobia.  That’s too bad because learning math opens many doors to understanding concepts in science, computing, music, and business.  Math is also useful for accomplishing day-to-day tasks.

Why learn math?

Math is a universal language for describing patterns and shapes.  Math is everywhere around us.  When you learn math, you’ll be able to see the equations behind real-world phenomena, and then use these equations to predict the future.  How cool is that?  Learning math will also help you make better daily decisions like avoiding predatory loans, estimating times and distances when travelling, double-checking calculations in contracts and bills, and forecasting the cash flow of your business.  Math is not just for scientists and engineers—everyone benefits from knowing math the same way everyone benefits from knowing how to read and write.

Is this book for you?

This book is written for adult learners who think they suck at math and feel uncomfortable around numbers and equations.  Whether you hate math because of bad experiences, feel disheartened at the sight of equations, or simply don’t see the point of learning math, this book has something to offer you.  It’s time to reconnect with this beautiful subject.

This book will be useful for everyone who wants to learn math.  High school students can quickly learn the material they need for their classes.  University students can use the book to review and prepare for more advanced subjects like calculus, statistics, and linear algebra.  Parents who want to help their kids with homework can depend on this book to refresh their math skills.

How are we going to do this?

This book approaches math by showing you the connections between concepts.  Learning math does not require memorizing facts and equations.  It’s not about how many equations you know, but about knowing how to get from one equation to another.  Consult the concept maps on pages 1 and 3 to see all the topics covered in the book and how they are interconnected.

Each section in this book is a short tutorial that covers one math topic with precise definitions, illustrative examples, and concise explanations.  By progressing through the chapters and sections of this book, you’ll develop your math knowledge step by step, with each new layer of understanding building upon the previous ones.  The book covers numbers, sets, variables, equations, algebra, functions, geometry, trigonometry, and also math applications to personal finance.  If it’s useful math, we’ve got it covered!  To ensure that you really grasp the material, the book provides numerous exercises and practice problems (see Chapter 9).  You’ll find the answers to all the exercises and problems in Appendix 1 (page 1).

About the publisher

Minireference Co. is a publisher specializing in math and science.  Our goal is to make advanced math modelling tools accessible to everyone by producing affordable textbooks that explain math concepts clearly and concisely.  It’s time for a break from traditional textbooks that are expensive, heavy, and tedious to read.  The books in the No Bullshit Guide series are an efficient and enjoyable alternative for learning mathematical subjects.  Whether you’re a student, a parent, or an adult learner, we’ve got a book for you that will help you level-up in math.

About the author

I have been tutoring math and physics for more than 17 years.  Through this experience, I learned to break complicated ideas into smaller, interconnected chunks that are easy to understand.  I think the best way to teach math is to clearly define concepts and show the paths that connect them.  When learners know the basic vocabulary and are able to find their way in a new mathematical domain, the battle against math phobia is already half won.

Ivan Savov

Montreal, 2020

Introduction

If you look carefully, you’ll find mathematical patterns all around you: complex patterns like the water waves on the surface of a lake, medium-complexity patterns like the up-and-down oscillations of a mass suspended on a spring, and basic patterns that occur in all numbers and geometric shapes.

This is a book about basic math patterns.  The goal is to introduce you to fundamental building blocks like numbers, expressions, functions, algebra, and geometry.  Understanding basic math concepts will provide you with a common core of tools that you can use in diverse fields like physics, chemistry, biology, medicine, engineering, and business.

Thinking like a mathematician means being able to notice the patterns everywhere around you.  That’s what mathematicians do all day—seriously!  First you observe a pattern; then you try to describe the pattern (this is usually where the equations and formulas come in); finally you use the pattern to achieve some practical outcome.  Would you believe me if I told you that a few equations scribbled on a paper napkin can predict the outcome of a quantum physics experiment, calculate the yield of a chemical reaction, predict the growth rate of bacteria, save a patient’s life, build a bridge, and maximize the profits of a startup?

Do I have your attention?  I hope at this point you’re interested in learning at least a little bit of math.  Or perhaps you still feel kind of weird about reading a math book, and extra weird about reading a math book by choice, without someone forcing you to read it.  What kind of trouble are you getting yourself into?

Relax.  Math is no trouble.  Learning math is not something to worry about or foresee as difficult.  Math is not some sort of obstacle you have to jump over in one shot.  Learning math is more like climbing a mountain.  It’s up to you to choose the pace of your climb.  By investing some time in reading and solving exercises, everyone can gradually make it up the mountain.

The trick to learning math is to redefine what math means to you.  Dear reader, trust me on this one: math does not involve memorization and rote calculations!  That’s arithmetic.  It’s great if you’re fast at adding, subtracting, multiplying, and dividing, but real math is so much more than that.  For example, learning some basic algebra rules will allow you to simplify complicated expressions by rewriting them as equivalent but shorter expressions, so by the time you start plugging in the numbers you have a lot less arithmetic to do.  The more algebra you learn, the less arithmetic you’ll need to do.  What?  We learn more math in order to do less math?  Yes, that’s pretty much the whole point of the subject.  Knowing how to recognize abstract patterns, how to describe them precisely, and how to use them to simplify problems turns out to be a very useful skill set.

In addition to being a useful tool for learning other sciences, learning math is interesting on its own.  There will be some beautiful views at the end of each climb up the math mountains.

Guide to the math mountains

This book is your guide for the first part of your journey in the math mountains.  Math concepts like numbers, equations, functions, algebra, and geometry are the first peaks you must climb on your way to the major math and science mountains.

In Chapter 1, we’ll start by defining fundamental math ideas including numbers, variables, equations, and functions.  These are the main building blocks of math, and we’ll use them throughout the book.  Readers who are new to mathematics should read Chapter 1 carefully and invest the time needed to solve the exercises.

Algebra!  Yes, there, I said it.  In Chapter 2 we’ll learn the rules of algebra, which consist of various simplifications, reductions, and expansions we can perform on math expressions.  Learning algebra by memorizing a bunch of rules is a very difficult task.  Instead, you can think of algebra as a language.  Algebra techniques are verbs that we apply to math expressions.  To expand the expression means to write the expression as .  To factor the expression is to write it as .  To learn algebra you’ll need to learn some new nouns: variable, term, factor, expression, equation.  You’ll also need to become familiar with the algebra verbs: to solve (equations), to factor, to simplify, to expand (expressions), to complete the square (in a quadratic expression), etc.

Are you still with me, dear reader?  I know the prospects of learning algebra might not seem like the most exciting thing ever, and I’m not going to lie to you and say it will be easy to develop your expression-simplifying skills, but the payoff is totally worth it.

In Chapter 3 we’ll discuss exponents and logarithms in detail.  For instance, the expression means to multiply by itself times.  Exponents have some interesting properties, which we’ll spend some time exploring.  We’ll also discuss the logarithmic function , which is the inverse function of the exponential function .

In Chapter 4 we’ll discuss the Cartesian plane, which allows us to visualize math concepts like points, vectors, and geometric shapes.  We can also use the Cartesian plane to plot function graphs, which are visual representations of how functions behave for all inputs.  Chapter 5 is dedicated to the study of functions.  We’ll introduce important new vocabulary for describing functions’ inputs, outputs, and other properties.  We’ll build a catalogue of the 10 most important functions for math and scientific modelling.  We’ll also discuss how to combine, modify, and transform basic functions in order to form composite functions with various desirable properties.

The subject of geometry deals with shapes, transformations, distances, areas, and volumes.  In Chapter 6 we’ll learn about geometry, and discuss various formulas for lines, circles, cylinders, spheres, and other shapes.  We’ll also discuss trigonometry—the study of the relative lengths of the sides of right-angle triangles.

In Chapter 7 we’ll discuss vectors, which are used to describe directions in space.  Vectors are useful for science calculations, computing, statistics, machine learning, and myriad other domains.

In Chapter 8 we’ll discuss various supplementary math topics.  We’ll see how to solve systems of linear equations, how to compute compound interest, and learn a bit about proofs and set notation.  Learning set notation (Section sec:set_notation) is a key foundation for studying more advanced math topics.

The book concludes with a sizeable set of problems (Chapter 9).  Take note, dear reader: math is not a spectator sport.  Reading math is not enough—you must also practice your skills by solving problems.

Use the maps

The concept maps on pages 1 and 3 show an overview of the concepts and topics we’ll discuss in the book.  Note the numerous connections between concepts.  Understanding these connections is the key to understanding math: math isn’t a random bunch of facts, but an interconnected network of ideas.

Are you ready for this?  Let’s get started!

Chapter 1

Numbers, variables, and equations

In this chapter we’ll introduce the fundamental building blocks of math: numbers, variables, equations, and functions.  Learning about the basics will establish a solid foundation for all other topics that are to come.

We’ll start by learning a general procedure for solving equations.  This is a fundamental skill you’ll develop throughout the book, starting in Section 1.1 and expanding as you learn about more advanced types of equations and solution techniques.  In Section 1.2 we’ll define the different types of numbers that exist, then discuss number representations in Section 1.3.  In Section 1.4 we’ll learn how to use variables like and to represent unknowns in equations.

We’ll then discuss functions and function inverses in Section 1.5.  A function describes a transformation between an input variable and a corresponding output variable .  The inverse function describes the same transformation in the opposite direction, treating as the input and as the output.  By learning how to apply functions and function inverses to solve equations, you’re taking one giant step toward acquiring math superpowers.  Overall, your knowledge of numbers, variables, equations, and functions will allow you to solve many types of problems on the journey ahead.

1.1 Solving equations

Most math skills boil down to being able to manipulate and solve equations.  Solving an equation means finding the value of the unknown in the equation.

Check this out:

To solve the above equation is to answer the question “What is ?”  More precisely, we want to find the number that can take the place of in the equation so that the equality holds.  In other words, we’re asking,

That is quite a mouthful, don’t you think?  To remedy this verbosity, mathematicians often use specialized symbols to describe math operations.  The problem is that these specialized symbols can be very confusing.  Sometimes even the simplest math concepts are inaccessible if you don’t know what the symbols mean.

What are your feelings about math, dear reader?  Are you afraid of it?  Do you have anxiety attacks because you think it will be too difficult for you?  Chill!  Relax, my brothers and sisters.  There’s nothing to it.  Nobody can magically guess the solution to an equation immediately.  To find the solution, you must break the problem into simpler steps.  Let’s walk through this one together.

To find , we can manipulate the original equation, transforming it into a different equation (as true as the first) that looks like this:

That’s what it means to solve an equation: the equation is solved because the unknown is isolated on one side, while the constants are grouped on the other side.  You can type the numbers on the right-hand side into a calculator and obtain the numerical value of .

By the way, before we continue our discussion, let it be noted: the equality symbol () means that all that is to the left of is equal to all that is to the right of .  To keep this equality statement true, for every change you apply to the left side of the equation, you must apply the same change to the right side of the equation.

To find , we need to manipulate the original equation into its final form, simplifying it step by step until it can’t be simplified any further.  The only requirement is that the manipulations we make transform one true equation into another true equation.  In this example, the first simplifying step is to add the number four to both sides of the equation:

which simplifies to

Now the expression looks simpler, yes?  How did I know to perform this operation?  I wanted to “undo” the effects of the operation .  We undo an operation by applying its inverse.  In the case where the operation is the subtraction of some amount, the inverse operation is the addition of the same amount.  We’ll learn more about function inverses in Section 1.5.

We’re getting closer to our goal of isolating on one side of the equation, leaving only numbers on the other side.  The next step is to undo the square operation.  The inverse operation of squaring a number is to take its square root , so that’s what we’ll do next.  We obtain

Notice how we applied the square root to both sides of the equation?  If we don’t apply the same operation to both sides, we’ll break the equality!

The equation simplifies to

What’s up with the vertical bars around ?  The notation stands for the absolute value of , which is the same as except we ignore the sign that indicates whether is positive or negative.  For example and , too.  The equation indicates that both and satisfy the equation .  Seven squared is 49, , and negative seven squared is also 49, , because the two negative signs cancel each other out.

The final solutions to the equation are

Yes, there are two possible answers.  You can check that both of the above values of satisfy the initial equation .

If you are comfortable with all the notions of high school math and you feel you could have solved the equation on your own, then you can skim through this chapter quickly.  If on the other hand you are wondering how the squiggle killed the power two, then this chapter is for you!  In the following sections we will review all the essential concepts from high school math that you will need to power through the rest of this book.  First, let me tell you about the different kinds of numbers.

1.2 Numbers

In the beginning, we must define the main players in the world of math: numbers.

Definitions

Numbers are the basic objects we use to count, measure, quantify, and calculate things.  Mathematicians like to classify the different kinds of number-like objects into categories called sets:

- The natural numbers:

- The integers:

- The rational numbers:

- The real numbers:

- The complex numbers:

These categories of numbers should be somewhat familiar to you.  Think of them as neat classification labels for everything that you would normally call a number.  Each group in the above list is a set.  A set is a collection of items of the same kind.  Each collection has a name and a precise definition for which items belong in that collection.  Note also that each of the sets in the list contains all the sets above it, as illustrated in Figure 1.1.  For now, we don’t need to go into the details of sets and set notation, but we do need to be aware of the different sets of numbers.

Figure 1.1:   An illustration of the nested containment structure of the different number sets.  The set of natural numbers is contained in the set of integers, which in turn is contained in the set of rational numbers.  The set of rational numbers is contained in the set of real numbers, which is contained in the set of complex numbers.

Why do we need so many different sets of numbers?  Each set of numbers is associated with more and more advanced mathematical problems.

The simplest numbers are the natural numbers , which are sufficient for all your math needs if all you’re going to do is count things.  How many goats?  Five goats here and six goats there so the total is 11 goats.  The sum of any two natural numbers is also a natural number.

As soon as you start using subtraction (the inverse operation of addition), you start running into negative numbers, which are numbers outside the set of natural numbers.  If the only mathematical operations you will ever use are addition and subtraction, then the set of integers will be sufficient.  Think about it.  Any integer plus or minus any other integer is still an integer.

You can do a lot of interesting math with integers.  There is an entire field in math called number theory that deals with integers.  However, to restrict yourself solely to integers is somewhat limiting—a rotisserie menu that offers of a chicken would be totally confusing.

If you want to use division in your mathematical calculations, you’ll need the rationals .  The set of rational numbers corresponds to all numbers that can be expressed as fractions of the form where and are integers, and .  You can add, subtract, multiply, and divide rational numbers, and the result will always be a rational number.  However, even the rationals are not enough for all of math!

In geometry, we can obtain irrational quantities like (the diagonal of a square with side 1) and (the ratio between a circle’s circumference and its diameter).  There are no integers and such that , therefore we say that is irrational (not in the set ).  An irrational number has an infinitely long decimal expansion that doesn’t repeat.  For example, where the dots indicate that the decimal expansion of continues all the way to infinity.

Combining the irrational numbers with the rationals gives us all the useful numbers, which we call the set of real numbers .  The set contains the integers, the rational numbers , as well as irrational numbers like .  By using the reals you can compute pretty much anything you want.  From here on in the text, when I say number, I mean an element of the set of real numbers .

The only thing you can’t do with the reals is to take the square root of a negative number—you need the complex numbers for that.  We defer the discussion on until the end of Chapter 7.

Operations on numbers

Addition

You can add numbers.  I’ll assume you’re familiar with this stuff:

You can visualize numbers as sticks of different length.  Adding numbers is like adding sticks together: the resulting stick has a length equal to the sum of the lengths of the constituent sticks, as illustrated in Figure 1.2.

Figure 1.2:   The addition of numbers corresponds to adding lengths.

Addition is commutative, which means that .  In other words, the order of the numbers in a summation doesn’t matter.  It is also associative, which means that if you have a long summation like you can compute it in any order or , and you’ll get the same answer.

Subtraction

Subtraction is the inverse operation of addition:

Unlike addition, subtraction is not a commutative operation.  The expression is not equal to the expression , or written mathematically:

Instead we have , which shows that changing the order of and in the expression changes its sign.

Subtraction is not associative either:

For example while .

Multiplication

You can also multiply numbers together:

Note that multiplication can be defined in terms of repeated addition.

The visual way to think about multiplication is as an area calculation.  The area of a rectangle of width and height is equal to .  A rectangle with a height equal to its width is a square, and this is why we call “ squared.”

Figure 1.3:   The area of a rectangle with width  m and height  m is equal to m, which is equivalent to six squares with area m each.

Multiplication of numbers is also commutative, , and associative, .  In modern math notation, no special symbol is required to denote multiplication; we simply put the two factors next to each other and say the multiplication is implicit.  Some other ways to denote multiplication are , , and, on computer systems, .

Division

Division is the inverse operation of multiplication.

Whatever is, you need to divide it into equal parts and take one such part.

Division is not a commutative operation since is not equal to .  Division is not associative either: .  For example, when , , and , we get while .

Note that you cannot divide by .  Try it on your calculator or computer.  It will say “error divide by zero” because this action simply doesn’t make sense.  After all, what would it mean to divide something into zero equal parts?

Exponentiation

The act of multiplying a number by itself many times is called exponentiation.  We denote “ exponent ” using a superscript, where is the number of times the base is multiplied by itself:

In words, we say “ raised to the power of .”

To visualize how exponents work, we can draw a connection between the value of exponents and the dimensions of geometric objects.  Figure 1.4 illustrates how the same length corresponds to different geometric objects when raised to different exponents.  The number corresponds to a line segment of length two, which is a geometric object in a one-dimensional space.  If we add a line segment of length two in a second dimension, we obtain a square with area in a two-dimensional space.  Adding a third dimension, we obtain a cube with volume in a three-dimensional space.  Indeed, raising a base to the exponent is commonly called “ squared,” and raising to the power of is called “ cubed.”

The geometrical analogy about one-dimensional quantities as lengths, two-dimensional quantities as areas, and three-dimensional quantities as volumes is good to keep in mind.

Figure 1.4:   Geometric interpretation for exponents , , and .  A length raised to exponent corresponds to the area of a square.  The same length raised to exponent corresponds to the volume of a cube.

Our visual intuition works very well up to three dimensions, but we can use other means of visualizing higher exponents, as demonstrated in Figure 1.5.

Figure 1.5:   Visualization of numbers raised to different exponents.  Each box in this grid contains dots, where the base varies from one through five, and the exponent varies from one through five.  In the first row we see that the number raised to any exponent is equal to itself.  The second row corresponds to the base so the number of dots doubles each time we increase the exponent by one.  Starting from in the first column, we end up with in the last column.  The rest of the rows show how exponentiation works for different bases.

Operator precedence

There is a standard convention for the order in which mathematical operations must be performed.  The basic algebra operations have the following precedence:

1. Parentheses

2. Exponents

3. Multiplication and Division

4. Addition and Subtraction

If you’re seeing this list for the first time, the acronym PEMDAS and the associated mnemonic “Please Excuse My Dear Aunt Sally,” might help you remember the order of operations.

For instance, the expression is interpreted as “First find the square of , then multiply it by , and then add .”  Parentheses are needed to carry out the operations in a different order: to multiply times first and then take the square, the equation should read , where parentheses indicate that the square acts on as a whole and not on alone.

Exercises

E1.1     Solve for the unknown in the following equations:

a)         b)

c)         d)

E1.2     Indicate all the number sets the following numbers belong to.

a)         b)         c)         d)         e)

E1.3     Calculate the values of the following expressions:

a)         b)         c)

1.3 Number representations

We use the letters “a, b, c, …” to write words.  In a similar fashion, we use the digits , and to write numbers in the language of math.  You can think of the digits through as the “letters” used to write numbers.  For example, the number consists of the digits , , and .  Note that the same digit denotes two different quantities depending on its position within the number.  The first digit corresponds to the value three hundred, while the second digit corresponds to the value thirty.

Concepts

In this section, we’ll review three important number representations:

- The decimal notation for integers, rationals, and real numbers consists of an integer part and a fractional part separated by a decimal point.  For example, the decimal consists of the integer and the fractional part .

- The fraction notation for integers and rational numbers consists of a numerator divided by a denominator.  Here are some sample math expressions with fractions: , , , and .

- The number line is a graphical representation for numbers that allows us to visualize numbers as geometric points on a line.

The same number can be represented in multiple equivalent ways.  It is often convenient to convert from one representation to another depending on the calculations we need to perform.  For example, the number three can be expressed as the numeral , the decimal , the fraction , or as the point that lies three units to the right of the origin on the number line.  All these representations refer to the same quantity, but each representation is useful in different contexts.  The goal of this section is to get you comfortable working with all the number representations.

Positional notation for numbers

The Hindu–Arabic numeral system is the most widely used system for writing numbers today.  It is a decimal positional system.  The term decimal refers to the fact that it uses 10 unique symbols (the digits through ) to represent numbers.  The system is positional because the value of each digit depends on its position within the number.  Positional number systems are also called place-value systems.

Figure 1.6:   The place-value representation of the number .

Note the terminology used to refer to the individual digits of the numeral: we call the thousands, the hundreds, the tens, and the units.

Any natural number , no matter how large, can be written as a sequence of digits:

where the digits , , …come from the set .

For example, the numeral corresponds to this calculation:

Note how the English pronunciation of the number, “four thousand, two hundred and thirty-five,” literally walks you through the calculation.

Decimal representation

Any number less than one can be written as a decimal point followed by a sequence of digits, as illustrated in Figure 1.7.

The decimal point indicates the beginning of the fractional part of a number.  The place values of the digits to the right of the decimal point correspond to different decimal fractions.  For example, the digit corresponds to three different decimal fractions depending on its position within the number:

Figure 1.7:   The decimal representation of a number smaller than one.

The first digit to the right of the decimal point represents the tenths, the second digit represents the hundredths, the third the thousandths, and so on.

In general, a number written in decimal notation has both an integer part and a fractional part:

The decimal point appears in the middle of the digits and acts as a separator.  The digits to the left of the decimal point, , correspond to the integer part of the number, while the digits to the right of the decimal, , correspond to the fractional part of the number.

Figure 1.8:   The decimal number consists of an integer part and a fractional part separated by the decimal point.

Note the names for the different digits in the fractional part of the decimal in Figure 1.8.  These names are used when we describe the fractional part of a decimal in words:

- “” is read “one and four tenths,” or you could informally describe the decimal as you see it written: “one point four.”

- “” is read “forty-five and thirty-seven hundredths,” or sometimes “forty-five point three seven.”

- A length measurement like “ in” is read “three-hundred forty-five thousandths of an inch.”

We can use decimal notation to represent rational numbers like one-half (), one-quarter (), and three-quarters ().  We can also use decimal notation to write approximations to irrational numbers.  For example, the irrational number (the diagonal of a square with length one) is approximately equal to .  We say the approximation is “accurate to five decimals,” because this is how many digits there are in its fractional part.

So far we reviewed the decimal representation for numbers, which is very familiar to us from everyday life.  Perhaps you’re starting to think that math isn’t so bad after all?  Some of you must be saying, “Wonderful, I’m becoming friends with numbers while avoiding uncomfortable topics like fractions.”  Sorry, but you’re not getting off so easily because this is exactly what’s coming up next.  That’s right, we’re about to make friends with fractions, too.

Fractions

Fractions describe what happens when a whole is cut into equal parts and we are given of those parts.  For example, the fraction  describes having three parts out of a whole cut into eight parts, hence the name “three-eighths.”

Figure 1.9:   The fraction can be visualized as three slices from a pizza that has been cut into eight equal slices.

It’s important to understand fractions because many math concepts like rational numbers (), ratios, percents, and probabilities are best described in the language of fractions.

Definitions

The fraction “ over ” can be written three different ways:

The top and bottom parts of the fraction have special names:

- is called the denominator of the fraction.  It tells us how many parts make up the whole.

- is called the numerator.  It tells us the number of parts we have.

Fractions are the most natural way to represent rational numbers.  Why natural?  Check out these simple fractions:

The fractional notation on the left is preferable because it shows the underlying structure of the number while avoiding the need to write complicated decimals.

When written as decimal numbers, certain fractions have infinitely long decimal expansions.  We use the overline notation to indicate the digit(s) that repeat infinitely in the decimal, as in the case of , , and shown above.

Fractions allow us to carry out precise mathematical calculations easily with pen and paper, without the need for a calculator.

Example

Calculate the sum of and .

Let’s say we decide, for reasons unknown, that it’s a great day for decimal notation—we’d have to write our calculation as

Wow that was complicated!  This calculation is much simpler if we use fractions:

Want to know how we did that?  We multiplied the first term by and the second term by in order to obtain two equivalent fractions with the same denominator.  This is one of the standard strategies when performing fraction operations: rewriting them as equivalent fractions that have the same denominator.

Equivalent fractions

The fractions , , and all correspond to the same number.  Think about it—if you cut a pizza in 8 pieces and take 3 of them (see Figure 1.9), or you cut a pizza in 16 equal pieces and take 6 of them, you’ll get the same amount of pizza in the end.  All fractions of the form are equivalent to the fraction , meaning they correspond to the same number.

Multiplying fractions

Fraction multiplication involves multiplying the numerators together and multiplying the denominators together:

For example, the product of the fractions and gives .  This calculation shows that taking “one third of one half of some thing” is the same as taking one sixth of that thing.

Dividing fractions

To divide two fractions, compute the product of the first fraction times the second fraction “flipped” upside down:

In other words, division by the fraction is the same as multiplication by the fraction .  This is called the “flip and multiply” rule for dividing fractions.  For example, to divide the fraction by the fraction , we do the following calculation: .

Reciprocals

The mathematical term reciprocal is used to describe the notion of “flipping” a number.  The reciprocal of is , which is read “one over .”  Multiplication by the reciprocal is the same as division by .  The product of any number and its reciprocal equals one: .  The reciprocal of the fraction is the “flipped” fraction .  The product of and its reciprocal equals one: .

Another way to denote the notion of “flipping” a number is to use the exponent negative one.  The reciprocal of the number is denoted and equals .  The reciprocal of the fraction is denoted and equals .  Using the negative exponent notation for reciprocals, we can write the “flip and multiply” rule for dividing fractions as .  We’ll discuss negative exponents more generally in Section sec:exponents.

Adding fractions

Suppose we are asked to find the sum of the two fractions and .  If the denominators are the same, then we can add just the top parts: .  It makes sense to add the numerators since they refer to parts of the same whole.

However, if the denominators are different, we cannot add the numerators directly since they refer to parts of different wholes.  Before we can add the numerators, we must rewrite the fractions so they have the same denominator, called a common denominator.  We can obtain a common denominator by multiplying the first fraction by and the second fraction by in order to make the denominator of both fractions the same:

Now that we have fractions with the same denominator, we can add their numerators.  Note it’s okay to change the denominator of a fraction as long as we also change the numerator in the same way.  Multiplying the top and the bottom of a fraction by the same number is the same as multiplying by .  So while the numbers of the fractions change, their equivalency is preserved:

Example

To add and , we can use the product of the two denominators as the common denominator, , and perform the fraction addition as follows:

Note how we simplified the fraction by removing the factor that is common to both the numerator and the denominator.  The final answer is a reduced fraction equal to .

The rules for subtracting fractions are the same as for adding fractions: computing the subtraction is the same as computing the addition .

Whole-and-fraction notation

A fraction greater than like can also be denoted , which is read as “one and two-thirds.”  Similarly, .  We write the integer part of the number first, followed by the fractional part.

There is nothing wrong with writing fractions like and .  However, some teachers call these fractions improper and demand that all fractions are written in the whole-and-fraction way, as in and .  At the end of the day, both notations are correct.

Number line

The number line is a very useful visual representation for numbers.  Every number from the sets , , , and corresponds to some point on the number line.  Developing a visual representation for numbers allows us to instantly compare the numbers’ sizes based on their positions on the number line.

Figure 1.10 shows the natural numbers represented as equally spaced points on the number line.  We can construct the entire set of natural numbers by starting from and taking steps of length one to the right on the number line.  That’s what counting is—we just keep adding one.

Note that natural numbers never end.  We can always keep adding one to every number and obtain a larger number.  The number line therefore extends to the right to infinity.

Figure 1.10:   The natural numbers .

The integers are similar to the naturals, but they also extend to the left of zero.  Numbers to the left of zero are negative, while numbers to the right of zero are positive.  The number line extends indefinitely on both sides, going to negative infinity on the left and positive infinity on the right.

Figure 1.11:   The integers .

The set of integers corresponds to a set of equally-spaced points on the number line with gaps of empty space between each integer.  We need the real numbers to fill these gaps.

The set of real numbers is the complete representation of all possible points on the number line: every real number corresponds to some point on the number line, and every point on the number line corresponds to some real number.  Visually, the set of real numbers fills the entire number line in bold, as shown in Figure 1.12.  In other words, there are real numbers everywhere!

Figure 1.12:   The real numbers cover the entire number line.

Recall that the set of real numbers includes all the rational numbers like , , and , as well as irrational numbers like , , and .  This means any number you are likely to run into when solving math problems can be visualized as a point on the number line.  The number line can also be used to represent subsets of the real numbers.  We’ll talk about that in Section sec:set_notation.  For example, the subset of real numbers that are greater than two and smaller than four is shown in Figure fig:interval_2open_to_4open (page fig:interval_2open_to_4open).

Discussion

Since we’re still on the topic of number representations, I want to add some footnotes with “bonus material” related to the ideas we’ve covered in this section.  Feel free to skip to the next section if you’re in a hurry, because this is definitely not going to be on the exam!

Elementary arithmetic procedures

The four basic arithmetic operations are addition, subtraction, multiplication, and division.  We can perform these operations for numerals and of any size using only pen and paper.  It is sufficient to follow one of the well-defined procedures (called algorithms) for manipulating the individual digits that make up the numbers.  The Wikipedia articles on elementary arithmetic and long division offer an excellent discussion of these procedures.

[ Algorithms for performing elementary arithmetic ]

https://en.wikipedia.org/wiki/Elementary_arithmetic

https://en.wikipedia.org/wiki/Long_division

Computer representations

Whenever you want to store a number on a computer, you must choose an appropriate computer representation for this number.  The two most commonly used types of numbers in the computer world are integers (int) and floating point numbers (float).  Computer integers can accurately describe the set of mathematical integers , but there are limitations on the maximum size of numbers that computers can store.  We can use floating point numbers to store decimals with up to 15 digits of precision.  The int and float numbers that computers provide are sufficient for most practical computations, and you probably shouldn’t worry about the limited precision of computer number representations.  Still, I want you to be aware of the distinction between the abstract mathematical concept of a number and its computer representation.  The real number is irrational and has an infinite number of digits in its decimal expansion.  On a computer, is represented as the approximation (a float).  For most purposes the approximation is okay, but sometimes the limited precision can show up in calculations.  For example, float(sqrt(2))*float(sqrt(2)) = 2.0000000000000004 and float(0.1)+float(0.2) = 0.30000000000000004 .  The result of the computer’s calculation is only accurate up to the 15th digit.  That’s pretty good if you ask me.

Scientific notation

In science we often work with very large numbers like the speed of light (), and very small numbers like the permeability of free space ().  It can be difficult to judge the magnitude of such numbers and to carry out calculations on them using the usual decimal notation.

Dealing with such numbers is much easier if we use scientific notation.  The speed of light can be written as , and the permeability of free space is denoted as .  In both cases, we express the number as a decimal number between and followed by the number raised to some exponent.  The effect of multiplying by is to move the decimal point eight steps to the right, making the number bigger.  Multiplying by has the opposite effect, moving the decimal point to the left by six steps and making the number smaller.  Scientific notation is useful because it allows us to clearly see the size of numbers: is whereas is .  With scientific notation you don’t need to count the zeros!

The number of decimal places we use when specifying a certain physical quantity is usually an indicator of the precision with which we are able to measure this quantity.  Taking into account the precision of the measurements we make is an important aspect of all quantitative research.  Since elaborating further would be a digression, we won’t go into a full discussion about the topic of significant figures here.  Feel free to read the Wikipedia article on the subject to learn more.

Computer systems represent numbers using scientific notation, too.  When entering a floating point number into the computer, separate the decimal part from the exponent by the character e, which stands for “exponent.”  For example, the speed of light is written as 2.99792458e8 and the permeability of free space is 1.256637e-6.

Exercises

E1.4     Compute the value of the following expressions:

a)         b)         c)

Links

I encourage you to check the links provided below to learn more about numbers and number representations.

[ History of the Hindu–Arabic system for representing numbers ]

https://en.wikipedia.org/wiki/Hindu–Arabic_numeral_system

[ Positional number representation systems ]

https://en.wikipedia.org/wiki/Positional_notation

[ Decimal representation ]

https://en.wikipedia.org/wiki/Decimal_representation

[ More details on scientific notation ]

https://en.wikipedia.org/wiki/Scientific_notation

[ Info about significant figures calculations ]

https://en.wikipedia.org/wiki/Significant_figures

1.4 Variables

In math we use a lot of variables and constants, which are placeholder names for any number or unknown.  Variables allow us to perform calculations without knowing all the details.

Example

You’re having tacos for lunch today and wondering how many you can eat without going over your caloric budget.  Your goal is to eat 800 calories for lunch and you want to do the calculation before getting to the restaurant because you fear your math abilities might be affected in the presence of tacos.  You’re not sure how many calories each taco contains, so you invent the variable to denote this unknown.  You also define the variable to represent the number of tacos you will eat, and come up with the equation to represent the total number of calories of your lunch.  Solving for , you find the total number of tacos you should order is .  If the restaurant serves tacos that contain calories each, then you should order of them.  If the restaurant serves only giant tacos worth calories each, then you can only eat of them.  Observe we were able to solve for even before knowing the value of .

Variable names

There are common naming patterns for variables:

- : name used for the unknown in equations.  We also use to denote function inputs and the position of objects in physics.

- : common names for integer variables

- : letters near the beginning of the alphabet are often used to denote constants (fixed quantities that do not change).

- : the Greek letters theta and phi are used to denote angles

- : costs in business, along with for profit, and for revenue

- : capital letters are used to denote random variables in probability theory

Variable substitution

We can often change variables and replace one unknown variable with another to simplify an equation.  For example, say you don’t feel comfortable around square roots.  Every time you see a square root, you freak out until one day you find yourself taking an exam trying to solve for in the following equation:

Don’t freak out!  In crucial moments like this, substitution can help with your root phobia.  Just write, “Let ” on your exam, and voila, you can rewrite the equation in terms of the variable :

which contains no square roots.

The next step to solve for is to undo the division operation.  Multiply both sides of the equation by to obtain

which simplifies to

This can be rewritten as the equation , which in turn can be rewritten as using the techniques we’ll learn in Section sec:solving_quadratic_equations.

We now see that the solutions are and .  The last step is to convert our -answers into -answers by using , which is equivalent to .  The final answers are and .  Try plugging these values into the original square root equation to verify that they satisfy it.

Compact notation

Symbolic manipulation is a powerful tool because it allows us to manage complexity.  Say you’re solving a physics problem in which you’re told the mass of an object is kg.  If there are many steps in the calculation, would you rather use the number kg in each step, or the shorter symbol ?  It’s much easier to use throughout your calculation, and wait until the last step to substitute the value kg when computing the final numerical answer.

1.5 Functions and their inverses

As we saw in the section on solving equations, the ability to “undo” functions is a key skill for solving equations.

Example

Suppose we’re solving for in the equation

where is some function and is some constant.  We’re looking for the unknown such that equals .  Our goal is to isolate on one side of the equation, but the function stands in our way.

By using the inverse function (denoted ) we “undo” the effects of .  We apply the inverse function to both sides of the equation to obtain

By definition, the inverse function performs the opposite action of the function , so together the two functions cancel each other out.  We have for any number .

Provided everything is kosher (the function must be defined for the input ), the manipulation we made above is valid and we have obtained the answer .

The above example introduces the notation for denoting the inverse function.  This notation is inspired by the notation for reciprocals.  Recall that multiplication by the reciprocal number is the inverse operation of multiplication by the number : .  In the case of functions, however, the negative-one exponent does not refer to “one over-” as in ; rather, it refers to the inverse function.  In other words, the number is equal to the number such that .  Be careful: sometimes an equation can have multiple solutions.  For example, the function maps two input values ( and ) to the same output value .  The inverse function of is , but both and are solutions to the equation .  In this case, this equation’s solutions can be indicated in shorthand notation as .

Formulas

Here is a list of common functions and their inverses:

The function-inverse relationship is symmetric—if you see a function on one side of the above table (pick a side, any side), you’ll find its inverse on the opposite side.

Don’t be surprised to see in the list of function inverses.  Indeed, the opposite operation of multiplying by is to multiply by once more: ().

Example 1

If you want to solve the equation , you can apply the inverse function of , which is .  After adding four to both sides of the equation, , we obtain the answer .

Example 2

Let’s say your teacher doesn’t like you and right away, on the first day of class, he gives you a serious equation and tells you to find :

See what I mean when I say the teacher doesn’t like you?

First, note that it doesn’t matter what (the Greek letter psi) is, since is on the other side of the equation.  You can keep copying from line to line, until the end, when you throw the ball back to the teacher.  “My answer is in terms of your variables, dude.  You go figure out what the hell is since you brought it up in the first place!”  By the way, it’s not actually recommended to quote me verbatim should a situation like this arise.  The same goes with .  If you don’t have a calculator handy, don’t worry about it.  Keep the expression instead of trying to find its numerical value.  In general, try to work with variables as much as possible and leave the numerical computations for the last step.

Okay, enough beating about the bush.  Let’s just find and get it over with!  On the right-hand side of the equation, we have the sum of a bunch of terms with no in them, so we’ll leave them as they are.  On the left-hand side, the outermost function is a logarithm base .  Cool.  Looking at the table of inverse functions, we find the exponential function is the inverse of the logarithm: .  To get rid of , we must apply the exponential function base 5 to both sides:

which simplifies to

since cancels .

From here on, it is going to be as if Bruce Lee walked into a place with lots of bad guys.  Addition of is undone by subtracting on both sides:

To undo a square root we take the square:

Add to both sides,

divide by

and square again to find the final answer:

Did you see what I was doing in each step?  Next time a function stands in your way, hit it with its inverse so it knows not to challenge you ever again.

Discussion

The recipe I have outlined above is not universally applicable.  Sometimes isn’t alone on one side.  Sometimes appears in several places in the same equation.  In these cases, you can’t effortlessly work your way, Bruce Lee-style, clearing bad guys and digging toward —you need other techniques.

The bad news is there’s no general formula for solving complicated equations.  The good news is the above technique of “digging toward the ” is sufficient for 80% of what you are going to be doing.  You can get another 15% if you learn how to solve the quadratic equation:

We’ll show a formula for solving quadratic equations in Section sec:solving_quadratic_equations.  Solving cubic equations like using a formula is also possible, but at this point you might as well start using a computer to solve for the unknowns.  See page 9.1.11 in Appendix 1.

There are all kinds of other equations you can learn how to solve: equations with multiple variables, equations with logarithms, equations with exponentials, and equations with trigonometric functions.  The principle of “digging” toward the unknown by applying inverse functions is the key for solving all these types of equations, so be sure to practice using it.

Exercises

E1.5     Solve for in the following equations:

a)         b)         c)

E1.6     Find the function inverse and use it to solve the problems.

a)
- Solve the equation , where .

b)

- Solve for in the equation , given .

Chapter 2

Algebra

The rules of algebra tell us how to manipulate math expressions.  By observing and working with the structure of expressions, we can simplify them, and thus compute their values more easily.  In this chapter we’ll learn the general rules that apply to all math expressions.  Knowing these rules will equip you with a powerful toolbox of tricks you can apply to any problem you might face.

In Section 1.1, we learned how to isolate the unknown in equations, which is by far the most important technique for solving equations.  In this chapter we’ll learn a few more techniques, including how to simplify, expand, and factor expressions.  Together, these techniques are called algebra, from the Arabic al-jabr meaning “reunion of broken parts.”

In Section sec:solving_quadratic_equations, we’ll use algebra to derive a general formula for solving quadratic equations of the form .  Knowing how to solve quadratic equations is really important because they show up all over the place.

Alright!  Are you ready for algebra?  Let’s get started!

2.1 Basic rules of algebra

It’s important that you know the general rules for manipulating numbers and variables, a process otherwise known as—you guessed it—algebra.  This little refresher will cover these concepts to make sure you’re comfortable on the algebra front.  We’ll also review some important algebraic tricks, like factoring and completing the square, which are useful when solving equations.

Let’s define some terminology for referring to different parts of math expressions.  When an expression contains multiple things added together, we call those things terms.  Furthermore, terms are usually composed of many things multiplied together.  When a number is obtained as the product of other numbers like , we say “ factors into , , and .”  We call , , and the factors of .

Figure 2.1:   Diagram showing the names used to describe the different parts of the equation .

Given any three numbers , , and , we can apply the following algebraic properties:

1. Associative property: and

2. Commutative property: and

3. Distributive property:

We use the distributive property every time we expand brackets.  For example .  The brackets, also known as parentheses, indicate the expression must be treated as a whole; as a factor consisting of three terms.  Multiplying this expression by is the same as multiplying each term by .

The opposite operation of expanding is called factoring, which consists of rewriting the expression with the common parts taken out in front of a bracket: .  In this section, we’ll discuss all algebra operations and illustrate what they’re capable of.

Example

Suppose we are asked to solve for in the equation

Since the unknown appears on both sides of the equation, it is not immediately obvious how to proceed.

To solve for , we can bring all terms to one side and all constant terms to the other side.  First, expand the two brackets to obtain

Then move things around to relocate all s to the equation’s right-hand side and all constants to the left-hand side:

We see is contained in both terms on the right-hand side, so we can “factor it out” by rewriting the equation as

The answer is within close reach: .

[CONTENT OMITTED IN PREVIEW]

Chapter 3

Exponents and logarithms

Understanding exponents and logarithms is important for your math modelling skills.  Exponential functions can describe population growth, interest calculations on loans, probabilities of random events, voltages in electric capacitors, radioactive decay, and many other phenomena.

The logarithmic function is the inverse of the exponential function.  We need the logarithmic function every time we want to solve an equation containing exponents.  Additionally, the logarithmic scale allows us to conveniently compare numbers of vastly different sizes.  Logarithmic scales are used to describe systems with exponential scale differences, including sound intensity and the acidity of chemical solutions.

As a student of math, you can consider exponentiation and logarithm computation as basic operations, on the same footing as addition, subtraction, multiplication, and division.

In this chapter, you’ll learn the basic rules for manipulating exponents and logarithms.  As you read and practice, your job is to make sure you’re just as comfortable with exponents as you are with addition and multiplication, and as comfortable with logarithms as you are with subtraction and division.

[CONTENT OMITTED IN PREVIEW]

Chapter 4

Coordinate systems

Numbers have a dual nature: they’re simultaneously abstract mathematical concepts and concrete real-world quantities.  The number four corresponds to the abstract concept of “fourness” that is shared by all groups of four objects, but four can also be represented as the length of a four-metre-long wooden pole.  This dual nature of numbers is what makes them so useful: we can use numbers and algebra to solve real-world problems, and also visualize abstract algebra problems in terms of real-world lengths.  If you want to know the combined length of a four-metre pole and a two-metre pole, you can perform the calculation using numbers inside your head, without needing to move any real poles.  Alternatively, you can learn about the abstract concepts of addition and multiplication by manipulating physical objects.[1]

It is possible to add more “dimensions” to the correspondence between numbers and lengths.  The Cartesian plane is a two-dimensional coordinate system that assigns a pair of coordinates to every point in a two-dimensional plane.  In this chapter we’ll discuss this important visualization tool that will support your understanding of functions (Chapter 5), geometry (Chapter 6), and vectors (Chapter 7).

Many important math ideas can be expressed visually as two-dimensional pictures, geometric shapes, and curves.  The same math ideas can also be described by abstract math concepts like numbers and equations.  Coordinate systems serve as the bridge between the space you can visualize and the space of abstract math concepts like coordinates and equations.

[CONTENT OMITTED IN PREVIEW]

1. For example, playing with Cuisenaire rods is an excellent way to become familiar with numbers and math operations.

Chapter 5

Functions

Learning math is like learning a new language.  One of the most useful ideas you can learn in the language of math is the concept of a function.  If numbers and variables correspond to nouns, functions correspond to verbs.  Specifically, functions codify relations between variables; any relationship between two variables can be expressed as a function.  This makes functions a powerful tool for modelling real-world situations.

In this chapter we’ll learn some important math verbs.  We’ll start with some general theory about functions, then catalogue the most important functions that occur in everyday life, in scientific modelling, and in business.  We’re building your vocabulary of math action verbs so you’ll be able to get in on the action.

In Section sec:functions we’ll introduce the main concepts used to characterize functions: the function’s domain and image, the function’s graph, and the function’s values.  Section sec:functions_reference serves as a reference manual for 10 functions of central importance in math, science, and engineering.  In Section sec:function_transformations we’ll observe how translation and scaling transformations affect the functions’ graphs.

[CONTENT OMITTED IN PREVIEW]

Chapter 6

Geometry

Geometry is the mathematical study of shapes and proportions.  This branch of mathematics encompasses all things that can be drawn and analyzed using geometric concepts like similarity, proportionality, and orthogonality.  Geometry studies the common, abstract nature of all geometrical shapes.  For example, instead of studying and describing the properties of any particular triangle, we’ll study the geometrical properties common to all triangles.

We won’t just look at shapes; we’ll develop a language for describing them quantitatively in terms of lengths and angles.  We can find patterns in different geometric shapes and describe proportions and lengths using equations.

Here’s the chapter breakdown.  In Section sec:geometry, we’ll discuss properties of several geometric shapes: triangles, circles, cylinders, spheres, cones, and pyramids.  Sections sec:trigonometry and sec:trigonometric_identities discuss the topic of trigonometry, which is the study of the proportions of the sides of right-angle triangles.  We’ll learn all about the trigonometric functions and , which play an important role in many areas of mathematics.  In Section sec:circle we’ll learn more about circles and polar coordinates.  Sections sec:ellipse, sec:parabola, and sec:hyperbola will discuss the ellipse, the parabola, and the hyperbola, which are three other interesting geometric shapes that occur in nature.

[CONTENT OMITTED IN PREVIEW]

Chapter 7

Vectors

In this chapter we’ll learn how to manipulate multi-dimensional objects called vectors.  Vectors are the precise way to describe directions in space.  We need vectors in order to describe physical quantities like forces, velocities, and accelerations.

Vectors are built from ordinary numbers, which form the components of the vector.  You can think of a vector as a list of numbers, and vector algebra as operations performed on the numbers in the list.  Vectors can also be manipulated as geometric objects, represented by arrows in space.  For instance, the arrow that corresponds to the vector starts at the origin and ends at the point .  The word vector comes from the Latin vehere, which means to carry.  Indeed, the vector takes the point and carries it to the point .

Figure 7.1:   The vector is an arrow in the Cartesian plane.  The horizontal component of is and the vertical component is .

This chapter will introduce you to vectors, vector algebra, and vector operations, which are very useful for solving physics problems.  What you’ll learn here applies more broadly to current problems in computer graphics, probability theory, machine learning, and other fields of science and mathematics.  It’s all about vectors these days, so you’d best get to know them.

Figure 7.2:   This figure illustrates the new concepts related to vectors.  As you can see, there is quite a bit of new vocabulary to learn, but don’t be fazed—all these terms are just fancy ways of talking about arrows.

[CONTENT OMITTED IN PREVIEW]

Chapter 8

Extra topics

Learning all of mathematics would require several lifetimes.  There is so much to learn: applied math, abstract theoretical math, numerical methods, and many other subfields and specialties.  It’s up to you to choose how much you want to learn.  As an adult learner there will be no exams to force you to study, so if you’re learning something it’s because you want to know!

Out of the thousands of possible math topics you could learn next, I’ve selected a shortlist of three important topics to get you started.  In Section sec:solving_systems_of_linear_equations we’ll explore how to solve equations with multiple unknowns.  Specifically, we’ll focus on systems of linear equations that contain unknowns.  For example, the system of equations

consists of two equations that contain two unknowns: and .  There is a systematic procedure you can follow to combine the equations and reduce the problem to a single equation with a single unknown

which you know how to solve.  In the end, we find the unknowns and that satisfy both equations are and .

In Section sec:compound_interest, we’ll learn about the compound interest calculations used by banks to compute the interest owed on loans.  It’s important to understand the math so you can calculate the cost of borrowing for different interest rates and compounding methods.  This topic is particularly relevant for students who are considering taking out student loans.  Think of this math knowledge as financial self-defence.

Finally, in Section sec:set_notation, we’ll introduce sets and set notation.  Mathematicians often use symbols like (element of), (subset of), (for all), and (there exists), to make very concise math statements and definitions.  We managed to get through the entire book without the need for these “alien symbols,” but knowing set notation is important for your future math studies.  Most advanced math textbooks assume readers are familiar with these symbols, so it’s a good idea to know what the symbols mean.

[CONTENT OMITTED IN PREVIEW]

Chapter 9

Practice problems

We’ve now reached the problems chapter in this book.  The purpose of these problems is to give you a way to comprehensively practice your math fundamentals.  Knowing how to solve math problems is a very useful skill to develop.  At times, honing your math chops might seem like tough mental work, but at the end of each problem, you’ll gain a stronger foothold on all the topics you’ve been learning about.  You’ll also experience a small achievement buzz after each problem you vanquish.

Sit down and take a crack at these practice problems today, or another time when you’re properly caffeinated.  If you make time for some math practice, you’ll develop long-lasting comprehension and true math fluency.

Without solving any problems, you’re likely to forget most of what you’ve learned in the next few months.  You might still remember the big ideas, but the details will be fuzzy and faded.  By solving some of the practice problems, you’ll remember a lot more stuff.  Don’t break the pace now: with math, it’s very much use it or lose it!

Make sure you put your phone away while you’re working on the problems.  You don’t need fancy technology to do math; grab a pen and some paper from the printer and you’ll be fine.  The great mathematicians like Descartes, Hilbert, Leibniz, and Noether did most of their work with pen and paper and they did well.  Spend some time with math the way they did.

P9.1     Solve for in the equation .

P9.2     Solve for in the equation .

P9.3     Solve for in the equation .

P9.4     Use a calculator to find the values of the following expressions:

a)         b)         c)         d)

P9.5     Compute the following expressions involving fractions:

a)         b)         c)

P9.6     Use the basic rules of algebra to simplify the following expressions:

a)         b)         c)

d)         e)         f)

P9.7     Expand the brackets in the following expressions:

a)         b)         c)

[CONTENT OMITTED IN PREVIEW]

End matter

Conclusion

We covered many fundamental concepts during this hike in the math mountains.  We started with basic math ideas like variables, expressions, and equations, and then moved into algebra—hopefully you’ll agree with me that algebra is not as scary as some people think, right?  We covered many other scary topics like exponents and logarithms, and you made it through unscathed.  We even tackled more advanced topics like functions, vectors, complex numbers, proofs, and set notation.  Congratulations on powering through this intensive math bootcamp!

The only way to truly understand math is to apply math concepts to solving problems.  You don’t get points for memorizing rules, formulas, and equations; only when you learn how to use the equations will you truly “own” the math.  Math is not a spectator sport!  If you’re reading this book without solving the practice problems, you’re getting a bad deal.  If you haven’t attempted to solve the problems in Chapter 9, you need to turn back and give them a shot.

My intention with this book was to give you a solid, basic understanding of many mathematical concepts, explained quickly and simply so you wouldn’t get bored.  However, it’s possible that the book’s fast pace led to some gaps in the coverage of the material.  Let me know if you find any parts of the book that lack clarity or are missing explanations.  Send me an email if you find a confusing explanation, a missing definition, or an equation you think is wrong.  You can reach me at  ivan@minireference.com.  The book’s relative errorlessness is thanks to the many typo fixes, bug reports, and helpful suggestions I receive from readers like you.

To learn more about other books in the No Bullshit Guide series and find out how Minireference Co. is revolutionizing the textbook industry, visit our blog at minireference.com/blog.  You can also find us on the twitter  @minireference  and on the facebook  fb.me/noBSguide.

Acknowledgments

This book would not have been possible without the support and encouragement of the people around me.  First and foremost of the many people to thank are my parents, who have supported my life choices, and from whom I’ve learned many things.  Next are all my teachers.  I thank my CEGEP teachers: Karnig Bedrossian from whom I learned calculus, Paul Kenton from whom I learned how to think about physics in a chill manner, and Benoit Larose who taught me that more dimensions does not mean things get more complicated.  I thank Kohur Gowrisankaran, Frank Ferrie, Mourad El-Gamal, and Ioannis Psaromiligkos for their teaching during my engineering days, and Guy Moore and Zaven Altounian for teaching me advanced physics topics.  Among all my teachers, I owe the most to Patrick Hayden whose teaching methods have always inspired me.  From him, I learned that by defining things clearly, you can trick students into learning advanced topics, and even make it seem like the results are obvious!  Thanks go out to all my research collaborators and friends: David Avis, Arlo Breault, Juan Pablo Di Lelle, Omar Fawzi, Adriano Ferrari, Mohamad Nizar Kezzo, Igor Khavkine, Felix Kwok, Doina Precup, Andie Sigler, and Mark M. Wilde.  Thank you all for teaching me a great many things.

Preparing this book took many years and the combined efforts of many people.  I want to thank Afton Lewis, Oleg Zhoglo, Georger Araujo, and Tomasz Święcicki for helping me proofread, and all the readers who reported typos and suggested clarifications.  Thank you all for your comments and feedback.  Above all, I want to thank my editor Sandy Gordon, who helped me substantially improve the writing in the book.  Her expertise with the English language and her advice on style and content have been absolutely invaluable.

Last but not least, I want to thank all my students for their endless questions, demand for explanations, and curiosity.  If I’ve developed any ability to explain things, I owe it to them.

Further reading

You’ve reached the end of this book, but you’re only at the beginning of the journey of mathematical discovery.  There are many things left for you to learn about.  Below are some recommendations of subjects you might find interesting.

Newtonian mechanics

Newton’s laws of physics provide an excellent example of the scientific approach to understanding and modelling the world around us.  Using a few basic laws, it’s possible to build accurate models for the motion of objects in terms of concepts like position, velocity, acceleration, momentum, and energy.  It’s no surprise mechanics is a foundational subject of science.

Since you know basic math, it will be easy for you to understand the laws of physics.  Indeed, most physics laws are expressed as mathematical equations.  If you know how to manipulate equations and solve for the unknowns in them, then you already know half of physics.  If you previously avoided this subject out of fear, now would be a great time to revisit it.  Learning physics is an excellent source of knowledge buzz.

By learning how to solve complicated physics problems, you’ll also develop your analytical skills.  Later, you can apply these skills to other areas of life.  Even if you don’t go on to study science, the expertise you develop in solving physics problems will help you tackle complicated problems in general.

[TUTORIAL] Ivan Savov.  Mechanics explained in seven pages, 2017, see minireference.com/static/tutorials/mech_in_7_pages.pdf.

[BOOK] Ivan Savov.  No Bullshit Guide to Math & Physics, Minireference Publishing, Fifth edition, 2014, 978-0-9920010-0-1.

Calculus

Calculus is the language of quantitative science.  Many of the fundamental laws of physics, chemistry, biology, and economics are expressed in the language of calculus.  A solid grasp of this subject is essential for anyone interested in pursuing university-level studies in science, engineering, or business.

The new knowledge you’ll develop in calculus involves analyzing the properties of functions.  You’ll learn to describe how functions change over time (derivatives), and how to calculate the total amount of a quantity that accumulates over a time period (integrals).  The language of calculus will allow you to speak precisely about the different properties of functions, and better understand their behaviour.  You will learn how to calculate the slopes of functions, how to find their maximum and minimum values, how to compute their integrals, and other tasks of practical importance.  In addition to its practical applications, learning calculus will also expose you to the concept of infinity.  Calculus thinking requires understanding infinitely small numbers, infinitely large numbers, and computations with an infinite number of steps.

If you liked the math in this book, I encourage you to continue your journey with the No Bullshit Guide to Math & Physics, which will teach you the topics of mechanics, differential calculus, and integral calculus in an integrated manner, highlighting the connections between them, and discussing their applications.

[BOOK] Ivan Savov.  No Bullshit Guide to Math & Physics, Minireference Publishing, Fifth edition, 2014, 978-0-9920010-0-1.

The calculus book by Thompson is also worth checking out.

[BOOK] Silvanus P. Thompson.  Calculus Made Easy, Macmillian and Co., Second edition, 1914, http://gutenberg.org/ebooks/33283.

You can also learn calculus from these excellent video lessons.

[VIDEOS] Grant Sanderson (3Blue1Brown), Essence of calculus, YouTube playlist, 2018, online: https://bit.ly/3Blue1BrownCalc.

[VIDEO LECTURES] Gilbert Strang.  Highlights of Calculus, MIT OpenCourseWare, 2010, see https://bit.ly/StrangCalcLectures.

Linear algebra

Learning linear algebra will open many doors for you.  You need linear algebra to understand statistics, computer graphics, machine learning, quantum mechanics, and many other areas of science and business.

Here’s a little preview.  Linear algebra is the study of vectors and linear transformations .  Linear transformations are vector functions that obey the linear property .  Using the standard notation for functions, we write to show the linear transformation acting on an input vector to produce the output vector .  Every linear transformation can be represented as a matrix , which is an array of numbers with rows and columns.  Computing is equivalent to computing the matrix-vector product .  Because of the equivalence between linear transformations and matrices, we can also say that linear algebra is the study of vectors and matrices.

Vectors and matrices are used all over the place!  If your knowledge of high-school math gave you modelling superpowers, then linear algebra is the vector-upgrade that teaches you how to build models in multiple dimensions.

[VIDEO LECTURES] Gilbert Strang.  Linear Algebra, MIT OpenCourseWare, 2010, online: http://bit.ly/StrangLAlectures.

[BOOK] Ivan Savov.  No Bullshit Guide to Linear Algebra, Minireference Publishing, Second edition, 2017, ISBN 978-0-9920010-2-5.

Probability

Probability distributions are a fundamental tool for modelling non-deterministic behaviour.  A discrete random variable is associated with a probability mass function , which assigns a “probability mass” to each of the possible outcomes of the random variable .  For example, if represents the outcome of the throw of a fair die, then the possible outcomes are and the probability mass function has the values , .

Probability distributions and random variables allow us to model random processes like the roll of a die.  We can’t predict the exact outcome when two dice and are rolled, but we can predict the probability of different outcomes.  For example, the “pair of sixes” outcome is described by the event .  Assuming the dice are fair, this outcome has probability .

Probability theory is used all over the place, including in statistics, machine learning, quantum mechanics, and risk analysis.

[BOOK] Charles M. Grinstead and J. Laurie Snell.  Introduction to Probability, AMS, 2006, https://bit.ly/GrinsteadSnellProb.

General mathematics

Mathematics is a hugely broad field.  There are all kinds of topics to learn about; some of them are fun, some of them are useful, and some of them are totally mind expanding.

The following resources cover math topics of general interest and serve as a great overview of all areas of mathematics.  I highly recommend you take a look at these for further math enlightening.

[VIDEO] A map of mathematics that shows all the subfields of mathematics and their objects of study: https://youtu.be/OmJ-4B-mS-Y.

[VIDEOS] Video interviews and lessons by some of the best math educators in the world: https://youtube.com/user/numberphile.

[BOOK] Alfred North Whitehead.  An Introduction to Mathematics, Williams & Norgate, 1911, www.gutenberg.org/ebooks/41568.

General physics

If you want to learn more about physics, I highly recommend the Feynman lectures on physics.  This three-tome collection covers all of undergraduate physics and explains many more advanced topics.

[BOOK] Richard P. Feynman.  The Feynman Lectures on Physics, The Definitive and Extended Edition, Addison Wesley, 2005, ISBN 0805390456.  Read online at: http://feynmanlectures.caltech.edu

Final words

Throughout this book, I strived to equip you with the basic math tools you’ll need to make your future studies enjoyable and pain free.  Remember to always take it easy.  Never be afraid of math.  Never take math exams too seriously.  Play with math equations and try different approaches—the worst that can happen is you’ll need another piece of paper.  Grades don’t matter.  Big paycheques don’t matter.  Never settle for a boring job just because it pays well, and try to work only on projects you truly care about.

Along the way, I want you to be confident in your ability to handle any complicated math that life might throw at you.  You have the tools to do anything you want; choose your own adventure.

Answers and solutions

Chapter 1 solutions

Answers to exercises

E1.1 a) ; b) ; c) ; d) .  E1.2 a) ; b) ; c) ; d) ; e) .  E1.3 a) ; b) ; c) .  E1.4 a) ; b) ; c) .  E1.5 a) ; b) ; c) .  E1.6 a) , .  b) , .

Solutions to selected exercises

E1.4 a) To compute , we rewrite both fractions using the common denominator , then compute the sum: .  b) You can use the answer from part (a), or compute the triple sum directly by setting all three fractions to a common denominator: .  c) Here we first rewrite as , then use the common denominator for the computation: .

Chapter 9 solutions

Answers to problems

P9.1 .  P9.2 .  P9.3 .  P9.4 a) .  b) .  c) .  d) .  P9.5 a) .  b) .  c) .  P9.6 a) .  b) .  c) .  d) .  e) .  f) .  P9.7 a) .  b) .  c) .

Solutions to selected problems

P9.5 For c), .

Notation

This appendix contains a summary of the notation used in this book.

Math notation

Expression

Read as

Used to denote

variables

is equal to

expressions that have the same value

is defined as

a new variable definition

plus

the combined lengths of and

minus

the difference in lengths between and

times

the area of a rectangle

squared

the area of a square of side length

cubed

the volume of a cube of side length

to the

multiplied by itself    times

square root of

the side length of a square of area

cube root of

the side length of a cube with volume

divided by

parts of a whole split into    parts

one over

division by

of

the function applied to input

inverse

the inverse function of

compose

function composition;

to the

the exponential function base

natural log of

the logarithm base

to the

the exponential function base

log base of

the logarithm base

theta, phi

angles

sin, cos, tan

trigonometric ratios

percent

proportions of a total;

Set notation

You don’t need a lot of fancy notation to understand mathematics.  It really helps, though, if you know a little bit of set notation.

Symbol

Read as

Denotes

the set

define a sets

such that

describe or restrict the elements of a set

the naturals

the set .  Note .

the integers

the set

the rationals

the set of fractions of integers

the reals

the set of real numbers

the set of complex numbers

subset

one set strictly contained in another

subset or equal

containment or equality

union

the combined elements from two sets

intersection

the elements two sets have in common

set minus

the elements of that are not in

in

is an element of set

not in

is not an element of set

for all

a statement that holds for all

there exists

an existence statement

there doesn’t exist

a non-existence statement

An example of a condensed math statement that uses set notation is “ such that ,” which reads “there don’t exist integers and whose ratio equals .”  Since we identify the set of fractions of integers with the rationals, this statement is equivalent to the shorter “,” which reads “ is irrational.”

Complex numbers notation

Expression

Denotes

the set of complex numbers

the unit imaginary number or

real part of

imaginary part of

polar representation of

magnitude of

phase or argument of

complex conjugate of

Vectors notation

Expression

Denotes

the set of   -dimensional vectors

a vector

vector in component notation

vector in unit vector notation

vector in length-and-direction notation

length of the vector

angle the vector makes with the   -axis

unit vector in the same direction as

dot product of the vectors and

cross product of the vectors and

SymPy tutorial

Computers can be very useful for dealing with complicated math expressions or when slogging through tedious calculations.  Throughout this book we used SymPy to illustrate several math concepts.  We’ll now review all the math tools available through the SymPy command line.  Don’t worry if you’re not a computer person; we’ll only discuss concepts we covered in the book, and the computer commands we’ll learn are very similar to the math operations you’re already familiar with.  This section also serves as a final review of the material covered in the book.

Introduction

You can use a computer algebra system (CAS) to manipulate complicated math expressions and solve any equation.

All computer algebra systems offer essentially the same functionality, so it doesn’t matter which system you use: there are free systems like SymPy, Magma, or Octave, and commercial systems like Maple, MATLAB, and Mathematica.  This tutorial is an introduction to SymPy, which is a symbolic computer algebra system written in the programming language Python.  In a symbolic CAS, numbers and operations are represented symbolically, so the answers obtained are exact.  For example, the number is represented in SymPy as the object Pow(2,1/2), whereas in numerical computer algebra systems like Octave, the number is represented as the approximation (a float).  For most purposes the approximation is okay, but sometimes approximations can lead to problems: float(sqrt(2))*float(sqrt(2)) = 2.00000000000000044 .  Because SymPy uses exact representations, you’ll never run into such problems: Pow(2,1/2)*Pow(2,1/2).

This tutorial presents many explanations as code snippets.  Be sure to try the code examples on your own by typing the commands into SymPy.  It’s always important to verify for yourself!

Using SymPy

The easiest way to use SymPy, provided you’re connected to the internet, is to visit http://live.sympy.org.  You’ll be presented with an interactive prompt into which you can enter your commands—right in your browser.

If you want to use SymPy on your own computer, you must first install Python and the Python package sympy.  You can then open a command prompt and start a Python session using:

you@host> python

Python X.Y.Z

[GCC a.b.c (Build Info)] on platform

Type "help", "copyright", or "license" for more information.

>>>

The >>> prompt indicates you’re in the Python shell which accepts Python commands.  Type the following in the Python shell:

>>> from sympy import *

>>>

The command from sympy import * imports all the SymPy functions into the current namespace.  All SymPy functions are now available to you.  To exit the python shell press CTRL+D.

For an even better experience, you can try jupyter notebook, which is a web interface for accessing the Python shell.  Search the web for “jupyter notebook” and follow the installation instructions specific to your operating system.  It’s totally worth it!

begins with a python import statement for the functions used in that section.  If you use the statement from sympy import *   in the beginning of your code, you don’t need to run these individual import statements, but I’ve included them so you’ll know which SymPy vocabulary is covered in each section.

Fundamentals of mathematics

Let’s begin by learning about the basic SymPy objects and the operations we can carry out on them.  We’ll learn the SymPy equivalents of many math verbs like: “to solve” (an equation), “to expand” (an expression), “to factor” (a polynomial).

Numbers

>>> from sympy import  sympify, S, evalf, N

In Python, there are two types of number objects: ints and floats.

>>> 3

3                             # an int

>>> 3.0

3.0                           # a float

Integer objects in Python are a faithful representation of the set of integers .  Floating point numbers are approximate representations of the reals .  A floating point number has 16 decimals of precision.

Special care is required when specifying rational numbers if you want to get exact answers.  If you try to divide two numbers, Python will compute a floating point approximation:

>>> 1/7

0.14285714285714285           # a float

The floating point number is an approximation of the exact number .  The float approximation has 16 decimals while the decimal expansion of is infinitely long.  To obtain an exact representation of you need to create a SymPy expression.  You can sympify any expression using the shortcut function S():

>>> S('1/7')                  # = sympify('1/7')

1/7                           # = Rational(1,7)

Note the input to S() is specified as a text string delimited by quotes.  We could have achieved the same result using S(’1’)/7 since a SymPy object divided by an int is a SymPy object.

Except for the tricky Python division operator, other math operators like addition +, subtraction -, and multiplication * work as you would expect.  The syntax ** is used to denote exponentiation:

>>> 2**10                    # same as S('2^10')

1024

When solving math problems, it’s best to work with SymPy objects, and wait to compute the numeric answer in the end.  To obtain a numeric approximation of a SymPy object as a float, call its .evalf() method:

>>> pi

pi

>>> pi.evalf()               # = pi.n() = N(pi)

3.14159265358979

The method .n() is equivalent to .evalf().  The global SymPy function N() can also be used to to compute numerical values.  You can easily change the number of digits of precision of the approximation.  Enter pi.n(400) to obtain an approximation of to 400 decimals.

Symbols

>>> from sympy import Symbol, symbols

Python is a civilized language so there’s no need to define variables before assigning values to them.  When you write a = 3, you define a new name a and set it to the value 3.  You can now use the name a in subsequent calculations.

Most interesting SymPy calculations require us to define symbols, which are the SymPy objects for representing variables and unknowns.  For your convenience, when live.sympy.org starts, it runs the following commands automatically:

>>> from sympy import *

>>> x, y, z, t = symbols('x y z t')

>>> k, m, n = symbols('k m n', integer=True)

>>> f, g, h = symbols('f g h', cls=Function)

The first statement imports all the SymPy functions.  The other three statements define some generic symbols x, y, z, and t, and several other symbols with special properties.

Note the difference between the following two statements:

>>> x + 2

x + 2                 # an Add expression

>>> p + 2

NameError: name 'p' is not defined

The name x is defined as a symbol, so SymPy knows that x + 2 is an expression; but the variable p is not defined, so SymPy doesn’t know what to make of p + 2.  To use p in expressions, you must first define it as a symbol:

>>> p = Symbol('p')   # the same as p = symbols('p')

>>> p + 2

p + 2                 # = Add(Symbol('p'), Integer(2))

You can define a sequence of variables using the following notation:

>>> a0, a1, a2, a3 = symbols('a0:4')

You can use any name you want for a variable, but it’s best if you avoid the letters Q,C,O,S,I,N and E because they have special uses in SymPy: I is the unit imaginary number , E is the base of the natural logarithm, S() is the sympify function, N() is used to obtain numeric approximations, and O is used for big-O notation.

Expressions

>>> from sympy import simplify, factor, expand, collect

You define SymPy expressions by combining symbols with basic math operations and other functions:

>>> expr = 2*x + 3*x - sin(x) - 3*x + 42

>>> simplify(expr)                   # simplify the expression

2*x - sin(x) + 42

The function simplify can be used on any expression to simplify it.  The examples below illustrate other useful SymPy functions that correspond to common mathematical operations on expressions:

>>> factor( x**2-2*x-8 )             # factor a polynomial

(x - 4)*(x + 2)

>>> expand( (x-4)*(x+2) )            # expand and expression

x**2 - 2*x - 8

>>> collect(x**2+x*b+a*x+a*b, x)     # collect like terms in x

x**2 + (a+b)*x + a*b

To substitute a given value into an expression, call the .subs() method, passing in a python dictionary object { key:val, ...  } with the symbol–value substitutions you want to make:

>>> expr  = sin(x) + cos(y)          # define an expression

>>> expr

sin(x) + cos(y)

>>> expr.subs({x:1, y:2})            # subs. x=1,y=1 in expr

sin(1) + cos(2)

>>> expr.subs({x:1, y:2}).n()        # compute numeric value

0.425324148260754

Note how we used .n() to obtain the expression’s numeric value.

Solving equations

>>> from sympy import solve

The function solve is the main workhorse in SymPy.  This incredibly powerful function knows how to solve all kinds of equations.  In fact solve can solve pretty much any equation!  When high school students learn about this function, they get really angry—why did they spend five years of their life learning to solve various equations by hand, when all along there was this solve thing that could do all the math for them?  Don’t worry, learning math is never a waste of time.

The function solve takes two arguments.  Use solve(expr,var) to solve the equation expr==0 for the variable var.  You can rewrite any equation in the form expr==0 by moving all the terms to one side of the equation; the solutions to are the same as the solutions to .

For example, to solve the quadratic equation , use

>>> solve( x**2 + 2*x - 8, x)

[2, -4]

In this case the equation has two solutions so solve returns a list.  Check that and satisfy the equation .

The best part about solve and SymPy is that you can obtain symbolic answers when solving equations.  Instead of solving one specific quadratic equation, we can solve all possible equations of the form using the following steps:

>>> a, b, c = symbols('a b c')

>>> solve( a*x**2 + b*x + c, x)

[(-b+sqrt(b**2 - 4*a*c))/(2*a), (-b-sqrt(b**2-4*a*c))/(2*a)]

In this case solve calculated the solution in terms of the symbols a, b, and c.  You should be able to recognize the expressions in the solution—it’s the quadratic formula .

To solve a system of equations, you can feed solve with the list of equations as the first argument, and specify the list of unknowns you want to solve for as the second argument.  For example, to solve for and in the system of equations and , use

>>> solve([x + y - 3, 3*x - 2*y], [x, y])

{x: 6/5, y: 9/5}

The function solve is like a Swiss Army knife you can use to solve all kind of problems.  Suppose you want to complete the square in the expression , that is, you want to find constants and such that .  There is no special “complete the square” function in SymPy, but you can call solve on the equation to find the unknowns and :

>>> h, k = symbols('h k')

>>> solve( (x-h)**2 + k  - (x**2-4*x+7), [h,k] )

[(2, 3)]                               # so h = 2 and k = 3

>>> expand( (x-2)**2+3 )               # verify...

x**2 - 4*x + 7

Learn the basic SymPy commands and you’ll never need to suffer another tedious arithmetic calculation painstakingly performed by hand again!

Rational functions

>>> from sympy import together, apart

By default, SymPy will not combine or split rational expressions.  You need to use together to symbolically calculate the addition of fractions:

>>> a, b, c, d = symbols('a b c d')

>>> a/b + c/d

a/b + c/d

>>> together(a/b + c/d)

(a*d + b*c)/(b*d)

Alternately, if you have a rational expression and want to divide the numerator by the denominator, use the apart function:

>>> apart( (x**2+x+4)/(x+2)  )

x - 1  +  6/(x + 2)

Exponentials and logarithms

Euler’s number is defined one of several ways,

and is denoted E in SymPy.  Using exp(x) is equivalent to E**x.

The functions log and ln both compute the logarithm base :

>>> log(E**3)    # same as ln(E**3)

3

By default, SymPy assumes the inputs to functions like exp and log are complex numbers, so it will not expand certain logarithmic expressions.  However, indicating to SymPy that the inputs are positive real numbers will make the expansions work:

>>> x, y = symbols('x y')

>>> expand( log(x*y) )

log(x*y)

>>> a, b = symbols('a b', positive=True)

>>> expand( log(a*b) )

log(a) + log(b)

Polynomials

Let’s define a polynomial with roots at , , and :

>>> P = (x-1)*(x-2)*(x-3)

>>> P

(x - 1)*(x - 2)*(x - 3)

To see the expanded version of the polynomial, call its expand method:

>>> expand(P)

x**3 - 6*x**2 + 11*x - 6

When the polynomial is expressed in it’s expanded form , we can’t immediately identify its roots.  This is why the factored form is preferable.  To factor a polynomial, call its factor method or simplify it:

>>> factor(P)

(x - 1)*(x - 2)*(x - 3)

>>> simplify(P)

(x - 1)*(x - 2)*(x - 3)

Recall that the roots of the polynomial are defined as the solutions to the equation .  We can use the solve function to find the roots of the polynomial:

>>> roots = solve(P,x)

>>> roots

[1, 2, 3]

# let's check if P equals (x-1)(x-2)(x-3)

>>> simplify( P  -  (x-roots[0])*(x-roots[1])*(x-roots[2]) )

0

Equality checking

In the last example, we used the simplify function on the difference of two expressions to check whether they were equal.  This way of checking equality works because if and only if .  To know whether , we can calculate simplify(P-Q) and see if the result equals .  This is the best way to check whether two expressions are equal in SymPy because it attempts all possible simplifications when comparing the expressions.  Below is a list of other ways to check whether two quantities are equal, with example cases where equality fails to be detected:

>>> P = (x-5)*(x+5)

>>> Q = x**2 - 25

>>> P == Q                                      # fail

False

>>> P - Q == 0                                  # fail

False

>>> simplify(P - Q)                             # works!

0

>>> sin(x)**2 + cos(x)**2  == 1                 # fail

False

>>> simplify( sin(x)**2 + cos(x)**2 - 1 )       # works!

0

Trigonometry

from sympy import sin, cos, tan, trigsimp, expand_trig

The trigonometric functions sin and cos take inputs in radians:

>>> sin(pi/6)

1/2

>>> cos(pi/6)

sqrt(3)/2

For angles in degrees, you need a conversion factor of [rad/]:

>>> sin(30*pi/180)                 # 30 deg = pi/6 rads

1/2

The inverse trigonometric functions and are used as follows:

>>> asin(1/2)

pi/6

>>> acos(sqrt(3)/2)

pi/6

Recall that .  The inverse function of is atan(x)

>>> tan(pi/6)

1/sqrt(3)                          # = ( 1/2 )/( sqrt(3)/2 )

>>> atan( 1/sqrt(3) )

pi/6

The function acos returns angles in the range , while asin and atan return angles in the range .

Here are some trigonometric identities that SymPy knows:

>>> sin(x) == cos(x - pi/2)

True

>>> simplify( sin(x)*cos(y)+cos(x)*sin(y) )

sin(x + y)

>>> e = 2*sin(x)**2 + 2*cos(x)**2

>>> trigsimp(e)

2

>>> trigsimp(log(e))

log(2*sin(x)**2 + 2*cos(x)**2)

>>> trigsimp(log(e), deep=True)

log(2)

>>> simplify( sin(x)**4 - 2*cos(x)**2*sin(x)**2 + cos(x)**4 )

cos(4*x)/2 + 1/2

The function trigsimp does essentially the same job as simplify.

If instead of simplifying you want to expand a trig expression, you should use expand_trig, because the default expand won’t touch trig functions:

>>> expand(sin(2*x))

sin(2*x)

>>> expand_trig(sin(2*x))   # = expand(sin(2*x), trig=True)

2*sin(x)*cos(x)

Complex numbers

>>> from sympy import I, re, im, Abs, arg, conjugate

Consider the quadratic equation .  There are no real solutions to this equation, but we can define an imaginary number (denoted I in SymPy) that satisfies this equation:

>>> I*I

-1

>>> solve( x**2 + 1 , x)

[I, -I]

The solutions are and , and indeed we can verify that and since .

The complex numbers are defined as .  Complex numbers contain a real part and an imaginary part:

>>> z = 4 + 3*I

>>> z

4 + 3*I

>>> re(z)

4

>>> im(z)

3

The polar representation of a complex number is .  For a complex number , the quantity is known as the absolute value of , and is its phase or its argument:

>>> Abs(z)

5

>>> arg(z)

atan(3/4)

The complex conjugate of is the number , which has the same absolute value as but opposite phase:

>>> conjugate( z )

4 - 3*I

Complex conjugation is important for computing the absolute value of () and for division by ().

Euler’s formula

>>> from sympy import expand, rewrite

Euler’s formula shows an important relation between the exponential function and the trigonometric functions and :

To obtain this result in SymPy, you must specify that the number is real and also tell expand that you’re interested in complex expansions:

>>> x = symbols('x', real=True)

>>> expand(exp(I*x), complex=True)

cos(x) + I*sin(x)

>>> re( exp(I*x) )

cos(x)

>>> im( exp(I*x) )

sin(x)

Basically, is the real part of , and is the imaginary part of .  Whaaat?  I know it’s weird, but weird things are bound to happen when you input imaginary numbers to functions.

Vectors

A vector is an -tuple of real numbers.  For example, consider a vector that has three components:

To specify the vector , we specify the values for its three components , , and .

A matrix is a rectangular array of real numbers with rows and columns.  A vector is a special type of matrix; you can think of the vector as a matrix.  Because of this equivalence between vectors and matrices, in SymPy we use Matrix objects to represent vectors.

This is how we define vectors and compute their properties:

>>> u = Matrix([4,5,6])

>>> u

[4, 5, 6]                 # 3-vector

>>> u[0]                  # 0-based indexing for entries

4

>>> u.norm()              # length of u

sqrt(77)

>>> uhat = u/u.norm()     # unit vector in same dir as u

>>> uhat

[4/sqrt(77), 5/sqrt(77), 6/sqrt(77)]

>>> uhat.norm()

1

Dot product

The dot product of the -vectors and can be defined two ways:

where is the angle between the vectors and .  In SymPy,

>>> u = Matrix([ 4,5,6])

>>> v = Matrix([-1,1,2])

>>> u.dot(v)

13

We can combine the algebraic and geometric formulas for the dot product to obtain the cosine of the angle between the vectors

and use the acos function to find the angle measure:

>>> acos(u.dot(v)/(u.norm()*v.norm())).evalf()

0.921263115666387      # in radians  =  52.76 degrees

Just by looking at the coordinates of the vectors and , it’s difficult to determine their relative direction.  Thanks to the dot product, however, we know the angle between the vectors is , which means they kind of point in the same direction.  Vectors that are at an angle are called orthogonal, meaning at right angles with each other.  The dot product between two vectors is negative when the angle between them is .

The notion of the “angle between vectors” applies more generally to vectors with any number of dimensions.  The dot product for -dimensional vectors is .  This means we can talk about “the angle between” 1000-dimensional vectors.  That’s pretty crazy if you think about it—there is no way we could possibly “visualize” 1000-dimensional vectors, yet given two such vectors we can tell if they point mostly in the same direction, in perpendicular directions, or mostly in opposite directions.

The dot product is a commutative operation :

>>> u.dot(v) == v.dot(u)

True

Cross product

The cross product, denoted , takes two vectors as inputs and produces a vector as output.  The cross products of individual basis elements are defined as follows:

The cross product is defined by the following equation:

Here’s how to compute the cross product of two vectors:

>>> u = Matrix([ 4,5,6])

>>> v = Matrix([-1,1,2])

>>> u.cross(v)

[4, -14, 9]

The vector is orthogonal to both and .  The norm of the cross product is proportional to the lengths of the vectors and the sine of the angle between them:

(u.cross(v).norm()/(u.norm()*v.norm())).n()

0.796366206088088    # = sin(0.921..)

The cross product is anticommutative, :

>>> u.cross(v)

[4, -14, 9]

>>> v.cross(u)

[-4, 14,-9]

Watch out for this, because it’s a new thing.  The product of two numbers and is commutative: .  The dot product of two vectors and is commutative: .  However the cross product is not commutative: , it is anticommutative: .

Conclusion

I’ll conclude with some words of warning about technological dependence.  Computer technology is very powerful and everywhere around us, but we must not forget that computers are merely calculators that depend on human commands to direct them.  This means it’s important for you to learn how to do math “by hand” first, in order to know how to instruct computers to do the math for you.

I don’t want you to use the tricks you learned in this tutorial to avoid learning how to do math and blindly rely on SymPy to do math calculations for you.  That’s not a good idea!  I’ll be very disappointed if you use SymPy to skip the “intellectual suffering” necessary to learn the new math concepts like numbers, equations, functions, etc.  That’s what math is all about—understand math concepts and the relationships between concepts.  The part that is about rote memorized of math calculations procedures that you should have learned at school is not important at all.  The tedious and repetitive math calculations is precisely what can be “outsourced” to SymPy.

To solve problems in math (or physics, chemistry, biology, etc.)  the most important things are to: A) define the variables relevant for the problem, B) draw a diagram, and C) clearly set up the problem’s equations in terms of the variables you defined.  With these steps in place, half the work of solving the problem is already done!  Computers can’t help with these important, initial modelling and problem-specific tasks—only humans are good at this stuff.  Once you set up the problem (A, B, C), SymPy can help you breeze through any subsequent calculations that might be necessary to obtain the final answer.

Most of the big math and science discoveries were made using pen and paper, which shows that scribbling on paper is a useful as a tool for thinking.  With what you learned about SymPy, you now have access to the combination of pencil and paper for thinking and SymPy for calculating.  It’s a very powerful combination!  What is a real-world problem you’d like to solve?  Try modelling the problem using math equations and see what happens.  Go out there and do some science!

Links

[ Installation instructions for jupyter notebook ]

https://jupyter.readthedocs.io/en/latest/install.html

[ The official SymPy tutorial ]

http://docs.sympy.org/latest/tutorial/intro.html

[ A list of SymPy gotchas ]

http://docs.sympy.org/dev/gotchas.html

No Bullshit Guide textbook series

This book is part of the No Bullshit Guide series of textbooks.  These textbooks make the most important and useful science topics accessible to a general audience.

No Bullshit Guide to Math & Physics

Newton’s laws of physics form the best-known example of the scientific approach for understanding the physical world.  Starting with a few basic principles, we can build accurate models for the motion of objects and the forces that exist between them.  Calculus is the language of quantitative science.  Many of the fundamental laws of physics, chemistry, biology, and economics are expressed in the language of calculus.  A solid grasp of this subject is essential for anyone who wants to pursue studies in science, engineering, or business.  This book combines math, mechanics, and calculus topics into a single tome.  By learning calculus and mechanics at the same time, readers are able to better see the connections between the two subjects, and understand concepts on a deeper level.  This combined, all-in-one book is ideal for adults who want to learn (or relearn) university-level math and physics topics.

[BOOK] Ivan Savov.  No Bullshit Guide to Math & Physics, Minireference Publishing, Fifth edition, 2014, 978-0-9920010-0-1.

No Bullshit Guide to Linear Algebra

Linear algebra is the study of vectors and linear transformations.  You need to know linear algebra to understand computer graphics, statistics, machine learning, quantum mechanics, and many other areas of science, business, and technology.  This book offers a comprehensive guide to all aspects of linear algebra: computational, geometric, and theoretical.  A sizeable part of the book is dedicated to the applications of linear algebra, including a chapter on quantum mechanics.  This book will be of interest to undergraduate students taking a linear algebra course, graduate students who need a linear algebra review, programmers, data scientists, and anyone who’s interested in quantum mechanics.

[BOOK] Ivan Savov.  No Bullshit Guide to Linear Algebra, Minireference Publishing, Second edition, 2017, ISBN 978-0-9920010-2-5.

Visit  minireference.com to learn more about these and other titles.

Table of Contents

Front matter

Numbers, variables, and equations

Algebra

Exponents and logarithms

Coordinate systems

Functions

Geometry

Vectors

Extra topics

Practice problems

End matter