Basically, the region_plot
primitive behaves strangely if the expression has half-integer exponents. More specifically, here is the setup I'm using:
u = var("u")
v = var("v")
unit_disc = u**2 + v**2 <= 1
uv_range = ((u, -1, 1), (v, -1, 1))
I am first defining a two-variables functions as follows, and trying to plot the associated implicit curve:
f = u + sqrt((1 - u**2 - v**2)**3)
show(f)
region_plot([f == 0, unit_disc], *uv_range)
This works nicely to draw the zero level of the function. (Note: I am using the region_plot
primitive instead of the more suited implicit_plot
one, because I want to restrict the plot to the unit disc.)
However, if I use a half-integer exponent, the primitive will throw the exception ValueError: negative number to a fractional power not real
:
g = u + (1 - u**2 - v**2)**(3/2)
show(g)
region_plot([g == 0, unit_disc], *uv_range)
Did I discover a new bug?
The issue is that the way I define my function makes it so that I end up having those half-integer exponents lying everywhere, despite using only polynomials and substituing with square root terms. Sage automatically 'reduces' everything to half-integer exponents, and there is no way for me to revert this change.
How can I prevent this behaviour?
(P.S.: I wanted to include images and all, but even if I host them outside of this platform, it won't let me because karma... Why? This is not StackOverflow...)