Question 2: Calculating e The constant e, sometimes called Euler's number, is important in many areas...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 2: Calculating e The constant e, sometimes called Euler's number, is important in many areas of mathematics and physics. An approximation for it is present in the constant math.e, which is 2.718281828459045. In this question you will write code to calculate the value of e and ex. Exercise You may use import math for this question, but the only thing you should use from it is math. factorial. Do not use anything else from the math module for this question. It turns out that we can calculate e* using the following sum: хо х1 х2 х3 x4 x5 x6 0! 1! 2! 3! 4! 5! 6! + + + + + + + Write a function exponent (x: float, threshold: float) -> float. The function uses the pattern above to approximate ex, including only terms that are at least as big as threshold. It is given that threshold is a positive number. For example, consider terms in exponent (2.0, 0.7): хо 0! 3! = 2! ex 1 = 1; 1 ≥ 0.7, so we include this term. 1 2 = 2; 2 ≥ 0.7, so we include this term. 2; 2 ≥ 0.7, so we include this term. 1.333...; 1.333... > 0.7, so we include this term. 4 IS 8 6 16 = 0.666...; 0.666... < 0.7, so we do not include this or any subsequent term. = 4! 24 So exponent (2.0, 0.7) must return 1+2+2+1.333... ≈ 6.3333. On the other hand, exponent (2.0, 2.0) must return 0; since the first term of the pattern is less than 2.0, we are adding up no terms. Consider also terms in exponent (1.0, 0.5): xº 1 = O! = 1;1 ≥ 0.5, so we include this term. = 1; 1 ≥ 0.5, so we include this term. 0.5; 1 ≥ 0.5, so we include this term. 2 = = 0.1666...;0.1666 < 0.5, so we do not include this or any subsequent term. 3! 6 So exponent (1.0, 0.5) must return 1 + 1 +0.5 = 2.5. Test your code carefully when x > 0, but also when x < 0. This approximation should work for any value of x. Question 2: Calculating e The constant e, sometimes called Euler's number, is important in many areas of mathematics and physics. An approximation for it is present in the constant math.e, which is 2.718281828459045. In this question you will write code to calculate the value of e and ex. Exercise You may use import math for this question, but the only thing you should use from it is math. factorial. Do not use anything else from the math module for this question. It turns out that we can calculate e* using the following sum: хо х1 х2 х3 x4 x5 x6 0! 1! 2! 3! 4! 5! 6! + + + + + + + Write a function exponent (x: float, threshold: float) -> float. The function uses the pattern above to approximate ex, including only terms that are at least as big as threshold. It is given that threshold is a positive number. For example, consider terms in exponent (2.0, 0.7): хо 0! 3! = 2! ex 1 = 1; 1 ≥ 0.7, so we include this term. 1 2 = 2; 2 ≥ 0.7, so we include this term. 2; 2 ≥ 0.7, so we include this term. 1.333...; 1.333... > 0.7, so we include this term. 4 IS 8 6 16 = 0.666...; 0.666... < 0.7, so we do not include this or any subsequent term. = 4! 24 So exponent (2.0, 0.7) must return 1+2+2+1.333... ≈ 6.3333. On the other hand, exponent (2.0, 2.0) must return 0; since the first term of the pattern is less than 2.0, we are adding up no terms. Consider also terms in exponent (1.0, 0.5): xº 1 = O! = 1;1 ≥ 0.5, so we include this term. = 1; 1 ≥ 0.5, so we include this term. 0.5; 1 ≥ 0.5, so we include this term. 2 = = 0.1666...;0.1666 < 0.5, so we do not include this or any subsequent term. 3! 6 So exponent (1.0, 0.5) must return 1 + 1 +0.5 = 2.5. Test your code carefully when x > 0, but also when x < 0. This approximation should work for any value of x.
Expert Answer:
Answer rating: 100% (QA)
Unfortunately I cant execute code but I can certainly guide you on how to write the function in Pyth... View the full answer
Related Book For
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young
Posted Date:
Students also viewed these programming questions
-
I need a report with a specific product from a company Assessment 3: Individual Assignment Marking Criteria Report: Structure and Marking Criteria Executive Summary (5 marks) A well written...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Which of the following statements is correct? a. The left side of a T-account is the credit side. b. Debits decrease asset and expense accounts and increase liability, equity, and revenue accounts....
-
Using the Trust Services Principles and Criteria for the Online Privacy Principle, develop an online privacy policy for Alltel Stadium that could be posted on the stadiums website for customers to...
-
What element reacts in a breeder reactor to breed nuclear fuel?
-
Consider a bank with the following balance sheet, as shown on the next page. You read online that the banks return on assets (ROA) was 1 percent. What were the banks after-tax profits? Bank Balance...
-
Find the general solution of the given equation by the method given. a. \(y^{\prime \prime}-3 y^{\prime}+2 y=10\). Method of Undetermined Coefficients. b. \(y^{\prime \prime}+y^{\prime}=3 x^{2}\)....
-
Presented below is the trial balance of Scott Butler Corporation at December 31, 2014. Instructions Prepare a balance sheet at December 31, 2014, for Scott Butler Corporation. (Ignore incometaxes.)...
-
Yumen XI Limited is a young start-up company. No dividends willbe paid on the stock over the next nine years because the firmneeds to plow back its earning to fuel growth. The company will paya $8 2...
-
You are the project manager for a new web-based online shopping system. Due to market competition, your management has directed you to go live with your systems one week earlier than originally...
-
Morgana Ltd is preparing its consolidated statement of cash flows for the year ended 30 June 2021. The following summarised information is taken from the consolidated statements of financial position...
-
The capital structure of a company during the whole of this current financial year has been as follows: Ordinary Shares $1 fully paid - market value $800,000 6% debentures ($100 par value) $212,000...
-
Cullumber Company is considering purchasing new equipment for $452,400. It is expected that the equipment will produce net annual cash flows of $58,000 over its 10-year useful life. Annual...
-
You are purchasing call options. You have gathered the following information: Number of options purchased 1,100 Strike Price of Option $35.84 Option Price $5.04 Share Market Price $37.52 Required...
-
If the TP overpays her 2023 Federal tax liability by $5,200, but wants to apply $3,000 of the overpayment to her 2024 estimated Federal income tax liability, then she should enter $3,000 on:
-
Assets Cash 2004 $31.000 18,000 27,000 80,000 (30,000) $126,000 2003 $ 20,000 14,000 20,000 78,000 (24,000) $108,000 Accounts receivable Merchandise inventory Property, plant, and equipment...
-
First, Ricki and Sam, are not familiar with tax rules so they would like a little background regarding what Bonus Depreciation really is and what the impact is on the business. While they have...
-
1. What are some current issues facing Saudi Arabia? What is the climate for doing business in Saudi Arabia today? 2. Is it legal for Auger's firm to make a payment of $100,000 to help ensure this...
-
Why do companies producing a varied and complex mix of products have higher costs than companies producing only a narrow range of products?
-
What type of organization is best suited to incentive compensation? Why?
-
What does financial control mean?
-
The trial balance of Jeremina plc as at 31 March 2002 is as follows: (i) Stock of finished goods on 31 March 2002 163,000. (ii) Motor expenses and depreciation on motors to be apportioned:...
-
You are Br erired: with the following information relating to Plott plc for the year to 31 March 2011: Additional information: 1. The above information has been obtained after the compilation of the...
-
The following information has been extracted from the books of Quire plc as at 30 September 2011. The following additional information is to be taken into account: 1. Stocks at 30 September 2011 were...
Study smarter with the SolutionInn App