rm-hull / newtons-method.cljs
Last updated

Newtons method (also know as the Newton-Raphson method) is a textbook example of an iterated method for finding successively better approximations to the roots (or zeroes) of a real-valued function. This program calculates the square root using anonymous recursion by way of the fixpoint combinator (a.k.a. Haskell Curry's paradoxical Y-combinator) which satisfies $y f = f (y f)$. By setting $x = y f$, it represents a fixed-point of the equation $x = f x$. The Newton-Raphson method can easily be implemented in terms of the Y-combinator as shown below. The helper functions are taken from SICP §1.1.7

Fork me on GitHub!