0% found this document useful (0 votes)
7 views2 pages

Practical 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Practical 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PRACTICAL-1

RELATION AS ORDERED PAIRS


TO CHECK IF THE ENTERED DATA IS AN ORDERED PAIR OR NOT
In[13]:= pairQ@8_, _<D := True;
pairQ@8__<D := False;
pairQ@85, 8<D
pairQ@85<D
pairQ@84, "b"<D

Out[15]= True

Out[16]= False

Out[17]= True

TO CHECK IF THE ENTERED DATA IS AN RELATION OR NOT


In[18]:= relationQ@8__ ? pairQ<D := True;
relation@__D := False;
Tuples@81, 2, 3<, 2D

Out[20]= 881, 1<, 81, 2<, 81, 3<, 82, 1<, 82, 2<, 82, 3<, 83, 1<, 83, 2<, 83, 3<<

dividesRelation @A : 8_Integer<D := Select@Tuples@A, 2D, Divisible@ðP2T, ðP1TD &D


dividesRelation @Range@4DD
In[21]:=

relationQ@%D

Out[22]= dividesRelation @81, 2, 3, 4<D

Out[23]= relationQ@dividesRelation @81, 2, 3, 4<DD

dividesRelation @n_IntegerD := Select@Tuples@Range@nD, 2D, Divisible@ðP2T, ðP1TD &D


div6 = dividesRelation @6D
In[24]:=

Reverse@81, 2, 3<D
881, 1<, 81, 2<, 81, 3<, 81, 4<, 81, 5<, 81, 6<,
82, 2<, 82, 4<, 82, 6<, 83, 3<, 83, 6<, 84, 4<, 85, 5<, 86, 6<<
Out[25]=

Out[26]= 83, 2, 1<

THE INVERSE OF A RELATION

inverseRelation @R_ ? relationQD := Reverse@R, 2D


mul6 = inverseRelation @div6D
In[27]:=

881, 1<, 82, 1<, 83, 1<, 84, 1<, 85, 1<, 86, 1<,
82, 2<, 84, 2<, 86, 2<, 83, 3<, 86, 3<, 84, 4<, 85, 5<, 86, 6<<
Out[28]=
2 Untitled-1

You might also like