# Evaluating limits restricted to real field with sagetex

I am trying to use sagetex to calculate some limits and it is having difficulties with the branch cuts for roots. Specifically, things like (-1)^(1/3) won't simplify to -1, presumably because it's on the branch cut. All the limits that I want to calculate are for real valued functions, but I can't seem to figure out how to convince sagetex that is the case. I can use

assume(x,'real')


But this only tells sagetex that the input is real, so it still doesn't assume the output is real. This command won't work on the function itself.

For example;

\documentclass{article}
\usepackage{sagetex}
\begin{document}
\begin{sagesilent}
f(x) = (x + 1)/(x^(1/3)+1)
ans=limit(f(x), x=-1)
\end{sagesilent}
\sage{ans}
\end{document}


Running this gives an output of 0, when in fact the limit should be 3 (using sum of cubes). I can only assume this is a result of the branch cut issue as it only happens on negative reals.

Is there a way to redefine the branch cut, or better yet, tell sagetex that f is a real valued function and to use the real valued cube root and not the complex one?

f(x) = (x + 1)/(sign(x)*abs(x)^(1/3)+1)

The abs(x) takes the absolute value of x thereby making sure the answer will be real. Then sign(x) of x puts a negative sign onto the answer, if x is negative. Running this through Sage without using the assume command will give you the limit of 3. Awkward but it works. That seems to be the solution that is recommended here.