title: Eigenvalues of symmetric 2 by 2 matrix in terms of variables \
body: <p>So given a symmetric matrix like of the form: </p>
  
  <pre class="lang-py prettyprint-override"><code>[[a,c]
  [c,b]]
  </code></pre>
  
  <p>One can get the eigenvalues with a general expression provided by the following function: </p>
  
  <pre class="lang-py prettyprint-override"><code>def get_eigenvals(a,b,c):
      e1 = 0.5*(a + b + ((a-b)**2 + 4*c**2)**(1/2))
      e2 = 0.5*(a + b - ((a-b)**2 + 4*c**2)**(1/2))
      return(e1,e2)
  </code></pre>
  
  <p>But if I input <code>a</code>,<code>b</code> and <code>c</code> that contain variables, how could I get the eigenvalues in terms of the same variables? For example if I set <code>a = 5D</code>, <code>D</code> being the variable, how can I then have my eigenvalues returned as expressions containing <code>D</code>? </p>
  
  <p>This is easy to implement in a program like Mathematica, but I'm wondering if there's a way of doing it in Python.</p>