Suppose one needs to select the real solutions after solving some equation.
Is this the correct and optimal way to do it, or is there a better one?
restart;
mu := 3.986*10^5; T:= 8*60*60:
eq := T = 2*Pi*sqrt(a^3/mu):
sol := solve(eq,a);
select(x->type(x,'realcons'),[sol]);
I could not find real
as type. So I used realcons
. At first I did this:
select(x->not(type(x,'complex')),[sol]);
which did not work, since in Maple 5
is considered complex
! So ended up with no solutions.
type(5,'complex');
(* true *)
Also I could not find an isreal()
type of function. (unless I missed one)
Is there a better way to do this that one should use?
update: To answer the comment below about 5 not supposed to be complex in maple.
restart;
type(5,complex);
true
type(5,'complex');
true
interface(version);
Standard Worksheet Interface, Maple 18.00, Windows 7, February
From help
The type(x, complex) function returns true if x is an expression of the form
a + I b, where a (if present) and b (if present) are finite and of type realcons.