Maybe it’s a silly question for experienced users, but I’m rather new and I’m having troubles.
I need to know if there is a way to force Mathematica to work in the Reals domain.
For example, if I do
Plot[x^(1/3),{x,-10,10}]
I obtain a plot only for positive reals,
For negative ones Mathematica branches to a complex root and doesn’t plot it.
I know that in the past existed a package called RealOnly which did the job, but now it’s obsolete.
I tried several combinations of Assumptions and so on, but couldn’t figure out how to use them.
All, I think that the “Re[]” takes just the real part of the solution(s). Of course, negative real numbers have complex roots. If you want to see the real part of (each of) the solutions :
Note, if you are looking for a way to “filter” and choose only those solutions that are Real (no imaginary part) you can add something that keeps only those solutions where the imaginary part is equal to zero.
What I would like to obtain, if it exists, is a general command that sets Mathematica to work only on the real branches of solutions.
In the old Derive program there is such a command : “Branch ? Real”
I know that I could arrange every plot or calculation for every single case, for example in the plot I mentioned I could do
Plot[Sign[x]*Abs[x]^(1/3), {x, -10, 10}]
and I would obtain my result.
But I’d like something general, so to set it up and go ahead without particular arrangements of the functions involved.
I think it’s on-topic. It still falls short of Stefano’s desire to have a general specification that keeps calculations in the Real branch. But CubeRoot does work for this. Surd however seems to generate the real roots when used directly, but not with Plot.
The basic mathematical issue is that the grand principles of algebra and analysis operate in the complex domain. Often, you have to reason through the complex domain to get a real answer. Any attempt to restrict Mathematica to operate in the real domain will generally impact its ability to break a problem down into subproblems. It is, however, often possible to ask for a real result:
However, here you can download the obsolete add-on package which did the job I actually need. Works for version 6
At a certain point it says
"The RealOnly package is obsolete. Use instead functionality provided by \
Reduce[equations, variables, Reals] and by Assuming, Refine, and similar \
functions."
I tried several combinations of Reduce or Assuming without success
If you don’t care to differentiate from among these solutions (though in my opinion, you’d be missing out on the best part!!) you could keep a single, real-valued magnitude:
in:= -1*Flatten@Union@%
out:= {-2.15443}
This yields a similar result as as plotting psurd[] above…
Plot[Piecewise[{{-1*Sqrt[Re[x]^2 + Im[x]^2]^(1/3), x < 0}, {x^(1/3),
x > 0}}], {x, -10, 10}]
I am sure my reply is off topic, but I have puzzled over a similar issue of reals and imaginary solutions.
In one problem, I have a messy integral whose integrand has no poles and is regular. Yet when I perform a numerical integration over some limits it will often throw off an imaginary solution. I have tried to suppress this behavior, because I don’t quite know what to do with the imaginary part of the solutions.
In the past, some respondents who answered my pleas for help said that if the imaginary part is small, they ignore it! Whoa. In some of my limits of integration, the imaginary part is as big as or larger than the real part. I am not familiar with Surd and will look into that, but otherwise, is this behavior in these integrals just user error on my part?
I am not quite a newby but lack depth in complex algebra and mathematical analysis.