make lua generate gnuplot commands

Actually a bit more maintainable
stop using globals
add midpoint euler method + fix missing method