Added function for U, and made an IMPORTANT bug fix.

OK, I think that this calculates U correctly.  Also, I changed things
in g and U, calling the returned arrays __g__ and __U__, respectively.
This is because I think there will be major problems if an object is
defined inside a function with the same name.