Search code examples
c++mathmatlabwolfram-mathematica

Methods to convert mathematical formulas into code in Matlab, C++, etc?


I have a basic question for all of the math experts out there.

"If I have an academic paper, whats the easiest way to convert a simple mathematical equation into working Matlab (or C++) code?"

Ideally, there would be a Latex >> Matlab (or C++) conversion tool.

However, failing this, is there a "cheat sheet" which contains all of the common mathematical symbols, and their equivalent implementation keywords in Matlab (or R, or C++)?


Solution

  • Use Mathematica Symbolic Computation.

    You can enter mathematical equations straight into Mathematica, then export the result as C code.

    Keep tweaking the equation until the rendering looks identical to the original equation in the academic paper. You can then plug your own parameters in, and Mathematica will calculate the result for you.

    You can even do cool things such as ask it to differentiate the equation - and it will produce the differential, and printout the resulting equation.

    You can call Mathematica from any language, including .NET, Q, Python, Java, etc.

    You could even compile the Mathematica program into a .NET assembly and embed it into your app.

    Mathematica will also emit Java or C code that matches the mathematical formula you have just entered.