Question: 4 Calculating e You'll use this series equation to approximate e . ( Trivia: this is the Taylor series for e x with x =

4 Calculating e
You'll use this series equation to approximate e.(Trivia: this is the Taylor series for ex with x=1.)
e=k=0n-11k!=1+11+12+16+124+1120+1720+15040+cdots
When you see a Sigma (??), think of a for loop. In this case, the for loop starts at 0 and ends at n-1. Here is one way to do that:Important: The summation (sum_(k=0)^(n-1)(1)/(k!)) and the for loop run from 0 to n-1. That's because for a given value of n we want to have n terms in the series. To do: In your copy of nummy . c you'll see a function called my_e(). Convert the mathematical series above into C within that function. You'll be using double type variables for everything except the for loop's index, which is an int. Note: You should not write or use a factorial function. Instead you should use a variable to store (k-1)! and multiply it by k on each loop iteration, essentially using k!=(k-1)!xx k. There will be an example of this in lecture. Also, remember that 0!=1. This is in C
4 Calculating e You'll use this series equation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!