documentation
now crash if nans in input