1 2 3
function costFunctionJ(t, t1, t2) { return +(0.5 / t.length * t.reduce(function(a, b) { return a + Math.pow(t1 + t2 * b[0] - b[1], 2) }, 0) + 0.0001).toFixed(3); }