︠d204704c-24a5-4ce0-853f-50ed4ecc0ce1o︠
# Sage Project
# Ashley Garvey
# 1) How do you formulate a set in sage?
︡63a408df-8a0c-4496-833d-e767cbe21243︡
︠051a85c0-b94d-45ac-8ce6-935703ccb055︠
x = set({1, 2, 5 ,6})
︡fe7df27e-126d-4f94-bcb1-174565c38e40︡{"done":true}
︠d2ce67ed-cc2e-4b1c-afd2-7c27aa04a036s︠
x
︡6d7601ba-f3bc-40cf-8755-7ed824320db6︡{"stdout":"{1, 2, 5, 6}\n"}︡{"done":true}
︠38bbc88a-4b54-4944-b0de-bab1aff0d547︠
︡f843823e-8ea5-454b-8a3a-9992fc8d42b1︡
︠7d1e0fd8-20d9-4861-9169-0b3306f1e138s︠
y = set({0, 3, 7, 8})
︡da369554-8e86-4029-98b2-194f3e693f5d︡{"done":true}
︠9d723555-a90d-4b59-8216-3b1bc797b5a8︠
︡5549a08d-9048-45ab-bce4-52fb119f3c9a︡
︠29053e26-0b7c-4e7b-925d-92f9da88e2cf︠
︡69d91c07-2f15-41de-b6a2-0415451d5940︡
︠8beff555-b011-48ba-bd1a-e2546675b638s︠
y
︡258d7945-2901-4015-bbf8-1edc4c75ad74︡{"stdout":"{0, 8, 3, 7}\n"}︡{"done":true}
︠86c90c35-cdba-4fb9-9e3c-ad9607761e5d︠
# The first step is to name the set.
# Then you must use the equal sign (=).
# Lastly you must write set{()} and the elements of the set go within the parenthesis
︡4521403c-5ce5-4009-b50c-1dc67f41e22d︡
︠569539fb-644c-4edf-8228-2fee18ea4843︠
# 2) How do you find the intersection of two sets?
︡a4599f19-45c1-4162-858f-818cd41106a5︡{"done":true}
︠9710774d-cc4d-41d0-baf3-6dffbcddcebas︠
x & y
︡fa44c29f-8128-4f8f-a501-fa7ece71e61f︡{"stdout":"set()\n"}︡{"done":true}
︠897be821-3aaa-4435-afde-a0aad6f191e5︠
# The intersection of two sets are all the elements that are included in both sets
# To fint the intersection on sage we use the & sign
# If we calculate the intersection of x & y we get the empty set since no elements of the set x are in the set y.
︡e0ca5017-1177-48db-8389-31c61b6da3e5︡
︠223baeea-97b6-40ed-8ea4-200ab18eb9f4︠
︡d24881a0-b032-4e8d-9644-f93a034be946︡
︠0f0a3b3d-ac9d-4770-af65-db1434f4bb82︠
# 3) How do you find the union of two sets?
︡21f261bc-9ca5-4616-b542-c4d666f4a257︡
︠45c4cb57-31ad-4f77-a5a6-5d1dcfd1dfeas︠
x | y
︡84fa6999-7c2f-42f9-9cdb-d87c1f5632be︡{"stdout":"{0, 1, 2, 3, 5, 6, 7, 8}\n"}︡{"done":true}
︠1087f417-1b64-4951-945f-9c9fdfc7a12c︠
︡d1e56e3a-61c3-42ef-a447-038bcfbb8ecf︡
︠a49de89c-6cb2-4c9e-9a4f-f30da85dbf6f︠
︡78333365-3734-4032-b8b6-6e3dd8b5d83a︡
︠16cf4e65-7d14-4fe9-a0c4-8bbbb83732e0︠
# The union of two sets are the elements from both sets combined into a larger set
# To find the union of a set we use the | symbol.
# The union of the sets x | y is {0, 1, 2, 3, 5, 6, 7, 8}
︡8ee6b382-ad01-499d-a72f-de021e9cf99f︡
︠a3c88517-58de-4901-a79c-e3a812c9d9c5︠
︡25ebc0aa-ee7e-4594-ac68-2f57092c33b6︡
︠e4c30731-ce77-4bd4-aa35-6f92873e7b32︠
# 4) How do you find the complete set of subsets of a set?
︡c43abffe-fbd0-4f0e-acd5-e97db129eeab︡
︠ad7ee65f-2f9f-4785-8f76-7a5e36096940s︠
subsets(x)
︡b52eeba1-1966-4088-803a-ec134b5827f2︡{"stdout":"<generator object powerset at 0x7fcb5fc469e0>\n"}︡{"done":true}
︠0386a7c2-33fe-4adb-aa3d-e02b8afd41d6︠
︡a6932163-a1d1-4486-9c69-fe83838ce3bd︡
︠2f4539fb-6a4c-4013-96d3-53c1a620e68d︠
︡2409e080-6d5e-41f5-b422-54ccf4ca4083︡
︠92eed460-db1d-4f35-89a6-0883b10179bcs︠
list(subsets(x))
︡05ed7cb5-b326-40a6-80a1-5fa0d1ea3927︡{"stdout":"[[], [1], [2], [1, 2], [5], [1, 5], [2, 5], [1, 2, 5], [6], [1, 6], [2, 6], [1, 2, 6], [5, 6], [1, 5, 6], [2, 5, 6], [1, 2, 5, 6]]\n"}︡{"done":true}
︠f8419b72-43c4-4290-aec5-4914ced543a9︠
︡8ef6afbb-342d-4b3a-9d28-8bffd10415ea︡
︠43176db4-627c-48e7-9ff7-71183e445c32︠
︡757e4d07-fa5e-4153-baee-1e7efbff28a6︡
︠093ea6c4-0163-436f-9cf8-22858dc5354as︠
subsets(y)
︡caf7284c-2694-448c-8352-2fbb17fc697f︡{"stdout":"<generator object powerset at 0x7ff462bce430>\n"}︡{"done":true}
︠d5e08d5d-a691-42b8-8ef0-24c17e39e093︠
︡d9fa170d-0667-4db1-b4b6-ec735ff483af︡
︠d479c687-45b6-439b-aa60-050e1b10aace︠
︡e0fc6a8e-b40f-4ad2-a050-2f41ae45014e︡
︠52d81f84-bb8b-4ddb-8efd-56454eaa31bbs︠
list(subsets(y))
︡331027a3-f135-41ae-9715-f5650c4f03e3︡{"stdout":"[[], [0], [8], [0, 8], [3], [0, 3], [8, 3], [0, 8, 3], [7], [0, 7], [8, 7], [0, 8, 7], [3, 7], [0, 3, 7], [8, 3, 7], [0, 8, 3, 7]]\n"}︡{"done":true}
︠00b8937c-2469-4cdd-83aa-f8affa4d6002︠
# To find the complete list of subsets of two sets you first have the generate the sets. To do this you have to do subsets(x).
# Then you have to list the set. to do this you have to type list(subsets(x)).
# This will list out all the subsets of the set x.