Skip to content

Commit 3f47a1f

Browse files
authored
Update logarithmic_series.py
1 parent 273ee44 commit 3f47a1f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

maths/series/logarithmic_series.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"""
55

66

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:
88
"""
99
Returns the logarithmic series for a number x (log x) upto n terms.
1010
1111
Parameters:
12-
x: a floating point number for log(x)
12+
x_value: a floating point number for log(x)
1313
n_terms: number of terms to be computed
1414
expand: Set this flag to get the terms as real numbers,
1515
unset for unsolved expressions
@@ -27,16 +27,16 @@ def logarithmic_series(x: float, n_terms: int = 5, expand: bool = False) -> list
2727
>>> logarithmic_series(3, expand=True)
2828
[2.0, -2.0, 2.6666666666666665, -4.0, 6.4]
2929
"""
30-
n_times_x_minus_1: float = x - 1
30+
n_times_x_minus_1: float = x_value - 1
3131
n: int = 1
3232
series: list = []
3333
for _ in range(n_terms):
3434
if expand:
3535
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
3737
else:
3838
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)
4040
if term.startswith("-(-"):
4141
term = "(" + term[3::]
4242
elif term.startswith("(-"):

0 commit comments

Comments
 (0)