title: IndexError: index 3 is out of bounds for axis 0 with size 3
body: <p>So this is my code to plot a Bézier curve:</p>
  
  <pre><code>def bezier(a):
      n = np.shape(a)[0]-1
          # initialise arrays
      B = np.zeros([101, 2])
      terms = np.zeros([n+1, 2])
          # create an array of values for t from 0 to 1 in 101 steps
      t = np.linspace(0, 1, 101)
          # loop through all t values
      for i in range(0, 101):
              #calculate terms inside sum in equation 13
              for j in range(0, n + 1):
                  # YOUR CODE HERE
                  terms[j,:] = ((1 - t[i]) ** 3 * a[0,:] \
                             + 3 * t[i] * (1-t[i]) ** 2 * a[1,:] \
                             + 3 * t[i] ** 2 * (1-t[i]) * a[2,:] 
                             + t[i] ** 3 * a[3,:])
          #sum terms to find Bezier curve
      B[i, :] = sum(terms, 0)
          # plot Bezier
      pl.plot(B[:, 0], B[:, 1])
          # plot control points
      pl.plot(a[:, 0], a[:, 1],'ko')
          # plot control polygon
      pl.plot(a[:, 0], a[:, 1],'k')
      return B 
  </code></pre>
  
  <p>And when I try to pass it some control points:</p>
  
  <pre><code>a = np.array([[0, 0], [0.5, 1], [1, 0]])
  B = bezier(a)
  </code></pre>
  
  <p>I receive this IndexError:</p>
  
  <pre><code>---------------------------------------------------------------------------
  IndexError                                Traceback (most recent call last)
  &lt;ipython-input-16-fce87c9f1c04&gt; in &lt;module&gt;()
        1 a = np.array([[0, 0], [0.5, 1], [1, 0]])
  ----&gt; 2 B = bezier(a)
  
  &lt;ipython-input-13-3bb3bb02cc87&gt; in bezier(a)
       11            for j in range(0, n + 1):
       12                # YOUR CODE HERE
  ---&gt; 13                terms[j,:] = ((1 - t[i]) ** 3 * a[0,:] + 3 * t[i] * (1-t[i]) ** 2 * a[1,:] + 3 * t[i] ** 2 * (1-t[i]) * a[2,:] + t[i] ** 3 * a[3,:])
       14        #sum terms to find Bezier curve
       15    B[i, :] = sum(terms, 0)
  
  IndexError: index 3 is out of bounds for axis 0 with size 3
  </code></pre>
  
  <p>So I figure it is trying to access something outside the container but I can't see where it is I need to change the code.</p>