title: How to calculate matrix roots using the characteristic polynomial using Lua
body: <p>I am trying to code <a href="https://www.mathworks.com/help/matlab/ref/eig.html#btifddh-2" rel="nofollow noreferrer">eig</a> myself, but I am having trouble with calculating the characteristic polynomial <code>(A-XI)</code> to get the roots of the matrix. I know how to do that by hand, and it is quite easy. The Lua interpreter cannot just <code>shove</code> an additional string in the matrix's elements if I first do not convert them from strings to numbers then concatenate <code>-X</code> at the main diagonal.</p>
  
  <pre><code>[1-X,   2,   3]
  [  4, 5-X,   6]
  [  7,   8, 9-X]
  </code></pre>
  
  <p>How can I get the matrix roots without bothering doing any symbolic decompositions and dynamic calculations or compilations?</p>