awk ' /^[^#]/{ # skip commented lines if(nfu0){ dxhalf=0.5*(y[1]-oldy[1]) # perhaps a check that dxhalf>0 should be added... for(i=2;i<=nfu;i++){ integral[i]+=(y[i]+oldy[i])*dxhalf # trapezoidal integration # print "debug", y[2],oldy[2],"aa",integral[2],"bb",integral[1] } } oldx=$1 # only used for triggering the first step for(i=1;i<=nfu;i++){ oldy[i]=y[i] } printf "%s",y[1]; for(i=2;i<=nfu;i++){printf "\t%20.17g",integral[i];} printf "\n" }' $* # writes the primitives of functions f_i(x) given a x-sorted data file # x=$1 f_1(x)=$2 f_2(x)=$3 ... # version 1.3 - July 2025 - Nicola Manini