var inc = .001;
var z = new Array(1.0/inc);
for (var x = 0.0; x < 1.0; x += inc) {
z.push(Math.cos(x));
}
var y = new Array(1.0/inc);
for (x = 0.0; x < 1.0; x += inc) {
y.push(1 - ((x * x) / 2) + ((x * x * x * x) / 24));
}
var sum = 0;
for (var i = 0; i < (1.0/inc); i++) {
sum += y[i] - z[i];
}
console.log(sum);
console.log(sum/(1.0/inc));
I'm pretty new to Javascript, but the arrays here are filled with floats and when I take the difference and try to print them it returns NaN. I'm stumped here. Here's a fiddle with the code (http://jsfiddle.net/2v7wu/). Thanks!