about | help | code help+videos | done | prefs |
Write a method that uses the 'n'-th degree Maclaurin expansion of e to the x, to approximate the value of e to the 'x' for the given 'x' and 'n' values. The Maclaurin expansion of e to the x is the sum of all the terms from k=0 to k='x' of (x^k)/(k!) where "!" is the factorial symbol. Remember that factorial is a form of repeated multiplication such that 4!=4*3*2*1=24 and 5!=5*4*3*2*1=120. You MAY want to write one or more helper methods (or not)! Part of the challenge of this problem is to do things efficiently enough so that you do not cause the test data to time out! THINK FIRST! Preconditions: 'x' and 'n' will be small enough so that overflow errors in the data type 'double' will NOT be an issue. The value of 'n' will be a number from 0 to 50 inclusive. As always, look at the test data! BIG HINT: You MUST consider the efficiency of your approach or you are likely to get timeout errors. quiz2023_12_13_HL_eToTheX(14.0, 0) → 1.0 quiz2023_12_13_HL_eToTheX(-1, 50) → 0.36787944117144245 quiz2023_12_13_HL_eToTheX(-3, 50) → 0.049787068367863986 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy