Question: For this assignment, write some functions that duplicate those in the standard math library. Don't use any standard math library functions in your functions. Use

 For this assignment, write some functions that duplicate those in the

For this assignment, write some functions that duplicate those in the standard math library. Don't use any standard math library functions in your functions. Use standard math functions only in main for testing. 1. Write the function double myexp (double x); that returns ex where e is the base of natural logarithms, 2.718281828... Do this by summing the terms of the power series, 72 2 3 2!3! Continue looping until the absolute value of the current term is close to zero. For example myexp( 2.4) 1+ 2.42.42/2+2.43/62.44/24 2.45/1202.46/720 + 11.023 The correct way to do this is to make use of the fact that each term of the series is equal to the previous term times x for that term's n. Don't calculate n for each term. Recall that n! blows up very quickly and calculating it by itself will lead to problems. Initialize a sum (to one) and a current term (to one) and write a loop body that computes the next term based on the current term and adds it to the current sum. Then the new term becomes the current term. Write the function to be side-effect free (no I/O, no globals). The function takes a parameter of type double and returns a value of type double. Within the function body use type double for the term and the sum. The loop counter should, of course, be an int. Assume that x is in the range -25 to +25 or so, although ideally it can be any real value

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 Databases Questions!