Create the Cartesian product of two sets

David shared this question 5 months ago
Answered

I am trying to create the Cartesian product of two sets l1 and l2.

I attempted Zip(zip({a,b},a,l1),b,l2) but that did not work in graphing app, classic app or CAS app.

I also tried to use the spreadsheet but it does not like ={x,y} or =(x,y) in A1. Not to mention I don't know how to paste a set vertically in a spreadsheet.

Anyone know how to find the Cartesian product?

Thanks.

Comments (5)

photo
1

How's that?

Sequence(Sequence((Element(l1, i), Element(l2, j)), i, 1, Length(l1)), j, 1, Length(l2))
If not, please say exactly what you want as output

photo
1

zip(zip({P,Q},P,l1),Q,l2)

flatten optional

photo
1

Yes. The first answered my question. I will take a look at the other answers to see which is the easiest to use. Thank you.

photo
1

I would like to construct a 2-parameter sequence c_{nm} by taking the cartesian product of two sequences {a_n} and {b_m}. The command SEQUENCE allows only one variable. Looking forward to hearing about the solution.

photo
photo
1

el procedimiento ya ha sido explicado arriba

adjunto un ejemplo

Files: foro.ggb
© 2020 International GeoGebra Institute