0

I am trying to plot hyperbola using sympy and also getting its asymptote in the plot as well. Here is my code-

from sympy import *
x = symbols('x')
plot(3/(x-1), ylim = (-10,10))

This gives the plot below-

enter image description here

I want to plot the hyperbola without its asymptote. Is there any way to do in sympy?

EDIT- Many people are suggesting to look answers here. This does not answer my question because I am looking for a solution specific to sympy only (without using any other library like matplotlib or numpy). If I needed to plot using matplotlib, I would not be using sympy. The reason I want to use sympy is 1. sympy is a CAS (should have this functionality, should not be dependent on other libraries) and 2. I don't need to specify the x and y points for plotting like in matplotlib.

Ankit Seth
  • 729
  • 1
  • 9
  • 23
  • 2
    Does this answer your question? [how to handle an asymptote/discontinuity with Matplotlib](https://stackoverflow.com/questions/2540294/how-to-handle-an-asymptote-discontinuity-with-matplotlib) – Aetooc Jan 04 '21 at 13:36
  • 1
    Not exactly. The answers are either for matplotlib or using pylab along with numpy. I want to know if there is a solution using sympy only. – Ankit Seth Jan 04 '21 at 15:26
  • An idea is `plot(Piecewise((oo, abs(x - 1) < 1 / S(100)), (3 / (x - 1), True)), ylim=(-10, 10))` which draws the desired plot, although it gives some warnings during the first execution. Sympy's plotting seems to dislike `nan` (for example `0*oo` results in `nan`, but can not be plotted). – JohanC Jan 05 '21 at 00:34

0 Answers0