MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Relation Problem in Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108438] Relation Problem in Mathematica
  • From: Paul Slevin <slevvio at hotmail.com>
  • Date: Wed, 17 Mar 2010 04:42:38 -0500 (EST)

Hello - I was wondering if somebody could help me with this problem. I have the set X = {1,2,3,4}, and have computed the Cartesian Product X^2.

Let R = {(1,2),(2,3),(3,4),(4,1)}
    S = {(2,1),(3,2),(4,3),(1,4)}

be relations on X.

I want to compute the product S o R = {(x,y) in X^2: there exists one z in X (for each (x,y) pair) such that (x,z) is in R and (z,y) is in S }.

i.e. I want mathematica to run through each (x,y) pair in X^2 and check if that pair is in S o R.

To clarify, (1,1) is in S o R, because (1,4) is in S and (4,1) is in R. 4 joins 1 to 1, and it is the only element that does so (so it is unique). 

Clearly the output I want should be the diagonal on X := {(1,1),(2,2),(3,3),(4,4)}. However I am really struggling here to get mathematica to work.

Could anybody help me with this idea? Thanks very much.


  • Prev by Date: Re: Algebraic reduction
  • Next by Date: Re: Integration of InterpolatingFunction
  • Previous by thread: elementary question about packages
  • Next by thread: Re: Relation Problem in Mathematica