Given a function fr from real numbers to real numbers. Program a higher-order function derivative, which differentiates a function like fr.
In this exercise you are asked to work numerically, in order to approximate the function. This stands as a contrast to symbolic differentiation.
As examples, (derivative (lambda (x) (* x x))) should behave (almost) as (lambda (x) (* 2 x)); (derivate sin) should behave almost as cos; and (derivate exp) should behave almost like exp itself.
Write a function compare-2-functions
(compare-2-functions f1 f2 numerical-input-list)
which applies f1 and f2 on elements in numerical-input-list, and outputs a list of differences between f1(x) and f2(x) for x in numerical-input-list. Use compare-2-functions to compare (derivative f) and f'.
The inspiration to the exercise comes from Christian Wagenknecht's book 'Programmierparadigmen', from Springer Verlag.