first full version of C code implementing the analytic solution