Functional Notation, Part 2

Last time we saw that we can replace y in an equation with f(x) when y is alone on the left side of an equation:

y = f(x) = 3x² – 5x + 1

The above is an example of the function definition. Once defined, you replace all the x‘s on the right side with whatever is in the brackets on the left side, even if it is not a number. For example,

f(2) = 3(2)² – 5(2) + 1 = 3
f(a) = 3a² – 5a + 1

Even if the thing in the brackets is another expression, for example, an expression that is used in calculus a lot is x + h:

f(x+h) = 3(x + h)² – 5(x + h) + 1

And you can even use another function of x inside the brackets of another function. Like x, the letter f is used in the first instance for a function, but if other functions need to be defined as well, other letters are used:

f(x) = 3x² – 5x + 1
g(x) = x² – 7
f[g(x)] = f(x² – 7) = 3(x² – 7)² – 5(x² – 7) + 1
g[f(x)] = g(3x² – 5x + 1) = (3x² – 5x + 1)² – 7

The domain of a function is all the valid values of x that can be used. Many times, the domain of a function (like f(x) and g(x) above) is just any real number. But there are functions where you cannot use just any number. For example, consider


There is one value of x you cannot use. That value is 2 because that will make the denominator 0, and as you know, this will bring the maths police to your door. So the domain of this function is all real numbers except for 0.

Now consider


Another illegal operation is taking the square root of a negative number. The requirement for this function is that x – 2 has to be 0 or greater. For this to be true, x must be greater than or equal to 2. The phrase ” greater than or equal to” can be replaced by the maths symbol ≥. So the domain of this function is x ≥ 2.

There are other reasons why the domain of a function is restricted, but the most common things to look for is dividing by 0 or taking the square root (or any even root) of a negative number.

Functional Notation, Part 1

Any maths beyond algebra relies on something called functional notation. I used this in one of my posts on Newton’s Laws but more needs to be said if you are to be comfortable with it.

We have looked at many equations to date. Most involved x and y. For example,

y = 3x² – 5x + 1

This will plot as a parabola on an xy coordinate system. The plot is a picture of all (x, y) pairs of numbers that, when substituted in the above equation, will result in a true statement. For example, (0, 1) would be a point on that parabola because 1 = 3(0)² – 5(0) + 1 = 1.

Most of the equations we have looked at have y on the left side and all the other things with x and stand-alone numbers are on the right side. In this form, it is easy to choose a number to replace x with, then do the maths with that number on the right side to find the corresponding y to make the equation true. For example, let’s choose “1” in place of x. The corresponding y will be

y = 3x² – 5x + 1 = 3(1)² – 5(1) + 1 = 3 – 5 + 1 = -1

So (1, -1) is also a point on this equation’s plot.

This is frequently done: choose a value for x, then replace x with that value and do the maths on the right side and find the corresponding y. Notice that we are free to choose a value for x, but once we do, the value for the corresponding y is fixed. For that reason, x is called the independent variable and y is called the dependent variable: y depends on the x we choose.

If y depends on the x we choose, then another way to say this is that “y is a function of x“. The new functional notation makes use of this by replacing y with f(x), read “function of x“. So the functional form of the equation above is

f(x) = 3x² – 5x + 1

This will plot exactly the same but we would replace the y label on the vertical axis with f(x):

So now it is easy to ask the question “What is the value of the function if x = 0″ by just replacing the “x” in f(x) with “0”, that is, f(0):

f(0) = 3(0)² – 5(0) + 1 = 1

So, f(0) = 1. We saw above that f(1) = -1. So now you will see the general coordinate as (x, f(x)) instead of (x, y). This is just a difference in notation – the plot stays the same.

There are some properties of functions and a few more definitions that will be explored next time.

Financial Maths, Part 5

Last time we saw that our $1000 invested at 3% compounded annually will result in $1343.92 in 10 years. To get even better results, the interest rate can be compounded more frequently than annually. Let’s say the interest is applied mid-year. Then the interest earned during the first half of the year will be added to the principal amount and that total will be used to apply the second half interest to.

This will change the formula An = A0(1 + r)n a bit though. First of all, we can’t apply the full per annum interest rate to the initial investment as only half a year has passed. So only half the interest rate will be used. Also, the period length is now half a year so the number of periods refers to how many half-years have passed.

So in our example, the annual interest rate is 3%, so the 6 month interest rate, r, is 3/2 = 1.5% since there are 2 six-month periods in a year. If we want to know how much we will have after 10 years, the number of periods, n, is now 10×2 = 20 since there are 20 half -year periods in 10 years. So we can use the same formula with r = 1.5% = 0.015 and n = 20:

A20 = A0(1 + r)20 = 1000(1 + 0.015)20 = $1346.86

So the extra compounding has made us a bit more money.

You might ask (OK – I’ll ask for you), would we make more money by compounding more frequently? Yes we would!

Let’s compound every quarter-year. this means the interest rate we apply each quarter is 3/4 = 0.75% and the number of periods after 10 years is 10×4 = 40:

A40 = A0(1 + r)40 = 1000(1 + 0.0075)40 = $1348.35

Looks like we want more yet. What about monthly? Here r = 3/12 = 0.25% = 0.0025 and n = 10×12 = 120:

A120 = A0(1 + r)120 = 1000(1 + 0.0025)120 = $1349.35

Better, but notice that this is not much better that quarterly. It appears that we will reach a limit as to how much we can make. Let’s try compounding daily. Here r = 3/365 = 0.0082% = 0.000082 and n = 10×365 = 3650:

A3650 = A0(1 + r)3650 = 1000(1 + 0.000082)3650 = $1349.84

Well that’s disappointing. There is only a 0.49 difference between compound monthly and daily after 10 years.

There is a maths formula that computes the amount of interest if the investment is compounded continuously. This is the limit of what you can make by compounding. For our example, after 10 years, the most compounding will get us after 10 years is $1349.86, just 2 cents more than compounding daily.

Financial Maths, Part 4

In my last post, I developed a recursion formula for compound interest where the interest is compounded annually:

An+1 = An + An × r/100 where you use the percentage value of r or
An+1 = An + An × r where the decimal equivalent of r is used.

These are good formulas if you want to know how much money you will have next year, but will take a while if you want to know how much you will have in 10 years. However, we can use the recursion formula to help develop the direct formula.

I will use the decimal equivalent equation so I don’t have to keep writing “/100”. I will add that at the end of this development.

Using the recursion formula, at the end of year 1 you will have

A1 = A0 + A0 × r = A0(1+r)

Please review my post on factoring, specifically the distributive property, if you do not understand why A0 + A0 × r = A0(1+r).

At the end of year 2, you will have A2 = A1 + A1 × r = A1(1+r). But we have A1 in terms of our initial investment A0 above. So substituting A1 = A0(1+r) into A2 = A1(1+r) results in

A2 = A1(1+r) = A0(1+r)(1+r) = A0(1+r)²

Wait! The exponent 2 of (1+r) is the same as the current period (the subscript of A2. Wouldn’t it be nice if this pattern continued? Let’s do one more iteration, substituting A2 with the above equation:

A3 = A2 + A2 × r = A2(1+r) = A0(1+r)²(1+r) = A0(1+r)³

Wow! It looks like this is true. In fact, it is. The exponent of the (1 + r) part is the same as the period of interest. If you want to find how much you will have after 10 years, you can use the direct formula:

An = A0(1 + r)n

So in our example of investing $1000 at 3% interest per annum (that is each year), compounded annually, you will have after 10 years

A10 = A0(1 + r)10 = 1000(1 + 0.03)10 = $1343.92

Of course, you need a calculator that can do exponents, or you can use the all-knowing internet. The percentage form of the direct equation is

An = A0(1 + r/100)n

where you would substitute the “3” in for r instead of “0.03”.

I said last time that interest can be applied (compounded) more frequently than annually. I will continue this example next time where we do just that.

Financial Maths, Part 3

It is now time to introduce compound interest. The main difference between compound interest and simple interest is that in compound interest, the amount that is used to apply the interest, changes each period. With simple interest, this amount is the initial investment and never changes.

In compound interest, the interest earned from previous periods is added to the initial investment (the principal) before applying the interest for the current period.

Let’s continue with the example of investing $1000 at 3% interest per annum (that is each year). In compound interest, the interest can be applied (compounded) even within a period, but let’s start out simple and apply the interest at the end of each year.

At the end of the first year, the 3% interest is applied to the initial $1000, so we now have $1030 in the bank just like with simple interest. However, things are different at the end of the second year. In simple interest, the interest rate is applied to the initial $1000, but with compound interest the $30 earned after the first year is added to our initial investment so that the principal has changed to be $1030. So after the second year, instead of applying the 3% to $1000, it is now applied to $1030. The following table shows how the investment is growing for the first 5 years:

n P r I An
0 1000 0 0 1000
1 1000 3% 30 1030
2 1030 3% 30.90 1060.90
3 1060.90 3% 31.83 1092.73
4 1092.73 3% 32.78 1125.51
5 1125.51 3% 33.77 1159.28

Notice how the P for a current period is the An of the previous period. Compare this table with the one from my last post which showed the investment growth using simple interest:

n P r I An
0 1000 0 0 1000
1 1000 3% 30 1030
2 1000 3% 30 1060
3 1000 3% 30 1090
4 1000 3% 30 1120
5 1000 3% 30 1150

Looks like it’s better to invest using compound interest. In our example, we have $9.28 more after 5 years.

So what is the recursive formula for this, that is, how do we calculate the current year’s amount if we know last year’s amount?

Starting with A0:

A1 = A0 + A0 × 3/100= $1000 + $30 = $1030
A2 = A1 + A1 × 3/100= $1030 + $30.90 = $1060.90
and so on until
A5 = A4 + A4 × 3/100 = $1125.51 + $33.77 = $1159.28

Again, let’s make this more general. The “3” in the above is the interest rate r. So replacing the “3” with r, we get the general recursion formula:

An+1 = An + An × r/100

or if you use the decimal equivalent of r:

An+1 = An + An × r

This is OK for finding the amount next year, but what if you want to find the amount after 10 years? You do not want to apply this recursion 10 times. In my next post, I will develop a more direct formula.

Financial Maths, Part 2

So I am talking about simple interest. In my last post, I explained how to calculate the interest after the money has been invested for one period – one year in our example. It turns out that by investing $1000 at a simple interest rate of 3%, you earn $30 after one year. This means you have a total of $1000 + $30 = $1030 after one year. What if you want to know what you have after 5 years?

There are two ways of doing this: sequentially or directly. The sequential method has the advantage of showing how your money is growing each period, and the formula is very useful for entering in spreadsheet applications like MS Excel. Let’s first discuss this sequential method.

So after the first year, you have $1030. Each year, the interest rate of 3% is applied to the initial $1000 investment, and you get an additional $30. Below is a table of how the investment grows each year. I will explain the headings and the calculations afterwards:


So according to this table, you will have $1150 after 5 years. So what are the column headings?

The first 4 were defined in my last post, but I’ll repeat them here. n is the period number. It starts at 0 since this indicates when time starts. You only get interest after the money has been invested for 1 period (a year in this case). P is the principal which in this scenario, is the amount originally invested. r is the interest rate. I is the amount of interest earned. From my last post, this is calculated as I = Pr or I = Pr/100, depending if you use the decimal equivalent of r or not (see my last post). An is the total amount you have after n periods. Using a subscript like this is very common in maths. A0 is the initial amount after 0 periods. A1 is the amount after 1 period. A5 is the amount after 5 periods.

I know the table is a bit repeating with the $1000 and the $30 repeated throughout the table, but I did this so you can see the difference between simple interest and the eventual compound interest that I will talk about later.

Notice that the difference between An for each adjacent period is $30, that is, $30 is added to the previous An to get the next period total amount, An+1. So the sequential formula to calculate the next period’s amount is:

An+1 = An + 30

This is called a recursion formula as you recursively calculate the next period’s total amount by knowing the previous period’s amount. So starting with A0:

A1 = A0 + 30 = $1000 + $30 = $1030
A2 = A1 + 30 = $1030 + $30 = $1060
and so on until
A5 = A4 + 30 = $1120 + $30 = $1150

Now let’s generalise this formula for any interest rate. The $30 in the above example is the interest I from the formula I = Pr or I = Pr/100. So the general recurring formula for the total amount of interest in a simple interest investment is:

An+1 = An + Pr (decimal equivalent r) or An+1 = An + Pr/100

That’s all well and good for a spreadsheet formula, but what if you only want to know how much money will you have after 10 years? Do you need to apply this formula 10 times to get the answer? The answer is “no” because we can get a formula that directly calculates an answer.

If you are adding the same amount each year, after 10 years, the total amount added is 10 × the amount after 10 years. So in our example, after 10 years, the total amount is $1000 + 10×30 = 1000 + 300 = $1300. Notice that I will get the same result as in the table above after 5 years: 1000 + 30×5 = 1000 + 150 = $1150. So you just need to multiply the same amount of interest each year by the number of periods desired. In general,

An = P + Prn (decimal equivalent r) or An = P + Prn/100

Next time I will introduce compound interest. But to prepare you for this a bit, notice that I can factor out a P from the above formula to get an equivalent one ( please see my posts on the Distributed Property if you need a review):

An = P(1 + rn) (decimal equivalent r) or An = P(1 +rn/100)

Knowing how to use this form of the equation will help you understand the compound interest formulas.

Financial Maths, Part 1

For some of my students, interest calculations are troublesome: you can say that they quickly lose interest in interest.

If I still have your interest after that bad joke, I will continue. The two main types of interest are simple and compound interest. In simple interest, the principal (the amount initially invested) stays the same and interest is calculated on that amount at all times. In compound interest, the principal grows and the value upon which interest is calculated changes.

I have previously talked about percentages and how to take a percentage of a number. Please review that if you do not know how to take a percentage of a number.

As always, in any new topic, there are some definitions to know so that we understand each other. The following are the main definitions with the abbreviations for them that will be used in equations:

Principal (P): the amount invested or borrowed
Interest rate (r): a percentage to be applied to the principal. This can be a percentage (eg. 15%) or its decimal equivalent (0.15).
Interest (I): the dollar amount which results when the interest rate is applied to the principal
Time (t): the amount of time to be used in a problem
Period: the basic amount of time used by the interest rate. For example, 15% per annum (abbreviated p.a.) means that the period is 1 year.
Number of periods (n): The number of periods to be used in a given problem. Note that equations can be in terms of time (t) or number of periods (n).

Let’s start out with a simple interest situation. Suppose I invest $1000 at a simple interest rate of 3% p.a., that is 3% each year. Though I haven’t asked a question yet, let me identify the key items of this set up:

P = $1000
r = 3% or 0.03
period = 1 year

So my first question is: how much interest do I earn after 1 year? At the end of each year, if I keep that initial amount 0f $1000 in the investment, I will earn 3% of $1000 in interest. If you remember, to take a percentage “of” something, the “of” means to multiply. So after 1 year:

I = 3% × $1000 = (3/100) × 1000 or 0.03 × 1000 = $30

Note that in equations where you can put the interest rate in directly (the “3”), there will be a “/100” part in the equation. In equations where the decimal equivalent of the interest rate (0.03) is to be used, there will be no “/100” part. So the formulas to find the amount of interest (I) earned in 1 period are:

I = Pr/100, if you like to use the interest rate number directly (the “3”)

I = Pr, if you like to use the decimal equivalent of the interest rate (0.03)

This is why you may see different formulas in different books.

In my next post, I will ask some more questions about this investment and provide more formulas.

System of Equations, Part 4

Please read the previous posts on this topic if you do not understand this one.

To illustrate the power of matrices, consider the following system of equations:

w + x + y + z = 5
w + 2xy + 2z = 10
2w – 2xy + 3z = 11
2w + x + y – 3z = 0

This would take a while using the substitution or elimination methods. I will solve this using the matrix method. This system, in matrix form, is:


This system is in the form Ax = b and as shown in my last post, the solution to this is found by pre-multiplying both side by A-1. Now admittedly, finding A-1 manually for a 4 × 4 matrix would take some time. However, taking advantage of the internet (or a modern calculator), I find that


Here I factored out the 1/59 out of each element in the matrix to make it look nicer.

So from my last post, you know that the answer is found by pre-multiplying the b matrix:

Ax = bA-1Ax = A-1bIx = A-1bx = A-1b

So the solution is:


So w = 3, x = 1, y = -1, and z = 2. Isn’t that fantastic!

System of Equations, Part 3

So now that you know about matrices, we can use them to add a third way to solve a system of equations. You will need to read my previous 3 posts on matrices if you are unfamiliar with how to multiply matrices.

In the last post on System of Equations, I looked at the system:

2x + 3y = 51
3x + 2y = 49

And in my last post on Matrices, I showed you how a 2×2 matrix of numbers and a 2×1 matrix of unknowns can be multiplied together to get a 2×1 matrix that looks suspiciously like the left sides of a system of equations. This is , in fact, true. If I form a matrix using the coefficients on the left side of the above system, I get a matrix which I will call A:


Let me now define a matrix x (which is different from the single variable x which is in italics and not bold):


Now I will define a matrix b:


Now see what happens if I multiply A by x:


The rows of this result look just like the left side of our system of equations. And b is the right side. So the matrix equivalent of the system is


This is easy to form directly. You just form A as the matrix of coefficients (with the unknowns in the same order in each equation), x is the matrix of unknowns, and b is the matrix of the numbers on the right sides. So how do we solve this?

From my last post, I defined the inverse of a matrix A as A-1. This is the matrix that if I multiply A by its inverse, I get the identity matrix which is the equivalent of “1” in scalar maths.

The process of isolating (solving) for variables in a matrix equation is exactly the same as for scalar equations: you do the same thing to both sides with the goal of having the unknowns by themselves on one side. So if I pre-multiply (remember, order of multiplication in matrix maths is important) both sides of our matrix equation by A-1, the left side is the identity matrix times x which is equal to just x. The right side multiplies out to form the solution.

As I said before, finding A-1 is beyond the scope of this set of posts. I will just tell you what it is. However, many modern calculators will do this for you, and you can also use the internet and search for “matrix inverse calculator”. It turns out that A-1 is:


So taking the matrix equation and pre-multiply both sides by A-1 gives

A-1Ax = A-1bIx = A-1bx = A-1b

\] \[

Which is the same answer as before, x = 9 and y = 11.

This is a very powerful method for large systems of equations. Next time I will solve a system of 4 equations with 4 unknowns. For those of you who have done this manually, you will appreciate the ease matrix algebra provides.

Matrices, Part 3

In my last post, I multiplied a 2 × 2 matrix by another 2 × 2 matrix. Now let’s multiply a 2 × 2 matrix by a 2 × 1 matrix. If you were paying attention last time, this is possible because the inside dimensions are the same (2= 2) and the resulting matrix will be a 2 × 1 matrix, that is, the outside dimensions.

This is done exactly the same way as illustrated in my last post, only there is only 1 column in the second matrix to multiply with the first matrix:


Now let the second matrix be composed of variables. This does not change the method at all. It just means that the result is a matrix with algebraic expressions:


Please keep this example in mind for my next post when I use matrices to solve a system of equations.

The last skill I need to present is matrix division. When using matrices, you do not actually divide a matrix by another matrix. Rather, you multiply by the inverse of a matrix.

In scalar arithmetic, you can think of dividing a number say 4, by another number, say 2, as multiplying the 4 by the inverse (reciprocal) of 2:


The same thing is done with matrices. However, finding the inverse of a matrix is a little involved and I will not cover that in this set of posts. Rather I will just give you the result when needed. However I will say a few things about the properties of matrix inverses.

In scalar arithmetic, multiplying a number by it’s reciprocal (inverse) equals 1:


The same thing is true with matrices, only what is “1” in the matrix world?

The equivalent “1” for matrices is the Identity Matrix. This is a square (rows = columns) matrix with 1’s down its diagonal and 0’s everywhere else:


This is the identity matrix for a 2 × 2 matrix. The inverse of a matrix is that matrix where multiplying it by the original matrix, results in the identity matrix. The inverse of a matrix A, is denoted as A-1.

\] \[

And it turns out that when multiplying a matrix by its inverse, order does not matter: A × A-1 = A-1 × A.

In my next post, I will put all this talk about matrices in practice and use them to solve a system of equations.