wrote some Python code to plot the coordinates of simple one dimensional linear mapping using matplotlib
Can someone tell me what's wrong with my code?
import matplotlib.pyplot as plt
import numpy as np
result = [10]
result[0] = 1
a = 1.1
x = np.linspace(0, 10, 10)
for i in range(len(result)):
result[i+1] = a*(result[i] - 1/2) + 1/2
plt.plot(x, result[i], 'ro')
plt.xlim(0, 10)
plt.ylim(0, 10)
plt.axhline(0, color='b', ls='-', lw=0.5)
plt.axvline(0, color='b', ls='-', lw=0.5)
plt.xlabel(r'$x$', fontsize=18)
plt.ylabel(r'$x_{n+1}$', fontsize=18)
plt.title(r'Graphs of $x_{n+1} = a(x_{n}-\frac{1}{2}) + \frac{1}{2}$', fontsize=20)
plt.show()
error message
Traceback (most recent call last):
y[i+1] = a*(y[i] - 1/2) + 1/2
IndexError: list assignment index out of range