Consider the following formula used to estimate e to a given value: e^x = 1+ x+
ID: 3837549 • Letter: C
Question
Consider the following formula used to estimate e to a given value: e^x = 1+ x+ x^2/2! + x^3/3! + x^4/4! + x^5/5!+ ellipsis In the space below, write the design statements (i.e., pseudo code) you would use to develop a function called FindExp that provides an estimate of e to the given value.. The value is passed into the function as a single parameter. A specified number of elements (or iterations) must be set in the function code. Again, write only the design statements will be to credit reduction. You may assume that the given x value is positive. Remember to follow quality practice of design and development.Explanation / Answer
Given formula :
This formula can be re-write in following manner.
From the above expression we can determine that following formula need to iterate in order to find the value of given expression.
sum = 1 + x * sum / i;
Here sum variable will be our desired output.
Pseudo Code:
Step 1: Start
Step 2: Declare a function FindExp that take two parameter n and x , where n will decide number of iteration and x will be user input.
Step 3: Intialize variable n.
Step 4: Take input from user that will be assigned into variable x.
Step 5: Pass n and x into function FindExp.
Step 6: Start loop
Step 6.1:Intialize i =n and decreement its value after each iteration.
Step 6.2: Set condition for loop i > 0, loop will terminate when it give false value.
Step 6.3: Initialize variable sum.
Step 6.4: Calulate sum = 1 + x * sum / i;
Step 6.5: Decrement value of i after each iteration.
Step 7: End loop.
Step 8: Print the value of sum that is our desire output i.e e^x.
Step 9:Exit
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.