Changed some 1/2 to 0.5 for speed purposes
Fixed grid spacing; had dx=x_max/n, now have dx=x_max/(n-1), where n is the number of points