Answered step by step
Verified Expert Solution
Question
1 Approved Answer
5. (25 pts) Stirling's approximation is used to estimate the value of natural logarithms of factorials of large numbers. The mathematical formula is. In (n!)
5. (25 pts) Stirling's approximation is used to estimate the value of natural logarithms of factorials of large numbers. The mathematical formula is. In (n!) = n lnn-n a. Write a function that meets the following specifications: def Simpson (N): N is a positive integer. The function should return both the estimated value of In(N!) and the percent error in the estimation based on the formula: error=1-[nln(n)-n]/In(N!) b. Write a function that meets the following specifications: def main(): Print lines of formatted output to the screen/console in the following format: In(500!) = 2605.3 (error = 0.15%) Notes: Output a similar formatted line only when error drops below values of 15%, 10%, 5%, 1% You can calculate the natural logarithm of a function with log () from the math module. You can calculate the factorial of an integer with factorial() from the math module
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started