title: Newton Raphson method JavaScript
body: <p>I try to do a Newton Raphson method with JS.
  I did that code but, on this code the polinomy it's defined and  I need to pass manually.
  I don't know how I can put a polinomy manually. Please any idea... :(</p>
  
  <pre><code>&lt;script language="javascript"&gt;
          function funcion(x)
          {
              return  Math.cos(x) - x * x * x;
          }
          function derivada(x)
          {
              return -Math.sin(x) - 3.0 * x * x * x;
          }
          function procesar(formulario)
          {
              var i = 0;
              var err, x_1, x = parseFloat(formulario.x.value);
              var resultado = '&lt;table border="1"&gt;&lt;thead&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;&lt;/thead&gt;&lt;tbody&gt;';
              do
              {
                  x_1 = x;
                  x = x - funcion(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>
  
  <p>That's my html:</p>
  
  <pre><code>&lt;body&gt;
    &lt;h1 align="center"&gt;Metodo de Newton-Raphson&lt;/h1&gt;
  
  
    &lt;form name="formulario" onsubmit="return procesar(this);"&gt;
      Ingrese la función
      &lt;input name="x" type="text" size="4" /&gt;
      &lt;input type="submit" value="Procesar" /&gt;
    &lt;/form&gt;
  
  
    &lt;/br&gt;
    &lt;/br&gt;
    &lt;/br&gt;
    &lt;table align="center" bgcolor="white"&gt;
      &lt;tr&gt;
        &lt;th&gt;
  
          &lt;br/&gt;
          &lt;div id="resultado"&gt;&lt;/div&gt;
  
        &lt;/th&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/body&gt;
  </code></pre>