Trying to solve a computer vision problem, I have to minimize a nonlinear energy function, implementing it in C++. Although I didn't find a library to help me with the specific function, I have the math for it. So what's the best way to go from symbolic math to C++ code?
Example: given the functions g(x):=x^2 and f(x):=x+2, let's imagine I am interested in converting f(g(x)) to C code; the obvious C code would be y=x^2+2; however for complicated math including jacobians, etc, it is not so easy, translating to pages and pages of operations.
I tried already Matlab and it's conversion module to C code, but the code is far from being optimized (ex: same operations repeating many times instead of reusing the result).