title: Solving a linear-quadratic system of equations, both graphically and numerically, in numpy/matplotlib?
body: <p>I have a system of a linear equation and a quadratic equation that I can set up with <code>numpy</code> and <code>scipy</code> so I can get a graphical solution. Consider the example code:</p>
  
  <pre class="lang-python prettyprint-override"><code>#!/usr/bin/env python
  # Python 2.7.1+
  
  import numpy as np #
  import matplotlib.pyplot as plt #
  
  # d is a constant;
  d=3
  # h is variable; depends on x, which is also variable
  
  # linear function:
  # condition for h: d-2x=8h; returns h
  def hcond(x):
    return (d-2*x)/8.0
  
  # quadratic function:  
  # condition for h: h^2+x^2=d*x ; returns h
  def hquad(x):
    return np.sqrt(d*x-x**2)
  
  # x indices data
  xi = np.arange(0,3,0.01)
  
  # function values in respect to x indices data
  hc = hcond(xi)
  hq = hquad(xi)
  
  fig = plt.figure() 
  sp = fig.add_subplot(111)
  
  myplot = sp.plot(xi,hc)
  myplot2 = sp.plot(xi,hq)
  
  plt.show()
  </code></pre>
  
  <p>That code results with this plot:</p>
  
  <p><img src="https://i.stack.imgur.com/CV5An.png" alt="test02.png"></p>
  
  <p>It's clear that the two functions intersect, thus there is a solution. </p>
  
  <p>How could I automatically solve what is the solution (the intersection point), while keeping most of the function definitions intact? </p>