Sunteți pe pagina 1din 13

Functions and Function Notation Review

Functions and Function Notation Review


Content
This live script reviews functions, function notation and necessary properties.

Table of Contents

Implicit Versus Explicit Functions


Function Notation
Defining Functions Using MATLAB
Plotting Functions Using MATLAB
Function Transformations
Inverse Functions
Summary

Implicit Versus Explicit Functions


A function describes a relationship between two ordered sets, an independent variable set X and a dependent
(sometimes called "output") variable set Y. Each element from the independent variable set (sometimes called
"the input variable"), is related to exactly one element of the dependent variable set, (sometimes called "the
output variable"). This relationship (sometimes also called a "mapping", or a "pair") can be specified using explicit
(1) or implicit (2) or explicit forms as shown below:

(1) (explicit form)

(2) (implicit form)

These equations describe the same relationship between and . The difference is that in the explicit function
(Equation 1), the dependent variable is given directly in terms of the independent variable (that is y appears
directly and exactly once on the left hand side and does not appear at all in the right hand side), while the implicit
function, (Equation 2), instead states a (more general) relationship between dependent and independent
variables.

Any relationship that has two dependent variables for any one independent variable is not a function. Take the
following equation that describes all points on a circle centered at the origin with a radius of 3, . In this
relationship, when , .

The vertical line test can be used to confirm graphically whether a relationship is a function or not. The vertical line
test involves using a vertical line on the xy-plane. If this line crosses the plot of the function more than once for any
unique , the curve does not represent a function. Below is a graph displaying the circle plot, that fails
the vertical line test:

% define values
th = 0:pi/50:2*pi;
xvalues = 3*cos(th);
yvalues = 3*sin(th);

% plot circle (xvalues,yvalues) and line ([1.5 1.5],[-3 3])


plot(xvalues,yvalues,[1.5 1.5],[-3 3]);

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

% make axis square and place grid


axis square; grid on; box on;

% add axis labels and title


xlabel('x');ylabel('y');
title('Vertical line test with a circle');

Function Notation
A function can also be expressed using the notation which defines the function and identifies as the
independent variable, as in the following example (basically replaced the dependent variable in the function
definition):

(3)

You can now evalute the function by replacing the variable with a real value. For example, to evalute the function
at , or , you can describe it as shown below:

Defining Functions Using MATLAB


You can define a function using MATLAB. First, define a symbolic variable x as shown in the following command

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

(note that lines starting with "%" are comments):

% create symbolic variable "x"


syms x

Since is now defined as a symbol, it is possible to assign a mathematical expression to the functon. This
assignment operation will create a new symbolic function:

% define function "f(x)"


f(x) = 2*x^2 + 3*x;

After creating this symbolic function, you can evaluate for any value in the possible ranges of the independent
variable (use the "Run Section" button to run the section and show the results below the commands).

f(4)

ans =

f(sqrt(3))

ans =

f(-1)

ans =

You can use other built-in functions provided in MATLAB to define more complicated functions such as:

Trigonmetric functions (sin, cos, tan)


Logarithmic functions (log, log10, dilog)
Piecewise functions (rectangularPulse, triangularPulse)

Below are examples of these functions using different symbolic variables.

Again, you can use the "Run Section" button to run the section and show the results below the commands. You can
also try changing functions in the command below (e.g. use the cosine or tangent functions, or change some
numerical values) and re-run the section to see how the results change.

% define several symbolic variables in one line using 'syms' function


syms t s k

% define sine wave function with a period of 2*pi


g(t) = sin(t)

g(t) =

% define a logarithmic function with base 10


h(s) = log10(s)

h(s) =

% define a piecewise function

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

l(k) = rectangularPulse(k)

l(k) =

syms x
y = piecewise(x<0, -1, x>0, 1)

y =

pretty(y)

{ -1  if  x < 0
{
{  1  if  0 < x

You may review the documenation for more information regarding the function syms, creating symbolic functions
and finding a list of Symbolic Mathematical Functions.

Plotting Functions using MATLAB


After defining a function, you can visualize it with the "fplot" command ("plot" is used for pairs of points, "fplot" is
used for functions).

You can specify the range of the independent variable by using a two-element array as the second argument.
Refer to the "fplot" documentation for more information on how to use it.

fplot(f, [0, 5])

fplot(g, [0 2*pi])

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

fplot(h,[0 10])

fplot(l)

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

Function Transformations
A graph of a function may be transformed either by shifting, scaling or reflecting it across an axis. For instance, to
shift the function horizontally (that is on the x-axis), you need to add or subtract to the "input" of the
function, , therefore obtaining , where , and where notation determines the direction of the shift.

Specifically, shifting the function to the left is obtained with , whereas the shifting is to the right

is obtained with . This can be observed by plotting the functions:

% define x and functions


syms x
f(x) = x^2; % Original function
gLeft(x) = f(x+3); % Horizontal transformation to the left by 3 units
gRight(x)= f(x-3); % Horizontal transformation to the right by 3 units

% plot f in the selected range


fplot(f,[-4 4])

% add the other 2 functions to the same figure


hold on % "hold on" allows plotting things on the same figure
fplot(gLeft, [-7 1])
fplot(gRight, [-1 7])
hold off % "hold off" allows plotting things on a new figure next time

% add grid, title, legend and label


grid on
title('Horizontal Transformations of f(x) = x^2') % Add title to graph
legend('f(x)','f(x+3)','f(x-3)','Location','Southeast') % Place lengend in graph

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

xlabel('x');

For vertical shift transformations (that is on the y-axis), a value must be added to the "output" of the function
. For instance, will shift the function vertically upwards, whereas will shift the function
vertically downwards.

% define functions
syms x
f(x) = x^2; % Original function
gUp(x) = f(x)+5; % Vertical transformation upwards by 5 units
gDown(x)= f(x)-5; % Vertical transformation downwards by 5 units

% plot functions
fplot(f,[-6 6])
hold on
fplot(gUp, [-6 6])
fplot(gDown, [-6 6])
hold off

% add grid, title, legend and label


grid on
title('Vertical Transformations of f(x) = x^2') % Add title to graph
legend('f(x)','f(x)+5','f(x)-5','Location','North') % Place lengend in graph
axis square;
xlabel('x');

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

It is also possible to transform a function by reflecting it across the y-axis, x-axis and the origin. For instance, to
reflect across the x-axis, the output value of the function (that is the dependent variable ) needs to be
multiplied by -1. Therefore, is the reflection of the function accross x-axis. For reflection transformation
across the y-axis, multiply the value of the input (independent) variable by -1 to get the value on the other side of
the y-axis. Therefore, is the reflection of the function across the y-axis. Combine both of these
transformations for reflection across the origin, meaning a reflection across both axes.

Below is a brief summary of the basic type of transformations of function , where :

Vertical shift upwards:


Vertical shift downwards:
Horizontal shift to the right:
Horizontal shift to the right:
Y-axis reflection:
X-axis reflection:
Origin reflection:

Inverse Functions
As previously defined, a function is represented as a relationsip between two sets, in which each element from the
independent variable set is related to exactly one element of the dependent variable set (but not the other way
around). For example, in the function , with the indepedent variable set , the
corresponding dependent variable set would be . The ordered pairs can be written as follows:

By interchanging these order pairs, we can see an inverse relationship, where the independent variable now

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

become the dependent variable.

A function that describes this relationship is called an inverse function. A function is the inverse of the
function , if for each in the domain of and for each in the domain of . The
inverse function of is denoted as . For instance:

Graphing these two function shows the inverted ordered pair relationship as a reflection through the line .
This is known as the reflective property of inverse functions: The graph contains the point if and
only iff the graph of contains the point .

% define functions
syms x
f(x) = 3*x-2;
g(x) = (2+x)/3;

% set up figure and get axes for later use


fig1=figure;ax=axes(fig1);

% plot functions on the given axes


hold on;
fplot(ax,f,[-5 5]);
fplot(ax,g, [-5 5]);
fplot(ax, x, [-5 5],'--r'); % use a red dashed line
hold off;

% make axis square, add grid, adjust viewing range, add minor grid and legend
axis square; grid on
ax.YLim = [-5 5];
ax.XMinorGrid = 'on';
legend('f(x)','g(x)','y = x','Location','Northwest')

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

However, even if the Reflective Property holds true for a specific funtion, it does not define an inverse funciton. A
function has an inverse if and only if it is one-to-one, meaning that for every unique value of independent variables,
there is exactly one dependent variable with a unique value. This property is also called "injectivity". For instance,
is a function because each independent variable x is related to exactly one independent variable y.
However, does not have an inverse function because sometimes more than one independent variable x is
related to the same dependent variable y, for example but also . While this (having 2 input
values resulting in the same output value) is ok in terms of being a function, (indeed passes the vertical
line test), it means that does not have an inverse because such an inverse would have 2 output values (e.g. 2
and -2) for the same input values (e.g. 4), and this is prohibited by the function definition.

This can be verified by using the horizontal line test. Since all the x-coordinates and y-coordinates are switched in
an inverse functions, the horizontal line test becomes a vertical line test for the inverse function. Below is a graph of
and its mirror across the line . Notice that fails the horizontal line test and its mirrored graph fails
the vertical line test. This means that does not have an inverse.

% define functions
syms x
f(x) = x^2;
g(x) = finverse(f,x);
h(x) = -finverse(f,x);

% set up figure and axes for later use


fig2 = figure;
ax2 = axes(fig2);

% plot functions on the given axes


fplot(ax2,f,[-3 3])

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

hold on
fplot(ax2,g,[-3 3],'g','ShowPoles','off')
plot(ax2,[-3 3], [2,2],'--r')
plot(ax2, [2 2], [-3 3],'--r')
fplot(ax2,h,[-3 3],'g','ShowPoles','off')
hold off

% adjust view range, grid and add legend


ax2.YLim = [-3 3];
grid off; axis square;
ax2.XMinorGrid='on';
ax2.YMinorGrid='on';
legend('f(x)','f^-^1(x)','Test lines','Location','Southwest');

Guidelines for Finding the Inverse of a Function:

1. Determine if has an inverse, or function is one-to-one.


2. Solve for x as a function of y.
3. Interchanging and results in .
4. Define the domain of to be the range of .
5. Verify that .

Example:

Find the inverse function for . are inverse functions.

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

1) To determine if is one-to-one, you can use two different generic values, and , where .
If , then is one-to-one.

This proves that the function is one-to-one and that it has an inverse.

2) Solve for as a function of :

3) Interchange and :

4) Define domain of to be the range of .

5) Verify the inverse function:

Therefore, the inverse function for is .

Summary
This example has shown a number of Calculus concepts and examples related to functions, including the
corresponding MATLAB code:

1. Function - A relationship (also called association or mapping) between one or multiple elements from a set
of independent variables to a single element from set of dependent variables.
2. Explicit Function - Function in which the dependent variable is written in terms of the independent variables
only.
3. implicit Function - Function in which the dependent variable is not isolated from the independent variable.

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]


Functions and Function Notation Review

4. Vertical Line Test - A test in which a vertical line is drawn on a graph to determine if the relationship plotted
is a function. If a vertical line interesects the graph more than once at any particular independent variable,
the relationship is not a function.
5. Transformation - A shift, reflection, or scaling of a the graph of a function.
6. Inverse Function - Function that "undoes" the action of another function, so that and
.

Copyright 2018 The MathWorks, Inc.

file:///C/Users/Tj/AppData/Local/Temp/Calculus%201_%20Functions.htm[9/17/2019 4:48:35 AM]