Very good to all, I've been trying for a while and nothing ... could someone correct me and tell me what my mistake is? all the code works well, the error is in wanting to take the values of the form, that's what does not work for me.
<!DOCTYPE html>
<html>
<head>
<title>Metodo de bisecion</title>
</head>
<body>
<h2>La funcion a iterar es: 6x^3-2x^2-x-1 = 0 en [0.5, 1]</h2><br><br>
<script type="text/javascript">
var n, an, fan, bn, fbn, pn, fpn;
n = 1;
an = parseFloat(document.getElementById("an").value);
bn = parseFloat(document.getElementById("bn").value);
//Comienza la iteracion
function biseccion(){
do {
pn = (an+bn)/2;
fpn =Math.abs((6*(Math.pow(pn, 3))) - (2*(Math.pow(pn, 2))) - pn - 1);
document.write(" | " + n + " | " + an + " | " + bn + " | " + pn + " | " + fpn + " | " + "<br><br>");
fpn =(6*(Math.pow(pn, 3))) - (2*(Math.pow(pn, 2))) - pn - 1;
fan =(6*(Math.pow(an, 3))) - (2*(Math.pow(an, 2))) - an - 1;
if (fpn*fan > 0) {
an = pn;
bn = bn;
}
else if (fpn*fan < 0) {
bn = pn;
an = an;
}
else{
alert("No se pudo determinar");
}
fpn =Math.abs((6*(Math.pow(pn, 3))) - (2*(Math.pow(pn, 2))) - pn - 1);
n++;
} while (fpn > 0.0001);
};
</script>
<!-- Formulario para ingresar intervalo de valores -->
<form>
a:<input type="text" id="an"><br><br>
b:<input type="text" id="bn"><br><br>
<input type="button" value="Comenzar iteraciones" onclick="biseccion()">
</form>
</body>
</html>