Code from my Numeric Method book. [written in Matlab]