# Question:relations and ranges

## Question:relations and ranges

Maple

Hi,
I started with Maple recently and so I`m not familiar with it`s concepts at all.
Browsing the help system I couldn`t find a common way to do calculations with ranges.
Maybe my approach is wrong. Give me a hint.

Conversion from relations to ranges are fairly easy.
A := {0 < x and x < 2};
a := map(solve, A);
B := {1 <= x and x <= 3};
b := map(solve, B);

Unions and intersections can be done with OrProp and AndProp but the conversion back to a set of relations is circuitous.
convert(convert(`in`(x, OrProp(a[], b[])), relation), set);

I can construct multidimensional ranges but I have no idea how to do calculations with them.
`union`(convert(convert(`in`(x, a[]), relation), set), convert(convert(`in`(y, b[]), relation), set));

To get the complement of a range one could try to swap relations but how can this be done with RealRange?
inversr:=proc(a::relation)::relation;
if(type(a,'`<`'))then(op(1,a)>=op(2,a))
elif(type(a,'`<=`'))then(op(1,a)>op(2,a))
elif(type(a,'`>`'))then(op(1,a)<=op(2,a))
elif(type(a,'`>=`'))then(op(1,a)<op(2,a))
end if;
end proc:;

Unhappily the conversion from relation to a range doesn`t work after appliance o that function.
C := {map(inversr, B[])};
c := map(solve, C);

﻿