Convert Mathematica equations into R code

我怕爱的太早我们不能终老 提交于 2019-12-12 11:19:19

问题


Is there an easy way to convert Mathematica equations into R code? I have several equations that consist of dozens of terms with subscripts, superscripts, and greek letters. For example, here's a small part of one equation in Latex format:

m_2_2= 48 b_1 c_2^2 d_1 \rho ^4+48 b_2 c_1^2 d_2 \rho ^4+216 b_2 c_1 c_2 d_1 \rho ^3+216 b_1 c_1 c_2 d_2 \rho ^3+96 b_1 c_2^2 d_1 \rho ^2+96 b_2 c_1^2 d_2 \rho ^2 + ...

I can copy from Mathematica as plain text, input text, Latex, or MathML, but how can I get any of those formats to work in R with all of the subscripts, superscripts, and greek? Unfortunately, the equations are so long that retyping manually would likely result in errors. Any suggestions?


回答1:


There is builtin support for exporting expressions to Fortran and C. I suggest you export the expression to C and then edit the C expression.

Details here: https://reference.wolfram.com/language/tutorial/GeneratingCAndFortranExpressions.html



来源:https://stackoverflow.com/questions/29952792/convert-mathematica-equations-into-r-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!