title: Newton Raphson method JS+html
body: <p>Need help, because I have an error in my code and I can't see it.</p>
  
  <p>I'm trying to do a newton raphson method.</p>
  
  <p>The user enters a polinomy and the function calculates the derivate, then applys the Newton's raphson formula and shows the final result in a table.</p>
  
  <p>My problem is that I can't make it work, because I can't show the final table with the results.</p>
  
  <p>See an example here: <a href="http://codepen.io/anon/pen/Qyddoy?editors=101" rel="nofollow">http://codepen.io/anon/pen/Qyddoy?editors=101</a></p>
  
  <p>Thats my JS code.</p>
  
  <pre><code>function funcion(func, x) {
      var nuevaFuncion= func.replace(/x/g, x);
      return eval(nuevaFuncion);
  }
  
  
  function derivada(x) {
      var func = document.getElementsByName("func")[0].value.trim();
      var derivative = nerdamer('diff(' + func + ')').evaluate();
  }
  
  function procesar(formulario) {
      var i = 0;
      var func = document.getElementsByName("func")[0].value;
      var err, x_1, x = parseFloat(formulario.x.value);
      var resultado = '&lt;table border="3"&gt;&lt;tr&gt;&lt;td align="center"&gt;i&lt;/td&gt;&lt;td align="center"&gt;x&lt;sub&gt;&lt;/sub&gt;&lt;/td&gt;&lt;td align="center"&gt;error&lt;/td&gt;&lt;/tr&gt;';
      do {
          x_1 = x;
          x = x - funcion(func, x) / derivada(x);
          err = Math.abs((x - x_1) / x);
          resultado += '&lt;tr&gt;&lt;td&gt;x&lt;sub&gt;' + i + '&lt;/sub&gt;&lt;/td&gt;&lt;td&gt;' + x_1 + '&lt;/td&gt;&lt;td&gt;' + err + '&lt;/td&gt;&lt;/tr&gt;';
          i++;
      } while (x != x_1 &amp;&amp; i &lt; 100);
      document.getElementById('resultado').innerHTML = resultado + '&lt;/tbody&gt;    &lt;/table&gt;&lt;br&gt;' + (i == 100 ? 'La solucion no es convergente. ' : 'La solucion es ' + x);
  return false;
  }
  </code></pre>