No import modules are allowed, **Python Code Only
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
No import modules are allowed, **Python Code Only
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am