Initializing u and sum
var sum = y [ n - 1 ] [ 0 ] ; var u = ( value - x [ n - 1 ] ) / ( x [ 1 ] - x [ 0 ] ) ; for ( var i = 1 ; i < n ; i ++ ) { sum = sum + ( u_cal ( u , i ) * y [ n - 1 ] [ i ] ) / fact ( i ) ; } document . write ( " " + value + " " + sum ) ;