title: How to plot the slope (tangent line) of parabola at any point?
body: <p>I want to plot a simple illustration of using derivative to find out a slope of a function at any point. It would look kinda like this:</p>
  
  <p><a href="https://i.stack.imgur.com/3PK1q.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3PK1q.png" alt=""></a></p>
  
  <p>I have already plotted a simple parabola using this code:</p>
  
  <pre><code>import numpy as np
  from matplotlib import pyplot as plt
  
  inputs = 0.2
  weights = np.arange(-6,14)
  target_prediction = 0.7
  
  prediction = inputs*weights
  errors = (prediction - target_prediction) ** 2
  plt.xlabel("Weight")
  plt.ylabel("Error")
  plt.plot(weights, error)
  </code></pre>
  
  <p>Now I want to add something like this:</p>
  
  <pre><code>current_weight = 5
  # draw a short fraction of a line to represent slope
  x = np.arange(optimal_weight - 3, optimal_weight + 3)
  # derivative
  slope = 2 * (inputs*current_weight - target_prediction)
  y = slope*x # How should this equation look like?
  plt.plot(x, y)
  </code></pre>
  
  <p>To draw a tangent line going through the <code>current_weight</code>.</p>
  
  <p>But I can't seem to figure this out, can you help?</p>