Carlos36r

25 Reputation

2 Badges

2 years, 87 days

MaplePrimes Activity


These are replies submitted by Carlos36r

@acer I have one more question if you don't mind. It is not directly related to the core issue here but relates to a particular usage:

The following:

printlevel := 2:
for x in [0,1,2] do                           
    if is(x in RealRange(Open(0),infinity)) then                                                 
        yes;
    else
        no;    
    end if;
end do;

gives the output:

x := 0
no
x := 1
yes
x := 2
yes

How do I suppress the x:= i lines? Basically I wish for the following output:

no
yes
yes

Why is the for loop outputing the value of the variable in the conditional's condition? Like I said, I believe this is not exclusively related to is(), but I did not know if I should create a whole new question concerning this.

@Carl Love Cheers.

@acer Many thanks.

@acer Thank you very much. That should do it for me for the kind of problems I am working with right now.

@acer Thanks for the pointer :-)

@Carl Love Noted, thanks!

@mmcdara Thanks!

Maple is riddled with idiosyncrasies.

@acer Cheers :-)

I have an app that juggles around multiple tools amongst which is Maple. So sometimes, I have to twist things around like this. For example, in this instance, I call maple to perform a specific action on intervals that are fed to my app from another tool. I also do not have adequate knowledge of Maple, so perhaps in future I could be moving more computation into the Maple part of the app and avoid these unholy ways of doing things.

@acer Actually, I found this little corner case where maple insists on calling (-oo, +oo) "real". So:

the program:

with(RealDomain):
func := 2*x;
r1 := solve(func < 0);
r1r := Or(`::`~(x,[r1])[]);
r2 := RealRange(-infinity,infinity);
r2r := Or(`::`~(x,[r2])[]);
allr := And(r1r,r2r);
result := solve(convert(allr, relation));

yields:

func := 2*x
r1 := RealRange(-infinity,Open(0))
r1r := Or(x::RealRange(-infinity,Open(0)))
r2 := real
r2r := Or(x::real)
allr := And(Or(x::RealRange(-infinity,Open(0))),Or(x::real))
result := NULL

result should really be equal to r1 but I think the real thingy is throwing it off.

If I change the program to (by changing -oo to -1):

with(RealDomain):
func := 2*x;
r1 := solve(func < 0);
r1r := Or(`::`~(x,[r1])[]);
r2 := RealRange(-1,infinity);
r2r := Or(`::`~(x,[r2])[]);
allr := And(r1r,r2r);
result := solve(convert(allr, relation));

I get the expected result:

func := 2*x
r1 := RealRange(-infinity,Open(0))
r1r := Or(x::RealRange(-infinity,Open(0)))
r2 := RealRange(-1,infinity)
r2r := Or(x::RealRange(-1,infinity))
allr := And(Or(x::RealRange(-infinity,Open(0))),Or(x::RealRange(-1,infinity)))
result := RealRange(-1,Open(0))

How do I stop Maple from making the real substitution?

I used some string conversion/manipulation but still without success. I tried enforcing Or(x::RealRange(-infinity,infinity)) instead of Or(x::real)):

with(RealDomain):
with(StringTools):
# same as before
func := 2*x;
r1 := solve(func < 0);
r1r := Or(`::`~(x,[r1])[]);
r2 := RealRange(-infinity,infinity);
r2r := Or(`::`~(x,[r2])[]);
allr := And(r1r,r2r);
# string manipulation
allrS := convert(allr, string);
allrSS := SubstituteAll(allrS,"Or(x::real)","Or(x::RealRange(-infinity,infinity))");
allrr := parse(allrSS);
# result
result := solve(convert(allrr, relation));

I get:

func := 2*x
r1 := RealRange(-infinity,Open(0))
r1r := Or(x::RealRange(-infinity,Open(0)))
r2 := real
r2r := Or(x::real)
allr := And(Or(x::RealRange(-infinity,Open(0))),Or(x::real))
allrS := "And(Or(x::RealRange(-infinity,Open(0))),Or(x::real))"
allrSS := "And(Or(x::RealRange(-infinity,Open(0))),Or(x::RealRange(-infinity,infinity)))"
allrr := And(Or(x::RealRange(-infinity,Open(0))),Or(x::RealRange(-infinity,infinity)))
result := NULL

@acer Awesome, thanks!

@acer How would one deal with the situation when an intersection is required between an interval and a union of intervals, or between two union of intervals?

For example:

with(RealDomain):
r1 := solve(x^2-1 > 0);
convert(x::r1,relation);
r2 := solve(x > 10);
convert(x::r2,relation);
r := solve(convert~(And(x::r1,x::r2),relation));

returns:

r1 := RealRange(-infinity,Open(-1)), RealRange(Open(1),infinity)
x::(RealRange(-infinity,Open(-1)), RealRange(Open(1),infinity))
r2 := RealRange(Open(10),infinity)
And(10 < x,x <= infinity)
r := NULL

As can be seen, converting r1 to a relation does not work.

Page 1 of 1