Made a start on gradient descent

Not ready to merge yet as it's not clean enough. Just putting it here so others can see what I'm doing.