2 Notation
The ideas which are here expressed so laboriously are extremely simple …. The difficulty lies, not in the new ideas, but in escaping from the old ones, which [branch]1, for those brought up as most of us have been, into every corner of our minds. — John Maynard Keynes The General Theory of Employment, Interest, and Money, 1936
This chapter introduces more of the notation we will use for mathematics and for computing.
Good use of notation should make the writer’s intent clear to the reader. In our study of calculus, each component of notation will refer to a mathematical object of some kind. Consequently, the notation should, on its own, indicate the kind of object.
In the previous chapter, we described three different kinds of objects: functions, quantities, and spaces. We introduced mathematical and computer notation to make clear what is the name of a function and the names of inputs. In this chapter, we will introduce constants, parameters, and special inputs. We will see how input names, like
Notation (noun): a series or system of written symbols used to represent numbers, amounts, or elements in something such as music or mathematics. –Oxford Dictionaries
It makes obvious sense to use a mathematical notation with which you are already familiar. We will supplement this notation with simple rules for naming, intended to make it clear just from the name what kind of mathematical object is being named.
Chapter ?sec-computing-with-R introduces computing with the R language.
Since you will be using computing extensively, it will pay to be aware of when the the way you are used to writing mathematical statements conflicts with the requirements of computing.
Traditional mathematical notation makes extensive use of spatial arrangement, as for instance in
or or . For those familiar with it, this notation can be both concise and beautiful. But it was developed in an era of parchment and pen, without any inkling of keyboards and the strictly linear sequence of characters so widely used in written communication. Most mainstream computer languages are based on keyboard input.Traditional mathematical notation was developed for communicating between people and, like everyday language, has gaps and ambiguities that get sorted out (not always correctly) by human common sense. Computer languages, on the other hand, need to be precise and unambiguous so they can be interpreted by machines.
We will attempt to use mathematical notation in a way that limits the conflict between tradition and computer notation. This conflict is particularly acute when it comes to the idea of an “equation,” so widely used in high-school mathematics but not a component of mainstream computer languages.
2.1 Functions, inputs, parameters
Our style of notation will be to give functions and their inputs explicit names. The basic principle is that a function name is a sequence of letters followed by an empty pair of parentheses, for instance,
When we come to introduce computer notation in Section 3.3, you will see that function definition is done in a somewhat different manner. Why? We need to work within the syntax and grammar of the computer language. We will be using the R language, but other mainstream computer languages would impose similar requirements.
As you saw in Chapter Chapter 1, our notation for defining a function includes the names of the parameters. In our mathematical notation, both the name of the function and the names of the inputs are shown on the left-hand side of the
A sensible person will define a function because they are planning to use it later on, perhaps multiple times. “Using” a function might mean including it in the formula in the definition of another function. But there is also a more specific sense of “using” to which we need to give a precise name. To apply a function means providing specific input quantities so that the output of the function can be calculated. An equivalent phrase is evaluate a function on an input(s). For instance, to apply the function
Remember that
Distinguish carefully between the definition of a function, say,
The right-hand side of a function definition is a formula. The formula specifies how each of the inputs will get used in a computation of the function output. When a function has more than one input, the input names serve to indicate where each input goes in the formula defining the calculation. For instance:
2.1.1 Input names
You may notice that we use the function names
To simplify identifying function definitions, we tend to use a small set of names for inputs:
or or . . This name is typically used when the input is meant to be time.- Less frequently,
, , when the other arguments are already in use.
In modeling, to make clearer the relationship of functions and the real-world setting, it is a good idea to use more descriptive names, like
In everyday speech, an “argument” is a discussion between people with differing views. But in mathematics and computing, argument means something else entirely: it is a synonym for “input to a function.”
Often, the functions we define will have formulas that include quantities other than the inputs. For instance, we might define:
This definition explicitly identifies
There is an argument to be made for identifying as inputs to the function all quantities needed for evaluating the function. In this style, the function would be defined as
In writing mathematical notation for the human reader, there is a tradition of distinguishing between quantities that will differ from one evaluation to another and quantities that will be the same each time the function is evaluated. These later quantities are called parameters.
In reading a definition such as
the named quantities that are not listed inside the parentheses on the left-hand side of the definition—
There is no absolute rule for identifying a named quantity used in a function’s formula as a parameter rather than as an input. It is a matter of style and the conventions of the field in which you’re working. When we get to the computer notation for defining functions, you will see that we simplify things by considering all named quantities used in a function formula as inputs.
A pendulum is a device that swings back and forth from a fixed pivot. The period of a pendulum is the time it takes to go through one complete cycle of motion—one “back” and one “forth.” It happens that it is simple to compute the period of a pendulum,
We could have written the function as
Of course, you might be the kind of person who puts pendula in elevators or on Mars. If so, you would need to use a different value for
You will see much more use of parameters in Block ?sec-modeling-part when we use parameters to “fit” functions to data.
2.1.2 Parameter names
To make it easy to recognize parameters, we will use names like
Pronounce names
But there will be occasions where we need to compare two or more functions and run out of appropriate names from the start of the alphabet. A way to keep things organized is to use subscripts on the letters, for instance comparing
to
The tradition of using letters from the start of the alphabet as parameter names dates from the time of Isaac Newton.
Professional models often use Greek letters as parameter names:
2.1.3 Functions without names
Traditional mathematical notation writes many functions both without a name and without the parentheses. Examples that you have likely seen are
Sometimes we will use names like square() just to emphasize the point that we are talking about a function. But, for the most part, we will stick to the traditional form because it is ubiquitous and recognizable by most readers.
The name/parentheses notation, like exp() or sin() allows us to avoid having to write
2.2 Special inputs
We will create functions as models of a real-world situation. Once created, we generally have to extract information from the function that informs the real-world choice, decision, or understanding that we need to make or develop.
There are many forms that the extracted information will take, depending on circumstance. With surprising frequency, two types of information turn out to be useful:
- The set of inputs that produces a maximum or minimum output.
- Inputs that produce a specific output.
We will call these special inputs and will study the techniques for determining them later in the book. For now, though, focus on the notation we will use so that you can spot when a special input is being used.
As we’ve stated before, the names of inputs will tend to be letters from the back of the alphabet:
2.3 Drill
Drill 1 Which of these is the symbol for “is defined as”?
Drill 2 What is the name of the function defined by
Drill 3 How do we refer to the output generated by applying
Drill 4 Using our notation conventions from the textbook, which one of the following kinds of things is
A constant A function name An input name
Drill 5 Using our notation conventions from the textbook, which one of the following kinds of things is
A constant A function name An input name
Drill 6 Using our notation conventions from the textbook, which one of the following kinds of things is
A constant A function name An input name
Drill 7 Using our notation conventions from the textbook, which one of the following kinds of things is
A constant A function name An input name
Drill 8 Using our notation conventions from the textbook, which one of the following kinds of things is
A constant A function name An input name
Drill 9 Can function names be multiple letters, e.g. g3()
or altitude()
?
Yes No
Drill 10 In the book, will input names have subscripts, like
Yes No
Drill 11 In the book, what is meant by the word “variable”?
- it is the same as output.
- it is the same as input.
- A column in a data table.
Drill 12 What is the name of the function being defined in
a b x
Drill 13 What is the name of the input to the function being defined in
a b x
Drill 14 What is wrong with this function definition?
- You cannot name a function “dorothy.”
- “kansas” is a US state, not the name of an argument.
- “dorothy” and “kansas” should be capitalized.
- Auntie Em is a person, not a number.
- Nothing.
Drill 15 What’s wrong with this function definition?
- No input has been given to
. - ‘electric()’ should have been written as E().
- Nothing
Drill 16 You are modeling the population of E. coli growing in optimal conditions. (Optimal for the E. coli, not for you!) In R, you’ve written population <- makeFun(100*exp(hours) ~ hours)
What’s the correct definition in traditional notation?
- None of the above.
Drill 17 In traditional notation, Celsius()
. This of the following correctly defines that function in R?
Celsius <- makeFun(5*(Fahrenheit-32)/9 ~ Fahrenheit)
Celsius <- makeFun(5/9*Fahrenheit - 32 ~ Fahrenheit)
Celsius() <- makeFun(5*(Fahrenheit-32)/9 ~ Fahrenheit)
Celsius(Fahrenheit) <- makeFun(5*(Fahrenheit-32)/9 ~ Fahrenheit)
Celsius(Fahrenheit) <- makeFun(5*(Fahrenheit-32)/9)
Drill 18 Which of these does the symbol
- a function name
- an input to a function
- the output from a function
- it is nonsense
- a constant
Drill 19 Given the definition
- the function name
- the input to the function
- the output from the function
- it is nonsense
- a constant
Drill 20 Given the definition
- the function name
- the input to the function
- the output from the function
- it is nonsense
- a constant
Drill 21 Given the definition
- the function name
- the input to the function
- the output from the function
- it is nonsense
- a constant
Drill 22 Given the definition
- the function name
- the input to the function
- the output from the function
- it is nonsense
- a constant
Drill 23 In the definition
- the function name
- the input to the function
- the output from the function
- it is nonsense
- a constant
Drill 24 In the definition
- the function name
- the input to the function
- the output from the function
- it is nonsense
- a constant
Drill 25 Can function names have subscripts or superscripts, like
Yes No
2.4 Exercises
Exercise 2.01
Use the MOSAIC Calculus naming conventions to answer these questions.
Part A What is
- The name of a function
- The name of an input.
- A specific numerical value
Part B How come we write
- No good reason
- It is a reminder that we are talking about a function with the name “
”. - The parentheses are part of the name.
Part C What sort of thing is denoted by
- A particular numerical value
- The name of an input
Part D Which of these symbols might stand for the entire domain of a function?
Part E Suppose you come across
is the name of a function and is the name of the input to that function.- It is meaningless.
- It is the same thing as
.
Part F Are
- Yes, although that function is being given two different names.
- Of course not!
Exercise 2.02
Keeping in mind the notation style we use in MOSAIC Calculus, which of these things is a function? Which a number?
Part A What kind of a thing is
A function A number
Part B What kind of a thing is
A number A function
Part C What kind of a thing is
A function A number
Part D What kind of a thing is
- A number
- The name of an input to a function.
- A function
Exercise 2.03
The following traditional-style notation is intended to define a function that is 2 times the pattern-book sinusoid. But something is wrong.
Part A What’s wrong with the definition?
isn’t an appropriate name- The formula should be written
is not a good choice for the input name.- The input name in the formula does not match the input name on the left side of
.
Exercise 2.04
Consider this expression in math notation:
Part A Which of the following R expressions implements the math-notation expression?
k exp(kt)
e^k*t / k
exp(k t) / k
exp(k*t) / k
1/k e^kt
Exercise 2.05
Suppose you want to define a straight-line function named
Part A What’s wrong with f <- m*x + b
- Need to use
makeFun()
to define a function. m
is not defined.b
is not defined.- Should be
y <- m*x + b
.
Part B What’s wrong with f <- makeFun(m*x + b)
- The first argument to
makeFun()
should be a tilde expression. m
is not defined.b
is not defined.makeFun()
requires two inputs.
Part C What’s wrong with f <- makeFun(x ~ m*x + b)
- The tilde expression should have the input name on the right-hand side of the
~
. m
is not defined.b
is not defined.- The first argument is not a tilde expression.
Part D What’s wrong with f <- makeFun(mx + b ~ x)
- The tilde expression is missing the multiplication operator
*
betweenm
andx
m
is not defined.b
is not defined.- The name
f
is mis-spelled.
Part E What’s wrong with f <- makeFun(b*x + m ~ x)
- The roles of
m
andb
have been reversed. m
is not defined.b
is not defined.x
is not defined.
Exercise 2.06
Paste these two lines into your R console:
<- 2
x sin(x)*sqrt(x)
In the following questions, numbers have been rounded to two or three significant digits. Select the answer closest to the computer output.
Part A Change
-1.51 0.244 0.84 0.99 2.14 NaN
Part B Change
-1.51 0.244 0.84 0.99 2.14 NaN
Part C Change
-1.51 0.244 0.84 0.99 2.14 NaN
In the sandbox, change the formula from
Part D For
-1.51 0.244 0.84 0.99 2.14 NaN
Exercise 2.07
Using the R console, translate each of the following mathematical expressions into R to calculate the numerical value of the expression. Write down the both the R expression and the numerical value produced by R.
Exercise 2.08
Each of these attempts to define a mathematical function using R leads to an error message. Modify each statement to work properly.
f(x) <- makeFun(2*x + 3 ~ x)
h <- makeFun(x ~ 2*x + 3)
f <- makeFun(2x + 3)
g(x) <- makeFun(4 sin(x))
h2 <- 2*x + 3 ~ x
g2 <- makeFun(2*x + 3 ~ y)
p(x,y) <- makeFun(2 x + 3 y ~ x & y)
Original word: “ramify”↩︎