### IntDiff.BC - numeric differentiation and integration of ### a single variable function ## Not guaranteed for any particular purpose define f(x) { return x^2 } # example - redefine in later code/bc session # Numerically differentiate the global function f(x) define dfxdx(x) { auto eps, os; os = scale scale = 0 eps = os/2 scale = os eps = 10^-eps return (f(x+eps)-f(x-eps))/(2*eps) } # New global variable like 'scale' - determines accuracy of numerical # integration at the expense of time. Don't set above 15 unless this # is running on a really fast machine! depth = 10 # Numerically integrate the global function f(x) between x = a and x = b define ifxdx(a,b) { auto h,s,t h = 2^-depth s = (b - a) * h for(i=a+s;i