A gradient descent lab

The problem

Build a small optimizer in plain Python that minimises functions of one and two variables, checks its own derivatives numerically, and shows how the learning rate decides between fast convergence, slow progress and divergence.

Requirements

Technologies

Step by step

  1. Write f, its exact gradient and a numerical gradient, and compare them at a few points.
  2. Write the gradient descent loop with a tolerance and a step limit.
  3. Run it with a small, a good and a too-large learning rate and record the results.
  4. Print a table of rate, steps and final value and explain each row in a sentence.

Expected result

A short program and table showing that the same method converges, crawls or diverges depending on the learning rate.

How it is evaluated

Ways to improve it