A sample cost function implementation to be used by Octave's advanced optimization algorithm fminunc.