function integratrapezio(){
var elmbasea = document.getElementById("valoresdex").value;
var elemb = document.getElementById("valoresdey").value;
var elemquant = +documentdocument.getElementById("valoresden").value;
var elemfuncao = document.getElementById("valordafuncao").value;
var k = (elmbasea-elemb)/elemquant;
var n = elemquant+1;
+elemquant+1;
var elemk = k+k/2;
var f = "x+2";
var fcont = "f(x)";0;
var c;
for (j=1;j<n; j++){
var i=ji=+j-1;
if ((i === 0)){c=1;}else{c=2;}
var x=elmbasea+i*k;
var funcao = eval(+f+);
var calculodafuncao=calculodafuncao+c*funcao;
x=+elmbasea+i*+k; }
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').innerHTMLfuncao = total.toFixedeval(2elemfuncao);
}
Tentei assim também:
function integratrapezio(){
var m = elmquant+1;
var elm = document.getElementById("result").value;
var elmbase = document.getElementById("valoresdex").value;
var elmaltura = document.getElementById("valoresdey").value;
var elmquant = +document.getElementById("valoresden").value;
var h = (elmbase-elmaltura)/elmquant;
var f = "f(x)";
var c;
for (j=1;j<m; j++){calculodafuncao=cont+c*funcao;
var i=j-1;
if ((icont = 0)){c=1;}else{c=2;}calculodafuncao;
var x=elmbase+i*h;
var pegarfuncao = evalalert(+f+calculodafuncao);
var Ii=Ii+c*pegarfuncao;
}
alert("o Resultado a = 1/2bh"+x+c);
var IR=(h/2)*(Ii);total=+elemk*+calculodafuncao;
/*qualcular a função f = (x) https://www1.univap.br/spilling/CN/CN_Capt6.pdf*/
if(document.getElementById('resultFunc').style.visibility = 'Visible'){document.getElementById('resultFunc').style.visibility = 'hidden';}
if(document.getElementById('resultFunc').style.visibility = 'hidden'){document.getElementById('resultFunc').style.visibility = 'visible';}
document.getElementById('resultFunc').innerHTML = IR.toFixed(2);total;
}