0% found this document useful (0 votes)
28 views

Problem Set2 Excel Functions

This document provides an overview of how to evaluate and graph functions using Excel. It discusses entering formulas in Excel, evaluating functions at specific values, and creating column arrays to graph functions over intervals by example. Graphing functions in Excel involves creating two column arrays, one for x-values and one for corresponding f(x) values, to plot the relationship between variables.

Uploaded by

ety purwanti
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Problem Set2 Excel Functions

This document provides an overview of how to evaluate and graph functions using Excel. It discusses entering formulas in Excel, evaluating functions at specific values, and creating column arrays to graph functions over intervals by example. Graphing functions in Excel involves creating two column arrays, one for x-values and one for corresponding f(x) values, to plot the relationship between variables.

Uploaded by

ety purwanti
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 12

Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

Mathematics for Business Decisions, Part I

Problem Set 2: Evaluating and Graphing Functions in Excel

Purpose: To use Excel to evaluate and graph functions that contain one or more parameters.
NOTE: This is a skill that you will use throughout the course.

Evaluating functions in Excel

Before you can start evaluating functions in Excel, you must learn the basics of how Excel
evaluates mathematical expressions.

Example 1: Suppose we want to evaluate the function f ( x)  6 x 2  7 x  8 at x  2 in Excel. It


is clear that in order to compute f (2)  6  2 2  7  2  8 we must be able to add, subtract, multiply,
and evaluate exponential terms like x 2 in Excel. When you type numbers or letters into a cell in
Excel, Excel treats these entries as data. It does not evaluate them. To put Excel in “math mode”
you must use the equal sign = as your first entry in the cell. Next, we must look at how to
perform basic math computations in Excel like +, −, ×, ÷ and powers. Below is a list of the
conversion symbols in Excel:

For addition use +,


for subtraction use −,
for multiplication use *,
for division use /,
and to raise a term to a power use the ^ symbol on the keyboard.

Using this information, we will write the function using what we will call Excel-function format
notation: f ( x)  6 * x ^ 2  7 * x  8 . You should compare this to the original function above.

We are still not quite ready to evaluate this function in Excel. We can’t put a variable like x
directly into an Excel formula. Instead, we have to use a cell reference for the variable. We can
then put the value of x for which we want to evaluate the formula into that cell. If we want to
evaluate the function for a different value of x, we enter the new value in the cell. Here is a case
where we’ve put the value of x in cell A2, and evaluated f(x) in cell A3. We’ve used x = 2 and
evaluated f(2):

x f(x)
2 18

We now show the code that generated this solution:

x f(x)
2 =6*A2^2-7*A2+8

We will now give more examples using Excel-function format so that the reader can get more
familiar with it.
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

Example 2: Convert the following mathematical expression into Excel-function format.


x 1
f ( x)  2 .
x  x 1

Solution: When expressed in Excel-function format f ( x)  ( x  1) /( x ^ 2  x  1) . The parentheses


around the denominator are necessary. The expression f ( x)  ( x  1) / x ^ 2  x  1 when written in
x 1
mathematical notation is f ( x)  2  x  1 . This is a very different result from what was
x
intended. In general, whenever you have a rational function (a function of the form:
P( x)
f ( x)  ) you should always set numerator and denominator apart by parentheses like this
Q( x)
(numerator)/(denominator).

Now let’s go in the other direction.

Example 3: Convert the function f ( x)  ( x ^ 2  7 * x  1) /( x ^ 2  3 * x  19) written in Excel-


function format into a mathematical expression.
x2  7x  1
Solution: In standard mathematical notation f ( x)  2 .
x  3 x  19

Let’s look at one more example that’s a little more useful. This one will involve a function that
has parameters. Most real-world formulas involve functions with parameters.

Example 4: Suppose you want to use Excel to make a “program” that computes discrete
compound interest. Let P = Principal (the amount invested or borrowed), r = nominal interest
rate, n = number of compounding periods per year, t = time (in years), and F = future value.
nt
The following formula gives the future value of the investment: F  P1  r  .
 n
Solution: The first step is to write the formula out in Excel notation as F = P*(1+r/n)^(n*t). The
parentheses after the caret ^ are necessary. Without ( ) after the ^, we would be evaluating the n
power instead of the n/t power. For example, if you type =2^3*5 in Excel, then Excel returns 40.
This is because only the 3 is raised to the power. Excel reads 2^3*5 as 2 3  5  8  5  40 . However,
Excel reads 2^(3*5) as 2 35  215  32768, a very different result. When Excel reads the
combination ^( it goes along and looks for the closing parenthesis ) . Excel then raises every
thing to the power inside the parentheses ( ).

Lastly, we must designate a cell for each parameter P, r, n, t, and for the formula for F.
Suppose you borrow (spend) $3000 on your credit card at a rate of 21% interest, compounded
monthly (n=12; most credit cards compound at the end of each monthly payment period), and do
not make any payments for 5 years. Make a spreadsheet to compute this situation in Excel.

We list the solution below:

P r n t F
3000 0.21 12 5 8495.449

We now show the code that generated this solution:


Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.
P r n t F
3000 0.21 12 5 =A2*(1+B2/C2)^(C2*D2)

Graphing functions in Excel

We’ve seen how to evaluate functions at particular values of x, we’re now ready to take the next
step and learn how to graph functions. We will assume that the functions are piecewise
continuous and smooth. Recall from college algebra that a function is continuous if you can draw
the function on a piece of paper without lifting your pen. Put another way, if we represented the
function as a wire on a piece of paper, then the wire would be in one piece (it would not be
broken). A function is piecewise continuous if it only has finitely many discontinuities, say
x1  x 2    x n , and it is continuous over each interval ( x1 , x 2 ), ( x 2 , x3 ), …, ( x n 1 , x n ) . A
function is smooth if you could run your hand over its graph without it cutting your hand. For
more details see your college algebra book or do a Google search on the web.

We plot graphs of functions in Excel by making two column arrays. In the first column we make
a column array of values of the independent variables, call them xi , over the interval that we
wish to graph the function. We usually take these values to be evenly spaced over the interval.
We shall refer to the distance between any two points, denoted x  xi  xi 1 , as the step size.
For example, if we want to graph a function over the interval [a, b], and we want n points, then
ba
we take our step size to be x  . One the other hand, if we want the spacing between two
n
ba
points to be x , then we take n to be n  , where n need not be an integer. In the second
x
column, we make an array of the values of the function corresponding to the points xi . The
values look like f ( xi ) . Rather than give a formal discussion of this, we will learn how to graph
functions by example.

Example 5: Graph the function f ( x )  x 2 over the interval [−1,1]. Use a step size of x  0.5 .
We will soon see that this step size is too large. As a rule of thumb, you should take your step
1
size x to be roughly th the width of the interval over which you are graphing the
100
function.
Start by inserting −1 into the first column in cell A2. Warning: Be sure to enter the value into
the cell. This should advance you to the next cell. Use the up-arrow to return you to the cell A2.
Once you are back in cell A2 you will need to bring up the Fill Series menu.

To get to the Fill Series menu, go through the following drop-down menus:
From the main toolbar go to Edit  Fill  Series (hotkeys <Alt> E i s).
Once you’re at the Fill Series menu, you need to change the “Series in” option to “Columns” (not
“Rows”). Warning: the default value is rows, not columns! Next, under the “Type” option, leave
the default setting at “Linear”. Set “Step value” to x = 0.5, and “Stop value” to 1. The steps are
shown in the figures below.
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

Going to Edit  Fill  Series from the


main toolbar brings up the Fill Series
menu, shown to the right in its default
state.

Under the heading “Series in”, switch


from “Rows” to “Columns”. Under the
heading “Type”, leave “Linear” alone.
Change “Step value” to .5, and “Stop
value” to 1. Do not check the “Trend”
box.

Now hit the OK button. You should get


a series in column A as shown at right.
Notice that cells A1 and B1
contain column titles. It is always a
good idea to label the columns in your
Excel files.

Now that we have all of our x values in a column array, we need to get the corresponding f (x )
values in a column array. To do this, we will have to construct the formula for f ( x)  x 2 in
column B. In Excel-function format, f ( x)  x ^ 2 . However, we cannot use the value x directly.
Instead, we must use the address of the cell where the value of x is stored. For example,
f (1)  A2^ 2 , since −1 is in the cell A2. We can now use the fill handle (the dark square located
in the lower right hand corner of a cell when you click on the cell) to complete the other values
of f (x ) .
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

The function is constructed using Excel-


function notation. The formulas are displayed
using the <ctrl> ~ command. You can toggle
back and forth between the formulas and
their numerical values by using the key
sequence <ctrl> ~.

Next, we want to graph the function y  f (x ) . To do this, we use the Chart Wizard found in the
tool bar. It looks like . If the chart wizard does not appear in the tool bar then you can add
it, just go to the toolbar and under Tools  Customize, then under “Categories”, choose “Insert”.
You will find the Chart Wizard under “Commands”. Just drag the icon into the toolbar.

To graph y  f (x) , highlight the range containing the values of f (x) . In our case, this is the
cells B2:B6. Then bring up the Chart Wizard. Select “XY(Scatter)”, and choose a scatter plot
with points connected by a smooth lines without markers as shown below. The darkened box is
the one that you want to choose.

Hit the Next > button, you should then see the following:
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

Next, click on the “Series” tab. You should then see:

Now, under “X values”, click on the box with a red arrow in the right-hand corner as shown
below.
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

Highlight the x values in the Excel file found in column A in cells A2:A6. You should now see

Under Name put the name that you want to call your chart. . Then hit “Next >”
and fill in your axis labels. Hit “Next” one more time, then “Finish”. Lastly, you can delete that
annoying in the chart and resize your chart. You should have something like

You are now ready to graph functions.


Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

Elementary-Level Problems

For problems 1-10 convert the following mathematical expressions into Excel-function format.
x 1
For example, the mathematical function f ( x)  2 when expressed in Excel-function
x  x 1
format becomes f ( x)  ( x  1) /( x ^ 2  x  1) . The parentheses around the denominator are
necessary. The expression f ( x)  ( x  1) / x ^ 2  x  1 when written in mathematical notation is
x 1
f ( x)  2  x  1 . This is a very different result from what was intended.
x

Problem 1: Write f ( x)  e x in Excel-function format.

2
Problem 2: Write f ( x )  e  x in Excel-function format.

Problem 3: Write f ( x)  5 x 2  3 x  7 in Excel-function format.

nt
 r
Problem 4: Write F  P1   in Excel-function format.
 n

Problem 5: Write F  Pe rt in Excel-function format.

x 2  2x  1
Problem 6: Write f ( x)  in Excel-function format.
1 x2

Problem 7: Write f ( x)  x 5  x 4  7 x 3  13x 2  3 x  19 in Excel-function format.

Problem 8: Write f ( x)  ln( x 2  2 x  1) in Excel-function format.

Problem 9: Write f ( x)  5 x 2 e x in Excel-function format. Use Excel to evaluate f (x) at x = 2.


Note: In Excel the exponential function is written as e x  Exp(x ) .

x2 1
Problem 10:Write f ( x )  in Excel-function format. Use Excel to evaluate f (x ) at x = .1.
x2 1

Elementary-Level Problems
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

Next, we try going in reverse. For problems 11-20 convert the following equations written in
Excel-function format into mathematical expressions. For example, the function
f ( x)  ( x ^ 2  7 x  1) /( x ^ 2  3x  19) is written in Excel-function format. It becomes
x2  7x  1
f ( x)  2 when it is expressed in standard mathematical notation.
x  3 x  19

Problem 11: f(x) = x^2 -3*x + 5

Problem 12: f(x) = (1+x)^2

Problem 13: F = P*(1+r/n)^(n*t)

Problem 14: f(x) = 5*x^2*Exp(x)

Problem 15: f(x) = (x^2 + x + 1)/(x^2 -2x + 1)

Problem 16: y = (1+r/n)^(n)-1

Problem 17: y = Exp(r) – 1

Problem 18: y = (1/sqrt(2*pi())*Exp(-(x^2)/2)

Problem 19: y = (x^2 - 1)/(x^2 + 1)

Problem 20: Let A1 be a cell reference to a variable x. y = -6* A1^3 + 5* A1^2 + 7* A1 + 9

Intermediate-Level Problems
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.

For problems 21-25 graph the following functions.

Problem 21: (Graphing) y  25  x 2 , over the interval 0  x  5 . In fill series, use time steps of
length ∆t = .01, start value of 0, and end value of 5.

Problem 22: (Graphing) Find the intersection of the following functions: y  e  x and y  x
over the interval [0,1]. In fill series, use time steps of length ∆t = .01, start value of 0, and end
value of 1.
nt
 r
Problem 23: (Graphing) F (t )  P1   for P = 1000, r = .05, n = 12, over the interval
 n
0  t  3 . In fill series, use time steps of length ∆t = .01, start value of 0, and end value of 3.

Problem 24: (Graphing) Find the point ( x0 , y 0 ) where the two functions intersect over the
given interval. y  f ( x)  25  x 2 and y  g ( x)  x  1 over 0 ≤ t ≤ 5.
Hint: Graph the function h( x)  f ( x)  g ( x) and find the roots (zeros) of h(x).

Problem 25: (Graphing) Two individuals each invest P = $100 in two different banks. Bank1
has a nominal interest rate of r1 = .04, compounded continuously. Bank2 has an investment
scheme of simple interest at a nominal interest rate of r2 = .05. The formulas for the two
schemes are respectively, F1 (t )  Pe r1t and F2 (t )  P (1  r2 t ) . Find the time at which the
compound interest formula overtakes the simple interest formula. You may assume that this
occurs in less than ten years, so that 0 ≤ t ≤ 10.

Problem 26: (Graphing) Find a value of x0  0 so that the functions y  g ( x)  .05( x  x0 )


x
and y  f ( x)  will intersect at 3 distinct points.
1 x2
Hint: Graph f(x) first.

Advanced-Level Problems: Applications of compound interest formulas


Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.
Problem 27: (compound interest) Recall that letting n   in the discrete compound interest
nt nt
 r F  r
formula F  P1   leads to F  Pe rt . That is  1    e rt as n   with the interest
 n P  n
n
rate r fixed. We are now going to verify this by letting m  for fixed r. Then n m.
r
1 m 1 1
It suffices to show (1  )  e , or equivalently (1  ) m  1 as m   . Create an Excel file
m e m
1 1
that computes the values of (1  ) m for positive values of m that approach ∞. Although you
e m
can’t let m go to ∞ in Excel, you can let m get large, say m = 1000. From the Excel computation,
1 1 m
it should be clear that mlim (1  )  1.
 e m
NOTE: In Excel use the exponential function Exp(x) to evaluate e-1 in the above limit.
That is, Exp(-1) = 1/e.

Problem 28: (compound interest) Create an Excel file to compute the future value for both the
discrete and continuous compound interest formulas:
nt
 r
(i) F  P1   (discrete compounding case)
 n
Input Variables (the given variables): P, n, r , and , t .
Output Variables: (the variable that you want): F

(ii) F  Pe rt (continuous compounding case)


Input Variables (the given variables): P, r , and , t .
Output Variables: (the variable that you want): F.

Problems 29-32: (Applications of Taylor series to compound interest)


It is a well-known fact in mathematics that that for fixed α and small values of x we can
approximate the function 1  x   by the following series (known as a Taylor series
approximation about x  0 )

1
1  x    1  x   (1   ) x 2  
2
nt
 r
Recall: the formula for compound interest is F  P1   , where P is the principal, F is the
 n
future value, r is the annual interest rate, n is the number of times per year the interest is
compounded, and t is time (in years). The formula for simple interest is F  P 1  rt .
r r
If we let x  and   nt , and assume that is small, then we can apply this approximation
n n
nt nt
 r  r
to show that 1    1  rt , from which it follows that F  P1    P(1  rt ). This says
 n  n
r
that for small enough and for fixed time, we can approximate the discrete compound interest
n
formula by the simple interest formula. Warning: this approximation assumes that   nt is
nt
 r
fixed. It is clearly not valid for all time, since F  P1   grows exponentially, whereas
 n
F  P 1  rt  grows linearly.
Hackernotes, Pima Community College © Wayne Hacker 2007. All rights reserved.
Problem 29: (compound interest) Let P = 1000, r = .04, n = 12. Starting at time t = 0, explore
nt
 r
the approximation Fcompound  P1    P (1  rt )  Fsimple by determining how long (in years)
 n
the approximation stays valid to the nearest dollar.

Problem 30: (compound interest) Consider the yield formula for discrete compound interest
n n
 r  r
y  1    1 . Use Excel to find the range of r over which y  1    1  r is valid to four
 n  n
decimal places with n = 12.

Problem 31: (compound interest) Consider the yield formula for continuous compound interest
y  e r  1 . Use Excel to find the range of r over which y  e r  1  r is valid to four decimal
places.

Problems 4 and 5 are consequences of the same approximation that is shown above.

Problem 32: (Taylor series) It is a well-known fact in mathematics that that the function e x
can be expressed by the following infinite series (known as a Taylor series about x  0 )

xn
ex   , where n!  1  2  3 n .
n0 n!
For small values of x we can approximate the infinite series by the first N+1 terms in the sum.
That is,
N
xn 1 1
ex    1  x  x2  x3   .
n  0 n! 2 6

Use Excel to compute the first 6 terms of the series (N = 5). Evaluate the series at x  1 and
compare it to the exact value e1  e  Exp(1). (i) How accurate is the approximation? (ii) Do a
scatter-plot graph in Excel and compare the 6-term ( N  5 ) Taylor series approximation about x
= 0 given by
1 2 1 3 1 4 1 5
y  1 x  x  x  x  x
2 6 24 120
to the exact function y  e x  Exp(x) over the interval [0,1]. Use a step size of h = .01 in your
fill-series step value. In other words, you are going to approximate e x by the polynomial given
above. Do you see any difference in the graphs, or for all practical purposes, is the approximation
indistinguishable from the original?
(iii) Next, repeat question (ii) with N=1. The equation becomes: y  1  x
Do you see any difference in the graphs in this case? If so, approximately at what value of x does
the approximation start to significantly diverge from the original graph?

You might also like