Determine the slope gradient of a collection of points (formula g(3) image)

Given a collection of points that represents a terrain area, find the slope gradient of the area.

Bonus question:

Find the standard deviation from the plane of best fit (formula g(4) image)

Note about formula:

h(hat) notation is common in regression analysis to represent the predicted value based upon the regression equation, in this case:

h(hat) = a(x) + b(y) + c for each pair (x, y)

Test points:

`(setq pts '((0.0 0.0 3785.00)(20.0 0.0 3784.00)(40.0 0.0 3781.00)(60.0 0.0 3777.00)(80.0 0.0 3773.00)`

(0.0 20.0 3769.00)(20.0 20.0 3766.00)(40.0 20.0 3766.00)(60.0 20.0 3768.00)(80.0 20.0 3773.00)

(0.0 40.0 3778.00)(20.0 40.0 3785.00)(40.0 40.0 3793.00)(60.0 40.0 3801.00)(80.0 40.0 3809.00)

(0.0 60.0 3817.00)(20.0 60.0 3824.00)(40.0 60.0 3831.00)(60.0 60.0 3837.00)(80.0 60.0 3842.00)

(0.0 80.0 3847.00)(20.0 80.0 3851.00)(40.0 80.0 3854.00)(60.0 80.0 3857.00)(80.0 80.0 3859.00)))

Slope Gradient (g3) = 1.05571

Standard deviation from plane of best fit (g4) = 13.33468

Values better be correct, I'm told the output results were certified as correct for the program I wrote.