Page 1 of 1

No import modules are allowed, **Python Code Only

Posted: Mon Jun 06, 2022 6:47 pm
by answerhappygod
No import modules are allowed, **Python Code Only
No Import Modules Are Allowed Python Code Only 1
No Import Modules Are Allowed Python Code Only 1 (55.94 KiB) Viewed 13 times
5. Below mentioned is the Maclaurin series for the exponential function ex. Summing higher number of terms provides better approximation. Σ==1+*+ x² x³ x4 = 1 + x + + + + ... = ex 2! 3! 4! n! n=0 where "!" represents the factorial such as 1!=1,2!=2 x 1=2,3!=3 x 2 x 1=6 and so on. Define a Python function seriesexp (x, tol) which, given numerical values x and tol, returns the sum of the above series for input x till the absolute value of the term becomes smaller than tol. For example, seriesexp (1,0.1) returns 2.66666 which is obtained by adding first four terms only because the absolute value of fifth term 1/4! becomes smaller than the input to the function 0.1 i.e. (1/24) <0.1