3 | FUNCTIONS
3 | FUNCTIONS
This chapter of Single Variable Calculus by Dr JH Klopper is licensed under an Attribution-NonCommercial-NoDerivatives 4.0 International Licence available at http://creativecommons.org/licenses/by-nc-nd/4.0/?ref=chooser-v1 .
3.1 Introduction
3.1 Introduction
In this third chapter we consider single variable functions. Functions in a single variable take an input value for the variable, which is usually symbolized by an or a , and calculates an output value, usually denoted by the symbol . In this textbook, we define functions such that both input and output values as real numbers.
x
t
y
Definition 3.1.1 A function is a map from the real numbers (input) to the real numbers (output). We write such that for the variables and we have that , where and is the single input variable and is the output value.
f
f:->
x∈
y∈
f:x↦f(x)
y=f(x)
x
y
The values for the input and output are sometimes constrained to a subset of the real numbers. In the function , we have that , whereas can be any real number.
f(x)
2
x
y≥0
x
We define three important terms with respect to function values. These are the domain, codomain, and the range. The terms are defined below.
Definition 3.1.2 The domain of a function is the interval(s) of the real numbers for the input values .
f
x
In most cases we have that the domain of a single variable function is . We can, however, state a specific domain. In this textbook, we will often define the domain, especially when we create a graph of a function.
x∈
Definition 3.1.3 The codomain of a function is the set of all possible values that the output can take, whether or not the output actually takes on that value.
f
Definition 3.1.4 The range of a function is the set of actual values that the output takes.
f
The function has the set of all real numbers as the domain. The codomain is also the real numbers. Note, however, that the output has the range .
f(x)=
2
x
y=f(x)
[0,∞)
We visualize functions of a single unknown, termed a single variable, as graphs on the Cartesian plane. The domain and the codomain are the perpendicular real number lines.
Definition 3.1.5 The Cartesian plane is a rectangular plane formed by two perpendicular axes both representing the real numbers, such that any point on the plane is the intersection of those values on the horizontal and vertical axes. The Cartesian plane is shown in Figure 3.1.1 with the horizontal axis and the perpendicular vertical axis.
(x,y)
x
y
In[]:=
ListPlot[{},PlotRange->{{-5,5},{-5,5}},PlotLabel->"Figure 3.1.5",AxesLabel->{"Horizonal axis","Vertical axis"},GridLines->Automatic,ImageSize->Large]
Out[]=
In this chapter, we consider the common functions that are used in calculus. We start with linear functions.
3.2 Linear functions
3.2 Linear functions
Definition 3.2.1 A linear function in a single unknown is a function of the from , where is the unknown (variable), is the slope, and is the -intercept (where ). A linear function is a straight line in the Cartesian plane.
f
x
f(x)=mx+b
x
m
b
y
x=0
We create such a function by using a Wolfram language user-defined function f.
Problem 3.2.1 Create a user-defined function for the equation in (1).
f(x)=3x-2
(
1
)We use the shorthand symbol := for SetDelayed notation, which leaves the right-hand side of the assignment unevaluated until we call the function and pass a parameter value.
f[x_]:=3x+2(*Createauser-definedfunctionnamedfthattakesasingleparameter*)
Now that we have created the function, we can calculate the output for various input (unknown or variable) values ( values).
y=f(x)
x
Problem 3.2.2 Calculate the value for the input values .
y=f(x)
x=2
To perform the calculation we call the f function and pass the parameter value . Here is a parameter and is passed in brackets following the call the the function f.
2
2
In[]:=
f[2](*Callthefunctionfandpasstheparameter2toit*)
Out[]=
8
As expected we have that . Out function maps to .
f(2)3(2)+26+28
f
2∈
8∈
We can calculate the values for a list of input values.
y=f(x)
Problem 3.2.3 Calculate the values for the input values .
y=f(x)
x={-3,-2,-1,0,1,2,3}
The Map function maps all the values in the second parameter to the function in the first parameter. Below, we use the Range function to create the values . These are all mapped to the function f that we created before.
-3,-2,-1,0,1,2,3
In[]:=
Map[f,Range[-3,3]]
Out[]=
{-7,-4,-1,2,5,8,11}
The /@ is short-hand code for the Map function.
In[]:=
f/@Range[-3,3]
Out[]=
{-7,-4,-1,2,5,8,11}
A list plot visualizes the pairs of input and output values. The ListPlot function generates the markers as pairs of values. To generate the pairs, we use the Transpose function and pass the lists of input and output values as a nested list object. The plot is created in Figure 3.2.1.
(x,y)
In[]:=
ListPlot[Transpose[{Range[-3,3],f/@Range[-3,3]}],PlotLabel->"Figure 3.2.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
Figure 3.2.1 clearly indicates that we have a straight line, that is, if we use more input values.
Instead of just the integers , we can include all the real numbers on the domain . Since there are an uncountable infinite number of values in this interval, a computer will generate enough points so as to appear that all points have been included.
-3,-2,-1,0,1,2,3
[-3,3]
The Plot function in Figure 3.2.2 shows a graphical representation of the function . We pass the user-defined function as first parameter and the interval for the domain of the function as second parameter. In this case the domain is .
y=3x-2
-3≤x≤3
In[]:=
Plot[f[x],{x,-3,3},PlotLabel->"Figure 3.2.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
By including the parameter {x,-3,3}, the Wolfram Language used enough points to create a seemingly continuous line.
It is clear to see that a linear function is defined by its slope and intercept. To understand the impact of the slope and the intercept we use the Manipulate function in Figure 3.2.3.
m
b
In[]:=
Manipulate[Plot[mx+b,{x,-3,3},PlotRange->{{-3,3},{-3,3}},PlotLabel->"Figure 3.2.3",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large],{m,-10,10},{b,-1,1}]
Out[]=
| |||||||||||
|
By dragging the sliders for the slope and the intercept , we can manipulate the graph.
3.3 Polynomials
3.3 Polynomials
Definition 3.3.1 A polynomial in a single variable is a function with powers of the unknown in the form shown in (2), where all the values are constants called coefficients, and ≠0.
x
x
a
i
a
n
f(x)=+x+++…+=
a
0
a
1
a
2
2
x
a
3
3
x
a
n
n
x
n
∑
i=1
a
i
i
x
(
2
)A polynomial as shown in (2) is said to be an degree polynomial, named after the highest power of the unknown .
th
n
x
Problem 3.3.1 Create a user-defined function for the equation in (3).
f(x)=-x-6
2
x
(
3
)In[]:=
f[x_]:=-x-6
2
x
A plot of the function f is created in Figure 3.3.1 on the domain .
[-3,4]
In[]:=
Plot[f[x],{x,-3,4},PlotLabel->"Figure 3.3.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
The graph in Figure 3.3.1 is described as a parabola and represents a degree polynomial. A parabola is the graph of a degree polynomial, also called a quadratic function.
nd
2
nd
2
Definition 3.3.2 A quadratic function is a polynomial of degree , shown in (4), where are constant coefficients and .
2
a,b,c
a≠0
f(x)=+bx+c
2
ax
(
4
)To investigate how the coefficients effect the graph of a quadratic function, we view Figure 3.3.2 through Figure 3.3.4.
In[]:=
Manipulate[Plot[a,{x,-3,10},PlotRange->{{-3,3},{-20,20}},PlotLabel->"Figure 3.3.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large],{a,-2,2}]
2
x
Out[]=
| |||||||
|
In[]:=
Manipulate[Plot[+bx,{x,-3,3},PlotRange->{{-4,4},{-15,15}},PlotLabel->"Figure 3.3.3",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large],{b,-2,2}]
2
x
Out[]=
| |||||||
|
In[]:=
Manipulate[Plot[+c,{x,-3,3},PlotRange->{{-4,4},{-3,10}},PlotLabel->"Figure 3.3.4",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large],{c,-2,2}]
2
x
Out[]=
| |||||||
|
Definition 3.3.3 A cubic function is a polynomial of degree .
3
In Figure 3.3.5 we create a graph of the cubic function .
f(x)=
3
x
In[]:=
Plot[,{x,-3,3},PlotRange->{{-4,4},{-27,27}},PlotLabel->"Figure 3.3.5",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
3
x
Out[]=
3.4 Root functions
3.4 Root functions
Definition 3.4.1 A root function in a single variable is a function where the power of the unknown is as shown in (5), where is an integer and .
f
x
n
n≠0
f(x)=
1
n
x
(
5
)When we have . Figure 3.4.1 visualizes this function on the domain . Note that the function is not defined when and we have a vertical asymptote.
n=-1
f(x)=
1
x
[-3,3]
x=0
Figure 3.4.1 represents a hyperbola. The vertical asymptote is at . Note that approaches as the value of approaches from the positive axis side and as the value of approaches from the negative axis side.
x=0
y
+∞
x
0
x
-∞
x
0
x
In[]:=
Plot[,{x,-3,3},PlotLabel->"Figure 3.4.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
-1
x
Out[]=
Definition 3.4.2 A vertical asymptote is a vertical line on a graph that a function approaches but never reaches as the input approaches a specific value.
x
When we have the square root and when we have the cube root .
n=2
x
n=3
3
x
Figure 3.4.2 shows a graph of the function on the domain ]. Note that the square root of is not defined for negative input values.
f(x)=
x
[0,5
x
In[]:=
Plot[
x
,{x,0,5},PlotLabel->"Figure 3.4.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]Out[]=
Problem 3.4.1 Plot the function on the domain .
f(x)=
3
x
[0,3]
The result is shown in Figure 3.4.3.
In[]:=
Plot
3
x
,{x,0,3},PlotLabel->"Figure 3.4.3",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->LargeOut[]=
Homework 3.4.1 Use the Manipulate function to show the graphs of the function , where on the domain .
3.5 Exponential function
3.5 Exponential function
Definition 3.5.1 An exponential function in a single variable is a function that has the unknown as the power of a coefficient.
Figure 3.5.1 shows the graph of the exponential function .
f(x)=
x
2
In[]:=
Plot[,{x,-3,3},PlotLabel->"Figure 3.5.1",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
x
2
Out[]=
The number , called Euler’s number, is a constant of nature and can be defined in a number of ways. A numerical approximation of the number is calculated below use the N function, to digits.
e
e
19
In[]:=
N[,20]
Out[]=
2.7182818284590452354
Problem 3.5.1 Plot the function on the domain .
f(x)=
x
e
[-3,3]
The results is shown in Figure 3.5.2.
In[]:=
Plot[,{x,-3,3},PlotLabel->"Figure 3.5.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
x
Out[]=
Homework 3.5.1 Plot the graph of the function on the domain .
3.6 Logarithmic function
3.6 Logarithmic function
Definition 3.6.1 The logarithm base of a number is the number such that =a, shown in (6).
b
a
c
c
b
log
b
c
b
(
6
)
Problem 3.6.1 Calculate 1000.
log
10
The Log function calculates logarithms. The fist parameter is the base and the second is the number .
a
In[]:=
Log[10,1000]
Out[]=
3
The solution shows that =1000.
3
10
Homework 3.6.1 Calculate .
When used as a base for a logarithm, Euler’s number defines the natural logarithm, which is the default of the Log function when the base is omitted.
Problem 3.6.2 Calculate 1000.
log
e
We use the N function to calculate a numerical approximation to the answer.
N[Log[1000]](*Whennobaseisspecified,thenaturallogarithmiscalculated*)
Out[]=
6.90776
The solution shows that ≈1000.
6.90776
e
Logarithms are only defined for positive real numbers.
Problem 3.6.3 Plot the function in (7) on the domain .
(0,4]
log
e
(
7
)The solution is shown in Figure 3.6.1.
In[]:=
Plot[Log[x],{x,0.01,4},PlotLabel->"Figure 3.6.1",PlotRange->All,AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
Homework 3.6.2 Plot the graph of the function on the domain , where is the natural logarithm.
3.7 Trigonometric functions
3.7 Trigonometric functions
Figure 3.7.1 shows a right-angled triangle with the left-bottom angle , which has an adjacent and an opposite side, together with a hypotenuse.
θ
In[]:=
ShowGraphics[{Orange,Line[{{0,0},{1,1}}],Line[{{1,0},{1,1}}],Line[{{0,0},{1,0}}]},PlotLabel->"Figure 3.7.1",GridLines->Automatic,ImageSize->Large],GraphicsOrange,Text"θ",,,Text"Hypoteneuse",,,Text"Opposite",,,Text"Adjacent",,-,GraphicsOrange,Line,,1,,Line,0,,
1
10
1
20
1
3
1
2
11
10
1
2
1
2
1
15
9
10
1
10
1
10
9
10
9
10
1
10
Out[]=
The right triangle in Figure 3.7.1 is used to define the three basic trigonometric functions and their inverses. All the trigonometric functions are ratios of the lengths of the sides of the triangle.
The trigonometric functions are defined in ().
sin(θ)=cos(θ)=tan(θ)=cosec(θ)==secant(θ)==cot(θ)==
opposite
hypotenuse
adjacent
hypotenuse
opposite
adjacent
hypotenuse
opposite
1
sin(θ)
hypotenuse
adjacent
1
cos(θ)
adjacent
opposite
1
tan(θ)
(
8
)The trigonometric functions in the Wolfram Language take angles measured in radians as input. In the code cell below, we see the sine of radians.
π
6
In[]:=
Sin
π
6
Out[]=
1
2
If the angles are described in degrees, the following syntax can be used.
In[]:=
Sin[30Degree]
Out[]=
1
2
Figure 3.7.2 shows the sine function on the domain .
In[]:=
Plot[Sin[x],{x,-2π,2π},PlotLabel->"Figure 3.7.2",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
Figure 3.7.3 shows the cosine function on the domain .
[-2π,2π]
In[]:=
Plot[Cos[x],{x,-2π,2π},PlotLabel->"Figure 3.7.3",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
Figure 3.7.4 shows the tangent function on the domain . Note the vertical asymptotes at .
[-2π,2π]
x=±π,±π,…
1
2
3
2
In[]:=
Plot[Tan[x],{x,-2π,2π},PlotLabel->"Figure 3.7.3",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
We see that the sine, cosine, and tangent functions are periodic functions, i.e. they have repeated values for given values.
y
x
Definition 3.7.1 A function is periodic if for some value and is the period of the function.
f(x)
f(x)=f(x+n)
n
n
For the sine function the period is , where is an integer. We define the same period for the cosine function. The period of the tangent function is .
n=2π
k
n=π
Problem 3.7.1 Show the periodicity of the sine function as shown in (9) using the Wolfram Language.
sin+2kπ,where
π
6
k={-3,-2,-1,0,1,2,3}
(
9
)The Wolfram Language provides syntax to complete Problem 3.7.1 in many ways. We can use the Table function, as shown in the code cell below.
In[]:=
TableSin+2πk,{k,Range[-3,3]}
π
6
Out[]=
,,,,,,
1
2
1
2
1
2
1
2
1
2
1
2
1
2
We can also use anonymous functions, either with the Function function or using short-hand notation.
MapFunctionk,Sin+2πk,Range[-3,3](*Usestandardnotation*)
π
6
Out[]=
,,,,,,
1
2
1
2
1
2
1
2
1
2
1
2
1
2
Functionk,Sin+2πk/@Range[-3,3](*Useshort-handnotation*)
π
6
Out[]=
,,,,,,
1
2
1
2
1
2
1
2
1
2
1
2
1
2
Sin+2π#&/@Range[-3,3](*Useshort-handnotation*)
π
6
Out[]=
,,,,,,
1
2
1
2
1
2
1
2
1
2
1
2
1
2
Figure 3.7.4 shows the coordinates for Problem 3.7.1.
(x,y)
In[]:=
ShowPlot[Sin[x],{x,-6π,6π},PlotLabel->"Figure 3.7.4",AxesLabel->{"x","y"},PlotRange->{{-6π,6π},{-1,1}},GridLines->Automatic,ImageSize->Large],ListPlotTranspose+2π#&/@Range[-3,3],Sin+2π#&/@Range[-3,3],PlotStylePointSize[0.02],Filling->Axis
π
6
π
6
Out[]=
Problem 3.7.2 Show the periodicity of the cosine function as shown in (10).
cos+2kπ,where
π
3
k={-3,-2,-1,0,1,2,3}
(
10
)In[]:=
Cos+2π#&/@Range[-3,3]
π
3
Out[]=
,,,,,,
1
2
1
2
1
2
1
2
1
2
1
2
1
2
Problem 3.7.3 Show the periodicity of the tangent function as shown in (11).
tan+kπ,where
π
4
k={-3,-2,-1,0,1,2,3}
(
11
)In[]:=
Tan+π#&/@Range[-3,3]
π
4
Out[]=
{1,1,1,1,1,1,1}
Problem 3.7.6 Show that the cosecant is the multiplicative inverse of the sin function by considering . Also show that the secant is the multiplicative inverse of the cosine by considering . Finally show that the cotangent is the multiplicative inverse of the tangent by considering .
sin
π
6
cos
π
3
tan
π
4
In[]:=
Sin
π
6
Out[]=
1
2
In[]:=
Csc
π
6
Out[]=
2
In[]:=
Cos
π
3
Out[]=
1
2
In[]:=
Sec
π
3
Out[]=
2
In[]:=
Tan
π
4
Out[]=
1
In[]:=
Cot
π
4
Out[]=
1
We plot the cosecant, secant, and cotangent functions on the domain in Figure 3.7.5.
[-2π,2π]
In[]:=
Plot[{Csc[x],Sec[x],Cot[x]},{x,-2π,2π},PlotLabel->"Figure 3.7.5",PlotLegends->"Expressions",AxesLabel->{"x","y"},GridLines->Automatic,ImageSize->Large]
Out[]=
|
The compositional inverse of the sine function is the arcsine function, the compositional inverse of the cosine function is the arccosine function, and the compositional inverse of the tangent function is the arctangent function. The three compositional inverses are written as , , and . Alternatively we write (θ), (θ), and (θ). Note that these are not the multiplicative inverses which would be , , and .
arcsin(θ)
arccos(θ)
arctan(θ)
-1
sin
-1
cos
-1
tan
-1
[sin(θ)]
-1
[cos(θ)]
-1
[tan(θ)]
The composition inverses are used to determine the angle.
Problem 3.7.7 Calculate the angle for the equation in (12).
sin(θ)=
1
2
(
12
)The solution is shown in (13).
arcsin[sin(θ)]=arcsinθ=arcsin
1
2
1
2
(
13
)We calculate the arcsine of a half below.
In[]:=
ArcSin
1
2
Out[]=
π
6