开发者

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 wou开发者_运维技巧ld 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++)?


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.


I've never seen such a thing. Most mathematical notation is written to be understood by a person of (at least) reasonable intelligence, so it frequently omits all sorts of details that would be necessary to produce working code. If you had such a tool, I doubt it would produce usable results more than (maybe) 10% of the time.

The reverse seems a great deal more tenable -- producing readable mathematical notation from code (especially from something like Matlab) sounds much more reasonable. It's much easier to omit information that's present than to try to synthesize information that's missing.


There is a codeproject article about Converting math equations to C# expressed as MathML


It's not possible. Generally, mathematical expressions in papers are made for humans to understand, as Jerry Coffin said. Because of this, there are all sorts of issues. One I think off the top of my head is optimality. (Mathematical) code for human consumption is rarely optimal, bad example is the Fibonacci sequence. Nobody would write Fibonacci code as humans understand it.

So, even if you did get the code parsed, you'll still have so much work to do it's the same as just writing it yourself.


The question is based on a core assumption - computers do everything better. This is not the case.

Computers and specifically computational machines tend to do iterative tasks better than humans and cognitive tasks worse. Is the maths you're trying to convert iterative or cognitive? If its iterative then the standard procedure - for x do n times or while (criterion) do etc... would be simple to use for iterative tasks. If you're delving into AI and machine learning there is a wealth of information out there as to how computers are supposed to do AI and do it well. I'm assuming that the questioner is asking for help from a cognitive sense and not iterative. Hence the problem - and lack of solution. If the task is cognitive to implement then computational machines will not help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜