expanded to use the correct objective and the questionably correct derivative.  Added in a procedure to test correctness versus random weights and uniform weights.  Still has an error somewhere, though, probably a divide by 0 error.