For26. A real number X (|X| < 1) and an integer N (> 0) are given. Find the value of expression
\(X - X^3/3 + X^5/5 - ... + (-1)^N \cdot X^{2 \cdot N +1}/(2 \cdot N +1).\)
The number obtained is an approximate value of the function arctg at the point X.

Solution in Python 3:

import math
X = 0.8
N = 20
print('X = ', X)
print('N = ', N)

p = X
S = X
k = 1
for i in range(1,N+1):
p *= -1*X*X
k += 2
S += p/k
print(i," : ",k," : ",p," : ",S)

print("Result:")
print(S)
print("atan(x):")
print(math.atan(X))