Numpy is giving array containing list of 2 raised to natural numbers as negative values. How can 2 raised to positive numbers like 1000 be negative?
I have an array 'x' that we use to plot x-axis value from 1 to n. We take x**(2**x) i.e x raised to (2 raised to x) for each value in array x and use it as y axis value.
Case 1: For x ∈ [1, 50)
I have used the code below, and the output is proper as there are no negative values in the output of np.power(2, x).
x = np.array([x for x in range(1, 50)])
print(np.power(2, x))
x2x = np.power(x, np.power(2, x))
plt.plot(x, x, label = 'f(n) = n')
plt.plot(x, x2x, label = 'f(n) = x**(2**x)')
plt.legend()
plt.show()
Output:
Case 2: For x ∈ [1, 100)
I have used the code below, and the output is having negative values in the output of np.power(2, x) and so np.power(x, np.power(2, x))
x = np.array([x for x in range(1, 100)])
print(np.power(2, x))
x2x = np.power(x, np.power(2, x))
plt.plot(x, x, label = 'f(n) = n')
plt.plot(x, x2x, label = 'f(n) = x**(2**x)')
plt.legend()
plt.show()
Output:
If x is always positive and non-decreasing and 2 is constant and positive then why is 2 raised to positive number getting negative output in numpy?