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


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;

f(x) = (x + 1)/(x^(1/3)+1)
ans=limit(f(x), x=-1)

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?


This is one of the recognized annoyances with Sage that lacks a simple solution. There are several possibilities depending on the type of problem which are discussed here but I think the solution for your specific problem is handled as is mentioned on this page:

f(x) = (x + 1)/(sign(x)*abs(x)^(1/3)+1)
limit(f(x), x=-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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.