Get symbolic output in IPython console

Viewed 25

Using this code in Spyder 4.2.5 with IPython 8.2.0:

from sympy import init_printing, symbols
from sympy import sqrt, diff

init_printing()
x = symbols('x')

g = 1 - x
u = sqrt(g)

h = 1 + x
v = sqrt(h)

y = u / v
y_d = diff(y)
print(y_d)   # <--- prints text mode in IPython console
display(y_d) # <--- outputs a picture in Plots

enter image description here

I'd like to print the symbolic output on the IPython console. I tried:

  • print but it outputs a text.
  • display but while it outputs a symbolic output, this output goes to the Plot tab.

So I'm looking for a combination of the two. A symbolic output can be displayed in the console, as visible on the picture, by typing y_d at the console prompt. What is the equivalent Python instruction?

0 Answers
Related