title: evaluating limits of piecewise discontinuous functions in sympy
body: <p>I'm trying to learn sympy through a coursera course and I've set up the following Piecewise function to learn about limits.</p>
  <p>The piecewise function I'm trying to express in <code>sympy</code> is as follows (apologies, I don't know if or how to make latex render on stackoverflow):</p>
  <pre><code>    f(x) = {  x^3      x &lt; 3
                2        x = 3
                -(x^2)   x &gt; 3
  </code></pre>
  <p>In python I've set it up as:</p>
  <pre><code>from sympy import *
  from sympy.abc import x
  from sympy.plotting import plot
  
  # some whacky discontinuous function
  fx = Piecewise((x**3, x &lt; 3), (-1 * (x)**2, x &gt; 3), (2, True))
  plot(fx, ylim = (-30, 30))
  </code></pre>
  <p>which yields the following graph</p>
  <p><a href="https://i.stack.imgur.com/fjTJv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fjTJv.png" alt="enter image description here" /></a></p>
  <p>I am then trying to evaluate the limits of <code>fx</code> and expecting the one sided limits to be <code>-9</code> and <code>27</code> from the right and left respectively, and <code>does not exist</code> for the overall limit.</p>
  <p>However when I execute</p>
  <pre><code>print(fx.limit(x, 3, '+'))
  print(fx.limit(x, 3, '-'))
  print(fx.limit(x, 3))
  </code></pre>
  <p>Each line prints <code>2</code> as the answer.</p>
  <p>Can someone help identify where I've gone wrong?</p>