微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

具有上下索引的方程的 Smypy 打印格式

如何解决具有上下索引的方程的 Smypy 打印格式

我有一个类似这样的代码

print("Gamma^",syms[i],"_",syms[j],syms[k],"=",syms[1],syms[2]**2)

当我在 jupyter-lab 中打印时,它看起来像这样

Gamma^ r _ phi phi = r theta**2
Gamma^ theta _ r theta = r theta**2
Gamma^ theta _ theta r = r theta**2
Gamma^ theta _ phi phi = r theta**2
Gamma^ phi _ r phi = r theta**2
Gamma^ phi _ theta phi = r theta**2
Gamma^ phi _ phi r = r theta**2
Gamma^ phi _ phi theta = r theta**2

有没有办法让它变成这样

enter image description here

或至少非常相似

解决方法

我能够获得类似的东西

Gamma = IndexedBase('Gamma')
phi,theta,r = symbols('phi,r')
display(Eq(Gamma[phi,theta]**phi,r*theta**2))

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。