在SymPy中获取特定符号

时间:2022-08-11 16:50:36

I am trying to achieve a symbol for the Greek letter nu followed by a prime superscript. This can be achieved easily using LaTeX:

我试图获得希腊字母nu的符号,然后是一个素数上标。使用LaTeX可以轻松实现:

$\nu'$

$ \ NU'$

I tried many variants in SymPy, none of which gave me the right symbol:

我在SymPy中尝试了很多变种,但没有一个给我正确的符号:

nuprime = symbols('{\nu}\'')
nuprime = symbols('{nu}{\'}')
nuprime = symbols('nu\'')
nuprime = symbols('$nu\'$')

To mention a few. How do I get the symbol I am looking for on SymPy?

提一下。如何在SymPy上获得我想要的符号?

EDIT I am using jupyter qtconsole with latex printing. I wish to create the nu prime symbol in this environment.

编辑我正在使用jupyter qtconsole与乳胶印刷。我希望在这种环境中创建nu prime符号。

2 个解决方案

#1


2  

I am not exactly sure in what context you want the symbol to be represented as ν', but for SymPy’s standard display the following works fine:

我不确定在什么情况下你希望符号表示为ν',但对于SymPy的标准显示,以下工作正常:

nuprime = sympy.symbols("ν'")

This makes use of the following:

这使用了以下内容:

  • Python 3 has a straightforward Unicode support.
  • Python 3具有简单的Unicode支持。
  • You can delimit strings by either single or double quotes. Whatever you choose, the respective other character does not need to be escaped.
  • 您可以使用单引号或双引号来分隔字符串。无论您选择什么,都不需要转义相应的其他角色。

#2


0  

I have had some success with the following, though I am not completely sure that I am exactly replicating your circumstances: 1) I opened Jupyter QtConsole 2) I inputted the following code:

我在以下方面取得了一些成功,但我并不完全确定我是在完全复制你的情况:1)我打开了Jupyter QtConsole 2)我输入了以下代码:

import sympy as sp
sp.init_printing(use_latex=True)
nuprime = sp.symbols("\\nu'")
nuprime

This produced the symbol I think you're looking for, at least on my QtConsole.

这产生了我认为你正在寻找的符号,至少在我的QtConsole上。

#1


2  

I am not exactly sure in what context you want the symbol to be represented as ν', but for SymPy’s standard display the following works fine:

我不确定在什么情况下你希望符号表示为ν',但对于SymPy的标准显示,以下工作正常:

nuprime = sympy.symbols("ν'")

This makes use of the following:

这使用了以下内容:

  • Python 3 has a straightforward Unicode support.
  • Python 3具有简单的Unicode支持。
  • You can delimit strings by either single or double quotes. Whatever you choose, the respective other character does not need to be escaped.
  • 您可以使用单引号或双引号来分隔字符串。无论您选择什么,都不需要转义相应的其他角色。

#2


0  

I have had some success with the following, though I am not completely sure that I am exactly replicating your circumstances: 1) I opened Jupyter QtConsole 2) I inputted the following code:

我在以下方面取得了一些成功,但我并不完全确定我是在完全复制你的情况:1)我打开了Jupyter QtConsole 2)我输入了以下代码:

import sympy as sp
sp.init_printing(use_latex=True)
nuprime = sp.symbols("\\nu'")
nuprime

This produced the symbol I think you're looking for, at least on my QtConsole.

这产生了我认为你正在寻找的符号,至少在我的QtConsole上。