CE En 270 - Homework #15

Programming with Loops: Taylor Series Expansion

The value of ex can be approximated with the following equation:

This equation can also be expressed as:

Write a spreadsheet where the user can enter an x value and a tolerance (epsilon).  The spreadsheet should display the value of ex as computed by the built-in Exp() function in Excel and by some VB code that you will write that solves the equation shown above.  Your spreadsheet may look something like this:

As you write your program, you must satisfy the following requirements:

  1. Write a sub associated with a button that does the calculations for ex.  Structure this sub so that it automatically stops adding increments when the absolute value of the current increment is less than the epsilon value.
  2. As your code is computing ex, you should print out the values of the iteration number and the increment to your spreadsheet as shown above.  Be sure to clear the contents of the area where you are printing the results prior to entering the loop that computes ex.

Hint: You code will need two loops, one nested inside the other. The outer loop will do the summation and the inner loop will compute the factorial. Or you can compute the factorial without an inner loop by keeping track of the factorial value from the previous iteration and multiplying it by the new i value.  Be sure to properly handle the case when i = 0 (factorial of zero = 1).

Submittal Instructions:

Click here to upload your homework assignment.