We can use a generic fixed-point program to implement Newton's method. Functions that build functions. Numerical derivatives are a handy tools, so lets add one to enhance our implementation of Newton's method. Local variables, local functions. More complicated functions have both local variables and local functions.
Local functions avoid the tendency to have lots of helper functions lying around.
They serve no other purpose than but to help another function, so we'll embed them in the main function, hiding their presence. Newton's method is easy. We'll handle this via two numerical derivatives. Going without a derivative is harder, but golden section searches are a fast alternative. These converge as fast as is possible to the max of a unimodal function, without needing a derivative.