如何将数学公式转换为Python代码? [英] How to convert Math Formula to Python code?
问题描述
有没有简单的方法可以将数学公式转换为Python代码? 也许是翻译人员,网络参考资料,特定的书籍章节或其他内容〜
Are there any easy ways to convert mathematical formulas to Python code? Perhaps translators, web reference, specific book chapters, anything ~
对于正则表达式,有诸如 Kodos 之类的程序以及诸如
For regular expressions there are programs such as Kodos and sites such as pythonregex.com, so I was hoping there would be something similar for formula notation and Python.
推荐答案
否,这通常是不可能的.有些数学函数不可计算(例如,请参见 wikipedia/Halting_problem ).在其他数学函数中,如何对其进行编码尚不明显(考虑困难的积分或微分方程).有很多关于找到这类问题的数值解的书(您可以在此处找到一些链接: wikipedia/Numerical_analysis ).
No, this isn't possible in general. There are mathematical functions that aren't computable (for example, see wikipedia/Halting_problem). There are other mathematical functions where it's just not obvious how to code them up (consider a difficult integral or differential equations). There are many books written on finding numerical solutions to these sorts of problems (you can find some links here: wikipedia/Numerical_analysis).
在简单的情况下,您可以直接转录数学公式,但是任何自动翻译方式都需要使用正式的语言来以本身就是编程语言的形式编写数学公式.这将是一个问题,因为您将要用一种语言编写数学公式,而用另一种语言编写数学公式.
For simple cases, you can transcribe mathematical formulae directly, but any automated means of translation would require a formal language for writing mathematical formulae in what would be a programming language in itself. This would beg the question, since you would be trading writing mathematical formulae in one language with writing them in another.
这篇关于如何将数学公式转换为Python代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!