Mathematica代码转换为Python

2024-01-09
#Mathematica #Python

Python 代码:

from sympy.parsing.mathematica import parse_mathematica
from sympy import var

# 1. Defined symbols
x, y, z = var('x y z')

# 2. Transform
a = "Cos[x]*Sin[y]*z^2"  # Mathematica代码
print(parse_mathematica(a))

显示:

z**2*sin(y)*cos(x)

延伸阅读