使用 SymPy 包打印产品符号 (∏) [英] Print a symbol for product (∏) by using SymPy package

查看:36
本文介绍了使用 SymPy 包打印产品符号 (∏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用 Python 中的 SymPy 包打印这张图片中的符号.

I would like to know how to print the symbols in this picture by using SymPy package in Python.

推荐答案

符号积是用 Product(expr, (index, low, high)) 创建的,其中 high与大多数 Python 代码不同,它包容.例如:

Symbolic products are created with Product(expr, (index, low, high)) where high is inclusive unlike in much of Python code. For example:

P00 = IndexedBase("P^{00}")
P02 = IndexedBase("P^{02}")
i = Idx("i")
t = symbols("t")
expr = Product(P00[i]*P02[t], (i, 1, t-1))
print(expr)

打印(假设 LaTeX 支持)为

which prints (assuming LaTeX support) as

索引的放置是次优的;问题是上标被硬编码到符号名称中,而不是实际提出的索引.但我没有看到告诉 SymPy 将某些索引打印为上标的方法.

The placement of indices is suboptimal; the issue is that the superscripts are hardcoded into symbol names instead of being actual raised indices. But I don't see a way to tell SymPy to print certain indices as superscripts.

这篇关于使用 SymPy 包打印产品符号 (∏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆