1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef BASE_MATH_H #define BASE_MATH_H internal f32 f(f32 d) { return d * d; } internal f32 derivative(f32 x, f32 (*f)(f32)) { f32 h = 1e-6; // small interval to differnetiate the scope return (f(x + h) - f(x - h)) / (2.0 * h); } #endif