Piecewise Functions

I have discussed functions before but I assumed nice continuous functions in the discussion. This is OK since most functions encountered in mathematics are of this type. But there are not so well-behaved functions called piecewise functions. These are also called hybrid functions in some textbooks, but I think piecewise is a bit more descriptive.

These kinds of functions are used in many areas of mathematics, engineering, science, and finance: pricing strategies, taxation, electric field modelling, imaging, computer science, digital art, aircraft design. This is why it is covered in high school maths.

So what is a piecewise function? As the name implies, it is a function that is defined differently over different intervals (pieces) of its independent variable (usually x). Here is an example:

So this function is −1 if the x used to evaluate this function is less than 0 (all negative numbers), it is the square root of x, if x is greater than or equal to 0 but strictly less that 2, and it is 3 if x is greater than or equal to 2. The plot of this function looks like

You can clearly see that the form of the function changes depending on where you are on the x-axis. Here’s another example

The graph of this function is

When working with this function, you would have to split the problem into parts. For example, given this function, solve f(x) = 5. You can use the graph to see that the solution will be in the third part of the function. But if you didn’t have this graph to guide you, how would you solve that algebraically?

You would set each part of the function equal to 5 and solve. If the answer is in the part of the x-axis where that function part is defined, then that is a solution. If not, then it is not a solution. For this example, first solve x3 = 5. The answer is x ≈ 1.71 (≈ means “approximately). Since 1.71 is not less than 0 where the x3 part is defined, this is not an answer.

Now solve x2 = 5, The answer is x ≈ ± 2.24. There are two answers here but neither is greater than 0 and less than 2. Finally try x/2 + 3 = 5. The answer is x = 4 which is greater than 2 so that is our answer.

In calculus, there are definitions for continuity and differentiability (smoothness) of a function. For those not familiar with calculus, you would probably say that the above graph is continuous as you could draw it without lifting your pencil off the paper. And you would be correct. But is the above graph smooth where the different parts of the function join? It turns out, using a process called limits, the curve is smooth at the origin, but not at the point (2, 4). This probably makes sense to you as there is a corner at that point and there would be a sharp change in direction a pencil would take at that point. I will talk about what limits are in my next post.

Transformations 4

Let’s do a couple of examples using the knowledge from my last 3 posts and show how the order of transformations make a difference.

The image of the equation that follows will be generated by the following transformations:

a. Dilate along y-axis by factor 1/2
b. Reflect along y-axis (across x-axis)
c. Dilate along x-axis by factor 3
d. Translate along x-axis +4 units
e. Translate along y-axis -2 units

\[y=\sqrt{3x-4}\]

In the previous post, I showed that given an equation y = f(x), its image under a general transformation is given by

\[f(x)\Rightarrow af\left[\frac{1}{n}(x-h)\right]+k\]

where
a = dilation\reflection factor along y-axis (from x-axis)
n = dilation\reflection factor along x-axis (from y-axis)
h = translation along x-axis
k = translation along y-axis

This assumes that dilations/reflections are done first. So if

\[f(x)=\sqrt{3x-4}\]

then

\[f(x)\Rightarrow af\left[\frac{1}{n}(x-h)\right]+k=-\frac{1}{2}\sqrt{3\left [ \frac{1}{3}(x-4)\right]-4}-2\]

This can be simplified to

\[y=-\frac{1}{2}\sqrt{ x-8}-2\]

In this form, the pre-image (the equation that this one came from before the transformation) is lost. The question could be asked, what are the transformations required to go from

\[y=-\frac{1}{2}\sqrt{ x-8}-2\Rightarrow y=\sqrt{3x-4}\]

One would expect that if we just do the opposite of the transformations above, we would get the original equation. Let’s see. Let’s do the following:

a. Dilate along y-axis by factor 2
b. Reflect along y-axis (across x-axis)
c. Dilate along x-axis by factor 1/3
d. Translate along x-axis -4 units
e. Translate along y-axis +2 units

These undo the previous transformations. Putting these in our model

\[f(x)\Rightarrow af\left[\frac{1}{n}(x-h)\right]+k\]

We get

\[f(x)\Rightarrow -2f\left[3(x+4)\right]+2=\sqrt{3(x+4)-8}+4+2=\sqrt{3x+4}+6\]

Not exactly what we wanted. What went wrong? Well, the model we used assumes that dilations go first. If we want to undo the previous transformations, not only do we use the values we just used, but they must be applied in reverse order as well: the translations go first then the dilations/reflections. Otherwise the dilations affect the translations before they are applied.

I’ll leave this as an exercise for the reader, but the model for transforming y = f(x) assuming that translations go first is

\[y=af\left( \frac{x}{n}-h \right)+ak\]

So undoing the original transformations in reverse order:

a. Translate along y-axis +2 units
b. Translate along x-axis -4 units
c. Dilate along x-axis by factor 1/3
d. Reflect along y-axis (across x-axis)
e. Dilate along y-axis by factor 2

gives the result

\[f(x)\Rightarrow -\frac{1}{2}f\left(3x+4\right)\Rightarrow-\frac{1}{2}\sqrt{3x+4-8}-2+2\Rightarrow\sqrt{3x-4}\]

which is the original equation.

So the order of transformations steps will change the final result.

I hope this series of posts helps you better understand transformations.

Transformations 3

In my last post, I took a general point (x,y) and through the series of transformations:

A. (x,y)
B. Dilate/reflect by factor a along y-axis
C. Dilate/reflect by factor n along x-axis
D. Translate k units along y-axis
E. Translate h units along x-axis

the point was changed to:

A(xy) —-> B(xay) —-> C(nxay) —-> D(nxay+k) —->
E(nx+hay+k).

Now let’s restrict the original point to be one that satisfies the equation y = x2. How does this equation change so that all of its points are transformed correctly?

Think of the transformation process as changing old points to new ones. So the old points, (xy), are changed to the new points (nx+hay+k) = (x‘, y‘), where the apostrophe ‘ is used to distinguish the new x‘s and the new y‘s from the old ones. So under this transformation, x‘ = nx+h and y‘ = ay+k.

Now the equation y = x2 is the equation that the old points satisfy. To find the equation that the new points satisfy, we need to find what the old variables are in terms of the new ones. Solving for the old x and y in the above equations, we get

\[x’=nx+ h\Longrightarrow x = \frac{1}{n}\left(x’-h\right)\]
\[y’=ay+ k\Longrightarrow y = \frac{1}{a}\left(y’-k\right)\]

If we replace the old variables in the equation with the right side of the above equations, then we will get an equation with the new variables, which can be cleaned up with a little algebra:

\[\frac{1}{a}(y’-k)=\left[\frac{1}{n}(x’-h)\right]^2\Longrightarrow y’=a\left[\frac{1}{n}(x’-h)\right]^2+k\]

Now that we have the new equation, we don’t need the ‘ anymore. So the new equation is:

\[y=a\left[\frac{1}{n}(x-h)\right]^2+k\]

Notice that if we were given this new equation and were asked, “what are the transformations that generated this equation from y = x2 ?”, then we can pick off the dilations and the translations. Be aware though, that we must assume that the dilations occurred first. Textbooks will tell you this to keep answers consistent. With this caution, if a = 2, n = 3, h =-5, and k =4, then the new equation would be

\[y=2\left[\frac{1}{3}(x+5)\right]^2+4\]

The graph below shows the effect of these transformations on the original curve:

So given a set of transformations, the steps that I did above for the particular equation y = x2, can be done for any equation.

What if the problem is reversed: given the end result, what is the set of transformations that created the new equation from and original one? Using functional notation, notice that:

\[f(x)={x}^{2}\Longrightarrow af\left[\frac{1}{n}(x-h)\right]+k=2{\left[\frac{1}{3}(x+5)\right]}^{2}+4\]

If you were given this final result, you can pick off the dilations along both axes (These are assumed to be first) and the translations along both axes. If either the a and/or the n were negative, then there would be reflections as well.

Transformations 2

In my last post, I took specific points and transformed them using dilations/reflections and translations. The goal is to transform an equation into a new equation. But before we get there, let’s again look at a single point. But this time, this will be a general point (x, y).

So starting with general point A(x, y), let’s do the same transformation as I did in my last post:

A. (x,y)
B. Dilate by factor 2 along y-axis
C. Dilate by factor 1/3 along x-axis
D. Reflect across x-axis
E. Reflect across y-axis
F. Translate 3 units up
G. Translate 3 units to the left

In this order, the new transformed points become:

A(x, y) —-> B(x, 2y) —-> C(x/3, 2y) —-> D(x/3, -2y) —->
E(-x/3, -2y) —-> F(-x/3, -2y+3) —-> G(-x/3-3, -2y+3)

From my last post, if you use the particular point A(3,1), and use these values in the result above, you get the same point G(-4,1).

This can be generalised more by using letters to represent the dilation factors and the translation amounts:

a = dilation/reflection factor along y axis
n = dilation/reflection factor along x axis
h = translation along x axis
k = translation along y axis

Note that I have combined dilations and reflections. This is because a reflection can be viewed as a negative dilation. If a is negative, then this is a reflection along the y axis (across the x axis) as well as a dilation. If n is negative, then this is a reflection along the x axis (across the y axis) as well as a dilation. This does slightly restrict the flexibility of transformations as we cannot separate the order of a dilation and a reflection, but for most problems, this is not an issue. Also, if h is negative, that is a translation to the left. If k is negative, that is a translation down.

Now I’ll apply this to the same set of transformations as above except that I will combine the dilation and reflection steps:

A. (x,y)
B. Dilate/reflect by factor a along y-axis
C. Dilate/reflect by factor n along x-axis
D. Translate k units along y-axis
E. Translate h units along x-axis

This leads to the new point:

A(x, y) —-> B(x, ay) —-> C(nx, ay) —-> D(nx, ay+k) —->
E(nx+h, ay+k)

If these transformations are reversed:

A. (x,y)
B. Translate h units along x-axis
C. Translate k units along y-axis
D. Dilate/reflect by factor n along x-axis
E. Dilate/reflect by factor a along y-axis

you get the new point:

A(x, y) —-> B(x+h, y) —-> C(x+h, y+k) —-> D[n(x+h), y+k] —->
E[n(x+h), a(y+k)]

This is different and you will generally get a different ending point for a specific point and transformation values.

Some terminology is needed here. We have an original point (x,y) and then under a set of transformations, a new point is created. In our first set of transformations, this new point was (nx+h, ay+k). Point (nx+h, ay+k) is the image of (x,y) under this transformation. Or (x,y) is the pre-image of (nx+h, ay+k).

It may help to think of this as a black box where (x,y) enters and is magically transformed to (nx+h, ay+k). Though we know it is not magic at all but just maths:

As mentioned, the goal here is to transform a set of points, usually defined by an equation, to a new set (new equation). The above mental image (pun intended) will help keep in focus what is being done.

In my next post, I will transform equations and show how that is done.

Transformations 1

From my experience teaching mathematics, I think that the topic most students find the most difficult is circular functions (trigonometry). The next most difficult topic is transformations: transforming a function to another via dilations, reflections, and translations. This is the first of several posts to address this topic.

First, by way of looking at individual points in a Cartesian coordinate system, let’s do some transformations and define some terms.

Consider the following points A, B, C, and D:

The first transformation will be to dilate these points. This means that we will change their distance from the x or y axes by multiplying the appropriate coordinate by a number. This number is called the dilation factor. If we dilate along the x-axis, we will change the x coordinate of each point by multiplying it by the dilation factor. Be aware that this is also called “dilating from the y-axis” because this dilation changes the point’s distance from the y-axis

So let’s dilate these points along the x-axis by a factor of 2. This makes each point twice as far from the y-axis. So point A becomes A1(6,1), B becomes B1(-4,3), C becomes C1(-8,-1), and D becomes D1(2,-2):

Dilation of factor 2 along x-axis

If we had used a factor of 1/2, then the new points would be half the distance from the y-axis than the original points.

If the factor we use is negative, not only is the dilation happening, but the points are also reflected across the y-axis. So if the dilation factor is -2 along the x-axis, the new points are A1(-6,1), B1(4,3), C1(8,-1), and D1(-2,-2):

Dilation and reflection
of factor -2 along x-axis

Another transformation is translation: moving a point left or right or up or down. So if you translate a point 3 units to the right (along the x-axis), then the new points are A1(6,1), B1(1,3), C1(-1,-1), and D1(4,-2):

Translation 3 units to right (+x directions)

Now all of these transformations can be done along the y-axis (from the x-axis) as well. So doing all transformations along the y-axis, I will dilate point A by a factor of 2, reflect point B with no dilation, translate point C up 3 units, and dilate point D by a factor of 1/2. The new points will then be A1(3,2), B1(-2,-3), C1(-4,2), and D1(1,-1):

Transformations along y-axis

The previous example just changed the x or the y coordinate of each point. Let’s look at point A and mix up these transformations. This will also show that the order of the transformations can affect the final result. Consider the following sequence of transformations of point A:

A. (3,1)
B. Dilate by factor 2 along y-axis
C. Dilate by factor 1/3 along x-axis
D. Reflect across x-axis
E. Reflect across y-axis
F. Translate 3 units up
G. Translate 3 units to the left

The following graph shows the sequence of these transformations .The new point’s letter refer to the result of the transformation’s letter above:

Now let’s do the previous steps in reverse:

A. (3,1)
B. Translate 3 units to the left
C. Translate 3 units up
D. Reflect across y-axis
E. Reflect across x-axis
F. Dilate by factor 1/3 along x-axis
G. Dilate by factor 2 along y-axis

We end up at a very different place. Also notice that if a point is on the y-axis, reflections across the y-axis and dilations along the x-axis, have no effect.

I will generalise this for a generic point (x,y) in my next post.

Graphing Circular Functions

The following file is for year 12 students covering trigonometric functions sine and cosine. It presents an orderly method to graph functions of the form:

f(x) = a sin[n(xh)] + k, x₁ ≤ xx₂ or f(x) = a cos[n(xh)] + k, x₁ ≤ xx₂. It assumes knowledge of trig functions (or circular functions) and how to use the unit circle.

Word Problems – 7

This one is a year 12 problem involving calculus.

A company initially provides a service to 1000 customers for $5 per month. The marketing department says that for every 10¢ reduction in price, they could get 100 more customers. What price would give the company the maximum revenue per month and what would that revenue be?

Let’s let x be the monthly price for the service. Then the revenue, R(x), would be x times the number of customers. The number of customers is the initial 1000 plus 100 times the number of 10¢ increments below $5 that is charged. The number of 10¢ increments below $5 is (5 – x)/0.1, so the revenue is

\[R\left(x\right)=x\left[1000+100\frac{\left(5-x\right)}{0.1}\right]=x\left[1000+1000\left(5-x\right)\right]\]
\[=1000\left(6x-x^2\right)\]

Looking at this function, you can recognise that this is an upside down parabola because of the minus sign in front of the x² term. So the maximum would be at the top of the parabola. This makes sense because there is a balancing act going on between a lot of customers and too low a price. The revenue will rise until the price is too low to increase the revenue. To find that point that is the maximum revenue, we need to find the derivative of R(x) and set that equal to 0, that is find the stationary point that is the top of the parabola.

\[R’\left(x\right)=1000\left(6-2x\right)=0\]
\[\Longrightarrow\ x=3\]

So the price that maximises revenue is $3, and R(3) = $9000. The number of customers is 1000 + 1000(2) = 3000.

Word Problems – 6

Now on to a trig (circular functions) problem. This problem requires that you have covered year 11 trigonometry (called circular functions in some texts).

The water depth in a harbour on a particular day is modelled by the following equation:

\[D\left(t\right)=10+3\mathrm{sin}\left(\frac{\pi t}{6}\right),0≤t≤24\]

where

D(t) = depth of water
t = hours after midnight limited to be between 0 and 24 hours

A ship has to have at least 8.5 meters of water depth to use the harbour. At what times can the ship safely dock at the harbour?

Solving this algebraically, let’s first find the times when D(t) = 8.5.

\[10+3\mathrm{sin}\left(\frac{\mathrm{\pi\ t}}{\mathrm{6}}\right)=8.5\Longrightarrow\mathrm{sin}\left(\frac{\mathrm{\pi t} }{\mathrm{6}}\right)=-0.5\]

So we have the requirement that the sine of “something” has to equal -0.5. When we take a function of something, that something is called the argument of the function. From a table of common sines and knowing that sin(-????) = -sin(????), we get that ????t/6 = -????/6 ⟹ t = -1. We need another angle on the unit circle that has a sine of -0.5:

So ????t/6=7????/6 ⟹ t = 7. The period of this sine function is

\[\mathrm{Period}\ =\frac{2\pi}{\frac{\pi}{6}}=12\]

Now we add this period to our two core values of t, until we get t > 24:

7 + 12 = 19
-1 + 12 = 11
11 + 12 = 23

So the t values we have that are between 0 and 24 are 7, 11, 19, 23. As the sine function initially increase from 0, the value of t = 7, which is 7 AM, is when the depth is decreasing and is below 8.5 meters. The depth is increasing and above 8.5 at t = 11 which is 11 AM. The depth then decreases below 8.5 at t = 19 which is 7 PM and rises above 8.5 at t = 19 which is 11 PM. So the ship can dock between midnight and 7 AM or between 11 AM and 7 PM or between 11 PM and the following midnight.

I’ve plotted D(t) and the line D(t) = 8.5 to show these solutions.

In fact, doing a rough sketch of this function would help get a feel for the answers before we begin.

We do this by raising the standard sine curve up 10 units and draw 2 cycles from 0 to 24 since we can calculate that the period is 12 hours. Since the sine of anything goes from -1 to +1, the minimums are at 10 – 3 = 7 and the maximums are at 10 + 3 = 13. Drawing a line at D(t) = 8.5, we can see that we should get 4 points that will divide the intervals where the depth is below or above 8.5 meters. Once we have the points at D(t) = 8.5, we can easily see the periods where the depth is above 8.5 meters.

Word Problems – 5

Carbon Dating

This one is about carbon dating. I find it fascinating that someone figured out this ingenious method to determine the age of once living things. This person was Willard Libby, a physicist and chemist who proposed this method in 1946.

Before I get to the word problem, let’s go through an explanation on how and why carbon dating works.

Life on earth is carbon-based, which means that its chemistry is based on carbon atoms. Living things ingest, breath in, grow from molecules which mostly include carbon atoms. But carbon atoms come in several isotope forms which means that the number of neutrons in its nucleus varies. Carbon 12 (6 protons and 6 neutrons), is the primary isotope (98.89% of all carbon). Carbon 13 (6 protons and 7 neutrons) is next at 1.11%. Both of these isotopes are stable, that is, they are not radioactive and break down into other elements. A trace amount of earth’s carbon is carbon 14 (6 protons and 8 neutrons). This isotope is radioactive. It is created mainly from the cosmic ray bombardment in earth’s upper atmosphere.

Though the percentage has varied in the past (and this is taken into consideration when very accurate results are required), it is a good approximation to assume that the percentage of carbon 14 has remained constant while life has been on earth. And this percentage remains constant in a living thing while it is alive. However, once it dies, the carbon in it is no longer being refreshed and the carbon 14 in it decays away. When a bone or any other object that was once living is found, measuring the remaining carbon 14 in it can be used to estimate its age.

Exponential Decay

Radioactive materials have a half life. The half life of a radioactive material is the time it takes for half of an original amount to remain. The amount left of a radioactive material is modelled as an exponential decay:

\[A=A_0e^{kt}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (1)\]

where

A = the amount of material left after t units

A0 = the original amount of material at time 0

e = an irrational number used frequently in science and engineering. e is approximately 2.71828

k = is a negative number (for exponential decay problems) that relates to the half life of a material and the units used for t

t = time in specified units. In our case, the units are years.

The Word Problem

The half life of carbon 14 is 5730 years. A bone found at an excavation site is found to have 30% of the carbon 14 it would have contained when it died. Approximately, how old is the bone?

The Solution

There doesn’t appear to be a lot of information here, but there is enough. Given the exponential decay equation (1), we have a lot of unknowns here: the original amount, the amount now, the parameter k, and of course, the answer to the question, t. But the first sentence is enough to solve for k.

If there is half of the original amount after 5730 years , then from equation (1):

\[0.5A_0=A_0e^{5730k}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(2\right)\]

If you divide both side by A0, then the equation becomes:

\[0.5=e^{5730k}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(3\right)\]

This can be solved using logarithms, with a CAS calculator, or our all knowing internet. Solving this, we get k = −0.00012. Isn’t it interesting that we do not need to know the original amount to get this far?

Now that we know k, we can answer the question. Using the same trick as before, if there is only 30% carbon 14 left, then:

\[0.3A_0={A_0e}^{−0.00012t}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \left(4\right)\]

The A0 again cancels out and solving this we get t = 9953 years.

That’s old. No bones about it!

Word Problems – 4

Continuing this series on word problems, let’s look at one that many year 11 or 12 students have seen if they have covered calculus. The first part of the question though, does not need calculus:

A 6 by 8 cm rectangular piece of metal has a square cut out of each corner:

The metal is then folded along the dashed lines to form a box of height x.

a) What is the volume of the box in terms of x?

b) What is the maximum volume the box can have and at what value of x does the maximum occur?

Let’s first redraw the rectangle, labelling what we know. If the height of the box is to be x, then that is the size of the cutout square. If an x is subtracted from each end of each side, then the length of each of the dotted lines (the base of the future box) is 6 – 2x and 8 – 2x:

After the metal is folded, we have a box like:

So to answer part a), the volume is height × length × width. So

V = x(8 – 2x)(6 – 2x)

For part b), we need a little calculus. But before we do that, just to get a mental image of what is going on (this is not needed to solve the problem though), let’s plot V as a function of x:

Notice that the volume is 0 at x = 0 and x = 3. This makes physical sense because when x = 0, there is no square cut out and the box would just be a flat sheet. If x = 3, there would be nothing left of the original 6 cm side and the two remaining flaps would just fold up against each other giving no volume. So the physical restriction on x here is 0 ≤ x ≤ 3.

The maximum volume then occurs at the peak of the curve between 0 and 3. To find what and where this maximum is, requires calculus, specifically finding a local maximum (a stationary point).

To find this point, let’s first expand the expression for V:

V = x(8 – 2x)(6 – 2x) = 4x3 – 28x2 + 48x

For the uninitiated, derivatives of a function give the gradients of lines tangent (that is just touching at one point) to it. At the maximum, the tangent line is horizontal which has a gradient of 0. So to find this, we find the derivative of our volume function and set that equal to zero and solve for x.

For those who have had calculus and know how to find derivatives of a polynomial function (like we have here):

V′ = 12x2 – 56x + 48 = 4(3x2 – 14x + 12)

So now we find the values of x where the derivative is 0:

V′ = 4(3x2 – 14x + 12) = 0 ⟹ x = 1.1315, 3.5352

To get that answer, the quadratic formula can be used. Or, if lazy like me, an equation solver on the internet.

We want the value between 0 and 3. So a square of sides 1.1315 cm will maximise the volume. The other value of x is where the minimum point is as seen in the plot. We find the maximum volume by putting x = 1.1315 in the original V function:

V(1.1315) = 4(1.1315)3 – 28(1.1315)2 + 48(1.1315) = 24.258 cm3

As before, drawing pictures gets you started.