4
4
"""
5
5
6
6
7
- def logarithmic_series (x : float , n_terms : int = 5 , expand : bool = False ) -> list :
7
+ def logarithmic_series (x_value : float , n_terms : int = 5 , expand : bool = False ) -> list :
8
8
"""
9
9
Returns the logarithmic series for a number x (log x) upto n terms.
10
10
11
11
Parameters:
12
- x : a floating point number for log(x)
12
+ x_value : a floating point number for log(x)
13
13
n_terms: number of terms to be computed
14
14
expand: Set this flag to get the terms as real numbers,
15
15
unset for unsolved expressions
@@ -27,16 +27,16 @@ def logarithmic_series(x: float, n_terms: int = 5, expand: bool = False) -> list
27
27
>>> logarithmic_series(3, expand=True)
28
28
[2.0, -2.0, 2.6666666666666665, -4.0, 6.4]
29
29
"""
30
- n_times_x_minus_1 : float = x - 1
30
+ n_times_x_minus_1 : float = x_value - 1
31
31
n : int = 1
32
32
series : list = []
33
33
for _ in range (n_terms ):
34
34
if expand :
35
35
series .append (((- 1 ) ** (n + 1 )) * (n_times_x_minus_1 / n ))
36
- n_times_x_minus_1 *= x - 1
36
+ n_times_x_minus_1 *= x_value - 1
37
37
else :
38
38
sign : str = "-" if (- 1 ) ** (n + 1 ) == - 1 else ""
39
- term : str = sign + "(" + str (x - 1 ) + "^" + str (n ) + ")" + "/" + str (n )
39
+ term : str = sign + "(" + str (x_value - 1 ) + "^" + str (n ) + ")" + "/" + str (n )
40
40
if term .startswith ("-(-" ):
41
41
term = "(" + term [3 ::]
42
42
elif term .startswith ("(-" ):
0 commit comments