function f(x) { return Math.pow(2, 2 * Math.sqrt(25 - x * x)) } var a = 0, b = 5, n = 100, h = (b - a)/n, S = 0; for (var j = 0; j < n; j++) { S += (f(a + j*h) + f(a + (j+1)*h))/2 * h } alert(S);