function integratrapezio(){ var elmbasea = document.getElementById("valoresdex").value; var elemb = document.getElementById("valoresdey").value; var elemquant = +document.getElementById("valoresden").value; var k = (elmbasea-elemb)/elemquant; var n = elemquant+1; var elemk = k/2; var f = "f(x)"; var c; for (j=1;j<n; j++){ var i=j-1; if ((i = 0)){c=1;}else{c=2;} var x=elmbasea+i*k; var funcao = eval(+f+); var calculodafuncao=calculodafuncao+c*funcao; } alert("o Resultado a = 1/2bh"+x+c); var total=elemk*calculodafuncao; /*qualcular a função f = (x) https://www1.univap.br/spilling/CN/CN_Capt6.pdf*/ if(document.getElementById('resultFunc').style.visibility = 'hidden'){document.getElementById('resultFunc').style.visibility = 'visible';} document.getElementById('resultFunc').innerHTML = total.toFixed(2); }