title: A function for calculating the eigenvalues of a matrix in R
body: <p>I want to write a function like <code>eigen()</code> to calculating eigenvalues and eigenvectors of an arbitary matrix. I wrote the following codes for calculation of eigenvalues and I need a function or method to solve the resulted linear equation.</p>
  
  <pre><code>eig &lt;- function(x){
         if(nrow(x)!=ncol(x)) stop("dimension error")
            ff &lt;- function(lambda){
                  for(i in 1:nrow(x)) x[i,i] &lt;- x[i,i] - lambda
                  }
  det(x)
  }
  </code></pre>
  
  <p>I need to solve <code>det(x)=0</code> that is a polynomial linear equation to find the values of <code>lambda</code>. Is there any way?</p>