diff --git a/Makefile b/Makefile index c02b5bc..23ce5e0 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ commands : @grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g' ## serve : run a local server. -serve : lesson-rmd +serve : lesson-rmd lesson-ipynb ${JEKYLL} serve ## site : build files but do not run a server. @@ -62,7 +62,7 @@ RMD_DST = $(patsubst _episodes_rmd/%.Rmd,_episodes/%.md,$(RMD_SRC)) # RMarkdown files IPYNB_SRC = $(wildcard _episodes_ipynb/??-*.ipynb) -IPYNB_DST = $(patsubst _episodes_ipynb/%.ipynb,_episodes/%.ipynb,$(RMD_SRC)) +IPYNB_DST = $(patsubst _episodes_ipynb/%.ipynb,_episodes/%.ipynb,$(IPYNB_SRC)) # Lesson source files in the order they appear in the navigation menu. MARKDOWN_SRC = \ @@ -88,7 +88,7 @@ HTML_DST = \ lesson-rmd: $(RMD_SRC) @bin/knit_lessons.sh $(RMD_SRC) -## lesson-ipynb : convert IPython Notebook files to markdown +## lesson-ipynb : convert IPython Notebook files to markdown lesson-ipynb: $(IPYNB_SRC) ${SAGE} -sh -c "jupyter nbconvert -y --execute --allow-errors --to markdown --output-dir=_episodes --template=_layouts/ipynb2md.tpl $(IPYNB_SRC)" @@ -112,6 +112,8 @@ unittest : lesson-files : @echo 'RMD_SRC:' ${RMD_SRC} @echo 'RMD_DST:' ${RMD_DST} + @echo 'IPYNB_SRC:' ${IPYNB_SRC} + @echo 'IPYNB_DST:' ${IPYNB_DST} @echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC} @echo 'HTML_DST:' ${HTML_DST} diff --git a/_config.yml b/_config.yml index d09e731..b4c8e4b 100644 --- a/_config.yml +++ b/_config.yml @@ -67,3 +67,6 @@ exclude: # Turn off built-in syntax highlighting. highlighter: false + +kramdown: + parse_block_html: true diff --git a/_episodes/01-first-session.md b/_episodes/01-first-session.md deleted file mode 100644 index 467ccc5..0000000 --- a/_episodes/01-first-session.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: First session with SageMath -teaching: 30 -exercises: 0 -questions: -- "..." -objectives: -- "..." ---- -> ## Learning Objectives -> -> * ... -{: .objectives} - -Lesson text - -~~~ {.python} -matrix([[1,2], [3,4]])^(-1) -~~~ - -~~~ {.output} -[ -2 1] -[ 3/2 -1/2] -~~~ - -> ## Some question -> -> Also, some other question -{: .callout} - -> ## Set up some challenge -> -> * Task 1 -> -> * Task 2 -{: .challenge} diff --git a/_episodes/01-introduction.md b/_episodes/01-introduction.md new file mode 100644 index 0000000..be291a2 --- /dev/null +++ b/_episodes/01-introduction.md @@ -0,0 +1,110 @@ +--- +title: First session with SageMath +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + +Lesson text + + + +~~~ +1 + 1 +~~~ +{: .source .python} + + + +~~~ +2 +~~~ +{: .output} + + + + +~~~ +matrix([[1,2], [3,4]])^(-1) +~~~ +{: .source .python} + + + +~~~ +[ -2 1] +[ 3/2 -1/2] +~~~ +{: .output} + + +Output with error message: + + +~~~ +x[10] +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +TypeError Traceback (most recent call last) + in () +----> 1 x[Integer(10)] + +TypeError: 'sage.symbolic.expression.Expression' object does not support indexing +~~~ +{: .error} +Output generating figures: + + +~~~ +plot(sin, (0,10)) +~~~ +{: .source .python} + + + +![png](../01-introduction_files/01-introduction_6_0.png) + + +For the challenges +you need to pay attention to include `
` +before it and `<\blockquote>` after it. +And for the solutions +you need to pay attention to include `
` +before it and `<\blockquote>` after it. +**This hacks is necessary for allow include Jupyter cells on challenges and solutions.** +
+## Challenge: Can you do it? + +What is the output of this command? + +~~~ +"a" + "b" +~~~ +{: .source} + +
+ +## Solution + + +~~~ +"a" + "b" +~~~ +{: .source .python} + + + +~~~ +'ab' +~~~ +{: .output} + + +
+
diff --git a/_episodes/01-introduction_files/01-introduction_5_0.png b/_episodes/01-introduction_files/01-introduction_5_0.png new file mode 100644 index 0000000..acd4372 Binary files /dev/null and b/_episodes/01-introduction_files/01-introduction_5_0.png differ diff --git a/_episodes/01-introduction_files/01-introduction_6_0.png b/_episodes/01-introduction_files/01-introduction_6_0.png new file mode 100644 index 0000000..8cee110 Binary files /dev/null and b/_episodes/01-introduction_files/01-introduction_6_0.png differ diff --git a/_episodes/02-multiply-matrix-and-vector.md b/_episodes/02-multiply-matrix-and-vector.md new file mode 100644 index 0000000..7153a61 --- /dev/null +++ b/_episodes/02-multiply-matrix-and-vector.md @@ -0,0 +1,163 @@ +--- +title: Multiply a matrix and a vector +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- +Let us define the 3 x 3 minus-identity matrix + + +~~~ +A = matrix([[-1,0,0], [0,-1,0], [0,0,-1]]) +A +~~~ +{: .source .python} + + + +~~~ +[-1 0 0] +[ 0 -1 0] +[ 0 0 -1] +~~~ +{: .output} + + +Or simply + + +~~~ +A = -identity_matrix(3) +A +~~~ +{: .source .python} + + + +~~~ +[-1 0 0] +[ 0 -1 0] +[ 0 0 -1] +~~~ +{: .output} + + +Define vector `v` to be the vector with coordinates `x`, `y`, `z` + + +~~~ +v = vector([x, y, z]) +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () +----> 1 v = vector([x, y, z]) + +NameError: name 'y' is not defined +~~~ +{: .error} +Didn't work... We need to define `y` (and `z`) as symbolic variables. Only `x` is defined by default when you launch Sage! + + +~~~ +x, y, z = SR.var("x y z") +~~~ +{: .source .python} + + +~~~ +v = vector([x, y, z]) +v +~~~ +{: .source .python} + + + +~~~ +(x, y, z) +~~~ +{: .output} + + +Multiply matrix and vector using `*` + + +~~~ +A * v +~~~ +{: .source .python} + + + +~~~ +(-x, -y, -z) +~~~ +{: .output} + + + + +~~~ +v.subs(x=1, y=0, z=3) +~~~ +{: .source .python} + + + +~~~ +(1, 0, 3) +~~~ +{: .output} + + + + +~~~ +A * v.subs(x=1, y=0, z=3) +~~~ +{: .source .python} + + + +~~~ +(-1, 0, -3) +~~~ +{: .output} + + + + +~~~ +A * v +~~~ +{: .source .python} + + + +~~~ +(-x, -y, -z) +~~~ +{: .output} + + + + +~~~ +_.subs(x=1, y=0, z=3) +~~~ +{: .source .python} + + + +~~~ +(-1, 0, -3) +~~~ +{: .output} + + diff --git a/_episodes/02-objects.md b/_episodes/02-objects.md deleted file mode 100644 index f15aeb2..0000000 --- a/_episodes/02-objects.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: Objects -teaching: 30 -exercises: 0 -questions: -- "..." -objectives: -- "..." ---- - -The rest of the lesson should be written as a normal RMarkdown file. You can -include chunk for codes, just like you'd normally do. - - -~~~ -1 + 1 -~~~ -{: .source .python} - - - - - 2 - - -Output with error message: - - -~~~ -x[10] -~~~ -{: .source .python} - -~~~ ---------------------------------------------------------------------------- -TypeError Traceback (most recent call last) - in () -----> 1 x[Integer(10)] - -TypeError: 'sage.symbolic.expression.Expression' object does not support indexing -~~~ -{: .error} -Output generating figures: - - -~~~ -plot(sin, (0,10)) -~~~ -{: .source .python} - - - - -![png](../02-objects_files/02-objects_5_0.png) - - -For the challenges and their solutions, you need to pay attention to where the -`>` go and where to leave blank lines. You can include code chunks in both the -instructions and solutions. For instance this: - -> ## Challenge: Can you do it? -> -> What is the output of this command? -> -> ~~~ -> "a" + "b" -> ~~~ -> {: .source} -> -> > ## Solution -> > -> > ~~~ -> > ab -> > ~~~ -> {: .solution} -{: .challenge} diff --git a/_episodes/02-objects_files/02-objects_5_0.png b/_episodes/02-objects_files/02-objects_5_0.png deleted file mode 100644 index a764cf7..0000000 Binary files a/_episodes/02-objects_files/02-objects_5_0.png and /dev/null differ diff --git a/_episodes/03-matrix-group.md b/_episodes/03-matrix-group.md new file mode 100644 index 0000000..fd4a151 --- /dev/null +++ b/_episodes/03-matrix-group.md @@ -0,0 +1,164 @@ +--- +title: Matrix Group Closure +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + +Multiply together till you achieve closure (of the group) + + +~~~ +count = 1 + +g = [A] + +for i in range(count): + for j in range(count): + new = True + tmp = g[i] * g[j] + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + +# don't do this till later +I3 = identity_matrix(3) +tmp = identity_matrix(3) +for i in range(count): + for j in range(10): + tmp = tmp * g[i] + if (tmp - I3).norm().abs() < 0.01: + print(i,j+1) + print(g[i]^(j+1)) # comment out or assert + break + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 1 count = Integer(1) + 2 +----> 3 g = [A] + 4 + 5 for i in range(count): + +NameError: name 'A' is not defined +~~~ +{: .error} +Find the inverses to the group elements + + +~~~ +I3 = identity_matrix(3) + +g_inverse = [] + +for i in range(count): + for j in range(count): + if (I3-g[i]*g[j])<0.01: + g_inverse.append(g[j]) + +for i in range(count): + print (g[i]) + print (g_inverse[i]) + print (g[i]*g_inverse[i]) + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 5 for i in range(count): + 6 for j in range(count): +----> 7 if (I3-g[i]*g[j]) in () + 1 g=[] + 2 count=Integer(3) +----> 3 g.append(reflection_matrix([Integer(1), Integer(0), Integer(0)])) + 4 g.append(reflection_matrix([Integer(0), Integer(1), Integer(0)])) + 5 g.append(reflection_matrix([Integer(0), Integer(0), Integer(1)])) + +NameError: name 'reflection_matrix' is not defined +~~~ +{: .error} + + +~~~ +# bit of conjugacy classes if you fancy - tidy up and do set of sets here? + +for i in range(4): + for j in range(4): + print("coset", i, j) + print(g[i] * g[j] * g_inverse[i]) + print(g[j]) + + +~~~ +{: .source .python} + +~~~ +('coset', 0, 0) + +~~~ +{: .output} + +~~~ +--------------------------------------------------------------------------- +IndexErrorTraceback (most recent call last) + in () + 4 for j in range(Integer(4)): + 5 print("coset", i, j) +----> 6 print(g[i] * g[j] * g_inverse[i]) + 7 print(g[j]) + 8 + +IndexError: list index out of range +~~~ +{: .error} +Do A3 next: sub in simple roots into the general reflection formula above, then generate the group + +$A_3$: $\alpha_1=\frac{1}{\sqrt{2}}(-1,1,0)^T, \alpha_2=\frac{1}{\sqrt{2}}(0,-1,1)^T, \alpha_3=\frac{1}{\sqrt{2}}(1,1,0)^T$ + + +~~~ +K. = NumberField(x^2 - 2, embedding=1.4) +g=[] +count=3 +g.append(reflection_matrix([-1/r, 1/r, 0])) +g.append(reflection_matrix([0, -1/r, 1/r])) +g.append(reflection_matrix([1/r, 1/r, 0])) + +g + +for i in range(count): + for j in range(count): + new = True + tmp = g[i] * g[j] + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + +for i in range(count): + for j in range(count): + new = True + tmp = g[i] * g[j] + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + + +I3 = identity_matrix(3) + +g_inverse = [] + +for i in range(count): + for j in range(count): + if (I3-g[i]*g[j])<0.01: + g_inverse.append(g[j]) + +I3 = identity_matrix(3) +tmp = identity_matrix(3) +for i in range(count): + for j in range(10): + tmp = tmp * g[i] + if (tmp - I3).norm().abs() < 0.01: + break + print(i, g[i].determinant(), g[i].trace(), j) + + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 2 g=[] + 3 count=Integer(3) +----> 4 g.append(reflection_matrix([-Integer(1)/r, Integer(1)/r, Integer(0)])) + 5 g.append(reflection_matrix([Integer(0), -Integer(1)/r, Integer(1)/r])) + 6 g.append(reflection_matrix([Integer(1)/r, Integer(1)/r, Integer(0)])) + +NameError: name 'reflection_matrix' is not defined +~~~ +{: .error} + + +~~~ +# bit of conjugacy classes if you fancy + +for i in range(4): + for j in range(4): + print("coset", i, j) + print(g[i] * g[j] * g_inverse[i]) + print(g[j]) + +~~~ +{: .source .python} + +~~~ +('coset', 0, 0) + +~~~ +{: .output} + +~~~ +--------------------------------------------------------------------------- +IndexErrorTraceback (most recent call last) + in () + 4 for j in range(Integer(4)): + 5 print("coset", i, j) +----> 6 print(g[i] * g[j] * g_inverse[i]) + 7 print(g[j]) + +IndexError: list index out of range +~~~ +{: .error} +Do H3 next: sub in simple roots into the general reflection formula above, then generate the group + +$H_3$: $\alpha_1=(0,1,0)^T, \alpha_2=-\frac{1}{2}(\tau,1,(\tau-1))^T, \alpha_3=(0,0,1)^T$ + +$\tau$ is the golden ratio $\tau = \frac{1}{2}(1+\sqrt{5})\sim 1.618$ and satisfies the relation $\tau^2=\tau+1$. + + +You will need to modify the two earlier examples to either deal with $\tau$ numerically (i.e. to within a certain error) or via the recursion relation. + + +~~~ + +g = [] +count = 3 + +g.append(reflection_matrix([1, 0, 0])) +g.append(reflection_matrix([-1/4*(1+sqrt(5)), -1/2, -1/4*(1-sqrt(5))])) +g.append(reflection_matrix([0, 0, 1])) + +# Build g + +for i in range(count): + for j in range(count): + new = True + tmp = (g[i] * g[j]).apply_map(expand) + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + + +for i in range(count): + for j in range(count): + new = True + tmp = (g[i] * g[j]).apply_map(expand) + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + + +I3 = identity_matrix(3) + +g_inverse = [] + +for i in range(count): + for j in range(count): + if (I3-g[i]*g[j])<0.01: + g_inverse.append(g[j]) + +I3 = identity_matrix(3) +tmp = identity_matrix(3) +for i in range(count): + for j in range(10): + tmp = tmp * g[i] + if (tmp - I3).norm().abs() < 0.01: + break + print(i, g[i].determinant(), g[i].trace(), j) + + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 3 count = Integer(3) + 4 +----> 5 g.append(reflection_matrix([Integer(1), Integer(0), Integer(0)])) + 6 g.append(reflection_matrix([-Integer(1)/Integer(4)*(Integer(1)+sqrt(Integer(5))), -Integer(1)/Integer(2), -Integer(1)/Integer(4)*(Integer(1)-sqrt(Integer(5)))])) + 7 g.append(reflection_matrix([Integer(0), Integer(0), Integer(1)])) + +NameError: name 'reflection_matrix' is not defined +~~~ +{: .error} + + +~~~ +K5. = NumberField(x^2 - x - 1, embedding=1.6) + +g=[] +count=3 +g.append(reflection_matrix((1, 0, 0))) +g.append(reflection_matrix((-1/2*a, -1/2, -1/2*(1-a))) +g.append(reflection_matrix((0, 0, 1))) + +g + +for i in range(count): + for j in range(count): + new = True + tmp = g[i] * g[j] + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + +for i in range(count): + for j in range(count): + new = True + tmp = g[i] * g[j] + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + + +I3 = identity_matrix(3) + +g_inverse = [] + +for i in range(count): + for j in range(count): + if (I3-g[i]*g[j])<0.01: + g_inverse.append(g[j]) + +I3 = identity_matrix(3) +tmp = identity_matrix(3) +for i in range(count): + for j in range(10): + tmp = tmp * g[i] + if (tmp - I3).norm().abs() < 0.01: + break + print(i, g[i].determinant(), g[i].trace(), j+1) + +~~~ +{: .source .python} + +~~~ + File "", line 7 +g.append(reflection_matrix((Integer(0), Integer(0), Integer(1)))) +^ +SyntaxError: invalid syntax +~~~ +{: .error} + + +~~~ +K. = NumberField(x^2-5) + +g=[] +count=3 +g.append(reflection_matrix((1, 0, 0)) +g.append(reflection_matrix((-1/4*(1+a), -1/2, -1/4*(1-a))) +g.append(reflection_matrix((0, 0, 1)) + +g + +for i in range(count): + for j in range(count): + new = True + tmp = g[i] * g[j] + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + +for i in range(count): + for j in range(count): + new = True + tmp = g[i] * g[j] + for k in range(count): + if (tmp - g[k]).norm().abs() < 0.01: + new = False + if new: + count += 1 + g.append(tmp) + print(g[-1], count) + + +I3 = identity_matrix(3) + +g_inverse = [] + +for i in range(count): + for j in range(count): + if (I3-g[i]*g[j])<0.01: + g_inverse.append(g[j]) + +I3 = identity_matrix(3) +tmp = identity_matrix(3) +for i in range(count): + for j in range(10): + tmp = tmp * g[i] + if (tmp - I3).norm().abs() < 0.01: + break + print(i, g[i].determinant(), g[i].trace(), j+1) + +~~~ +{: .source .python} + +~~~ + File "", line 6 +g.append(reflection_matrix((-Integer(1)/Integer(4)*(Integer(1)+a), -Integer(1)/Integer(2), -Integer(1)/Integer(4)*(Integer(1)-a))) +^ +SyntaxError: invalid syntax +~~~ +{: .error} diff --git a/_episodes/06-rotational-subgroup.md b/_episodes/06-rotational-subgroup.md new file mode 100644 index 0000000..92bcec0 --- /dev/null +++ b/_episodes/06-rotational-subgroup.md @@ -0,0 +1,90 @@ +--- +title: Rotational Subgroup +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + + +~~~ +g +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () +----> 1 g + +NameError: name 'g' is not defined +~~~ +{: .error} + + +~~~ +counteven=0 +g_even = [] +for i in range(count): + if (((g[i]).determinant()-1).abs() < 0.01): + counteven += 1 + g_even.append(g[i]) + print(g_even[-1], counteven) # + + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 1 counteven=Integer(0) + 2 g_even = [] +----> 3 for i in range(count): + 4 if (((g[i]).determinant()-Integer(1)).abs() < RealNumber('0.01')): + 5 counteven += Integer(1) + +NameError: name 'count' is not defined +~~~ +{: .error} + + +~~~ +closed = false + +for i in range(counteven): + for j in range(counteven): + + tmp = g_even[i] * g_even[j] + new = true + + #create a function that compares to group elements and returns label k if it is contained in the group? + for k in range(counteven): + if (tmp - g_even[k]).norm().abs() < 0.01: + new = false + break + + if new: + print("not closed") + closed = false + break + +if closed: + print ("closed") + +g_even_inverse = [] + +#create a function that makes inverses +for i in range(counteven): + for j in range(counteven): + if (I3-g_even[i] * g_even[j])<0.01: + g_even_inverse.append(g[j]) + print(g_even_inverse[-1]) # + +~~~ +{: .source .python} diff --git a/_episodes/07-orbits.md b/_episodes/07-orbits.md new file mode 100644 index 0000000..90ac53b --- /dev/null +++ b/_episodes/07-orbits.md @@ -0,0 +1,106 @@ +--- +title: Orbits +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + +Make an icosahedron by picking a seed vector on a 5-fold axis + + +~~~ +icosahedron_dupl = [] +T5 = vector([0,1,1.618]) +seed = T5 +for i in range(counteven): + icosahedron_dupl.append(g_even[i] * seed) + + + +# now delete duplicates - do ito golden ratio, or round or convert to set etc + +icosahedron_dupl + +icosahedron = [] + + +# define function take orbit +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 2 T5 = vector([Integer(0),Integer(1),RealNumber('1.618')]) + 3 seed = T5 +----> 4 for i in range(counteven): + 5 icosahedron_dupl.append(g_even[i] * seed) + 6 + +NameError: name 'counteven' is not defined +~~~ +{: .error} +Make a dodecahedron by picking a seed vector on a 3-fold axis + + +~~~ +dodecahedron = [] +T3 = vector([1,1,1]) +seed = T3 +for i in range(counteven): + dodecahedron.append(g_even[i] * seed) + + + +# now delete duplicates - do ito golden ratio, or round or convert to set etc +# define function take orbit +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 2 T3 = vector([Integer(1),Integer(1),Integer(1)]) + 3 seed = T3 +----> 4 for i in range(counteven): + 5 dodecahedron.append(g_even[i] * seed) + 6 + +NameError: name 'counteven' is not defined +~~~ +{: .error} +Make a icosidodecahedron by picking a seed vector on a 2-fold axis + + +~~~ +icosidodecahedron = [] +T2 = vector([1,0,0]) +seed = T2 +for i in range(counteven): + icosidodecahedron.append(g_even[i] * seed) + +# plot +# now delete duplicates - do ito golden ratio, or round or convert to set etc + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 2 T2 = vector([Integer(1),Integer(0),Integer(0)]) + 3 seed = T2 +----> 4 for i in range(counteven): + 5 icosidodecahedron.append(g_even[i] * seed) + 6 + +NameError: name 'counteven' is not defined +~~~ +{: .error} diff --git a/_episodes/08-polytopes.md b/_episodes/08-polytopes.md new file mode 100644 index 0000000..c94fca1 --- /dev/null +++ b/_episodes/08-polytopes.md @@ -0,0 +1,136 @@ +--- +title: Display polytopes +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + + +~~~ +point3d(icosahedron, size=100) + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +TypeError Traceback (most recent call last) + in () +----> 1 point3d(icosahedron, size=Integer(100)) + +/home/raniere/src/sagemath/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.pyc in point3d(v, size, **kwds) + 1126 except TypeError: + 1127 # argument is an iterator +-> 1128 v = list(v) + 1129 l = len(v) + 1130 + +TypeError: 'function' object is not iterable +~~~ +{: .error} + + +~~~ +icosahedron=[v.change_ring(RDF) for v in icosahedron] +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +TypeError Traceback (most recent call last) + in () +----> 1 icosahedron=[v.change_ring(RDF) for v in icosahedron] + +TypeError: 'function' object is not iterable +~~~ +{: .error} + + +~~~ +P=Polyhedron(icosahedron) +plot(P) + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +TypeError Traceback (most recent call last) + in () +----> 1 P=Polyhedron(icosahedron) + 2 plot(P) + +/home/raniere/src/sagemath/src/sage/misc/lazy_import.pyx in sage.misc.lazy_import.LazyImport.__call__ (/home/raniere/src/sagemath/src/build/cythonized/sage/misc/lazy_import.c:3646)() +387 True +388 """ +--> 389 return self._get_object()(*args, **kwds) +390 +391 def __repr__(self): + +/home/raniere/src/sagemath/local/lib/python2.7/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds) +710 kwds[new_name] = kwds[old_name] +711 del kwds[old_name] +--> 712 return func(*args, **kwds) +713 +714 return wrapper + +/home/raniere/src/sagemath/local/lib/python2.7/site-packages/sage/geometry/polyhedron/constructor.pyc in Polyhedron(vertices, rays, lines, ieqs, eqns, ambient_dim, base_ring, minimize, verbose, backend) +366 """ +367 # Clean up the arguments +--> 368 vertices = _make_listlist(vertices) +369 rays = _make_listlist(rays) +370 lines= _make_listlist(lines) + +/home/raniere/src/sagemath/local/lib/python2.7/site-packages/sage/geometry/polyhedron/misc.pyc in _make_listlist(x) + 88 """ + 89 if x is None: return [] +---> 90 return [list(y) for y in x] + 91 + 92 + +TypeError: 'function' object is not iterable +~~~ +{: .error} + + +~~~ +point3d(dodecahedron, size=100) + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +TypeError Traceback (most recent call last) + in () +----> 1 point3d(dodecahedron, size=Integer(100)) + +/home/raniere/src/sagemath/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.pyc in point3d(v, size, **kwds) + 1126 except TypeError: + 1127 # argument is an iterator +-> 1128 v = list(v) + 1129 l = len(v) + 1130 + +TypeError: 'function' object is not iterable +~~~ +{: .error} + + +~~~ +point3d(icosidodecahedron, size=100) +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () +----> 1 point3d(icosidodecahedron, size=Integer(100)) + +NameError: name 'icosidodecahedron' is not defined +~~~ +{: .error} diff --git a/_episodes/09-idd.md b/_episodes/09-idd.md new file mode 100644 index 0000000..f0a5e4d --- /dev/null +++ b/_episodes/09-idd.md @@ -0,0 +1,43 @@ +--- +title: IDD +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + +Show IDD is a root system. + + +~~~ +IDD=icosidodecahedron + +for points in IDD: + if not (-points in IDD): + print("first axiom violated") + +for points in IDD: + for refl in IDD: + tmp = reflection_matrix(refl[1], n2=refl[2], n3=refl[3]) * points + if not (tmp in IDD): + print("second axiom violated", tmp) + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () +----> 1 IDD=icosidodecahedron + 2 + 3 for points in IDD: + 4 if not (-points in IDD): + 5 print("first axiom violated") + +NameError: name 'icosidodecahedron' is not defined +~~~ +{: .error} diff --git a/_episodes/10-conjugacy-classes.md b/_episodes/10-conjugacy-classes.md new file mode 100644 index 0000000..f8a2a4c --- /dev/null +++ b/_episodes/10-conjugacy-classes.md @@ -0,0 +1,43 @@ +--- +title: Conjugacy Classes +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + + +~~~ +cc = [] + + + +for i in range(4): + for j in range(4): + print("coset", i, j) + print(g[i] * g[j] * g_inverse[i]) + print(g[j]) + +~~~ +{: .source .python} + +~~~ +('coset', 0, 0) + +~~~ +{: .output} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 6 for j in range(Integer(4)): + 7 print("coset", i, j) +----> 8 print(g[i] * g[j] * g_inverse[i]) + 9 print(g[j]) + +NameError: name 'g' is not defined +~~~ +{: .error} diff --git a/_episodes/11-number-and-dimensions-of-irreducible-representations.md b/_episodes/11-number-and-dimensions-of-irreducible-representations.md new file mode 100644 index 0000000..19925ba --- /dev/null +++ b/_episodes/11-number-and-dimensions-of-irreducible-representations.md @@ -0,0 +1,9 @@ +--- +title: Number and Dimensions of Irreducible Representations +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- diff --git a/_episodes/12-pymol-visualisation.md b/_episodes/12-pymol-visualisation.md new file mode 100644 index 0000000..1830c89 --- /dev/null +++ b/_episodes/12-pymol-visualisation.md @@ -0,0 +1,43 @@ +--- +title: More advanced Caspar-Klug orbits and pymol visualisation +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + + +~~~ +seeds = [[ 0.904721509025590, 0.0879675935421300, 0.416822136685000], +[0.979660168810660, 0.0952540054366200, 0.176614348770000], +[0.894764055651420, 0.317512115546100, 0.313979842320000], +[0.986175314321600, 0.165705309322800, 0]] +seeds + +T4capsid = [] + +for seed in seeds: + for i in range(count_even): + T4capsid.append(g_even[i] * seed) + +point3d(T4capsid, size=100) + + +~~~ +{: .source .python} + +~~~ +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) + in () + 8 + 9 for seed in seeds: +---> 10 for i in range(count_even): + 11 T4capsid.append(g_even[i] * seed) + 12 + +NameError: name 'count_even' is not defined +~~~ +{: .error} diff --git a/_episodes/13-cartan-matrix.md b/_episodes/13-cartan-matrix.md new file mode 100644 index 0000000..c88dbae --- /dev/null +++ b/_episodes/13-cartan-matrix.md @@ -0,0 +1,119 @@ +--- +title: Cartan matrix and Perron-Frobenius eigenvector +teaching: 30 +exercises: 0 +questions: +- "..." +objectives: +- "..." +--- + + +~~~ +# define Cartan matrix - function of arbitrary number of vectors? + +# find eigenvalues using SAGE routine + +# find the Perron-Frobenius eigenvalue + +def Cartan_matrix(Delta, symbolic=False): + """ + Return the Cartan matrix for a simple system + + INPUT: + + - ``Delta`` -- list of vectors or any iterable that can be turned into a vector + - + + EXAMPLES:: + + sage: Delta = ((1, 0, 0)), ((0, 1, 0)), ((0, 0, 1)) + sage: C = Cartan_matrix(Delta) + sage: C + [2 0 0] + [0 2 0] + [0 0 2] + """ + Delta=[vector(v) for v in Delta] + + M = matrix([[2 / w.dot_product(w) * v.dot_product(w) for w in Delta] for v in Delta]) + + if symbolic: + M = M.apply_map(expand) + + return M +~~~ +{: .source .python} + + +~~~ +Delta = ((0, 1, 0)), ((-1/4*(1+sqrt(5)), -1/2, 1/4*(1-sqrt(5)))), ((1, 0, 0)) + +Delta + +C = Cartan_matrix(Delta, symbolic=True) +C +~~~ +{: .source .python} + + + +~~~ +[ 2 -1 0] +[ -1 2 -1/2*sqrt(5) - 1/2] +[ 0 -1/2*sqrt(5) - 1/2 2] +~~~ +{: .output} + + + + +~~~ +E = C.eigenvectors_right() +E + + +A=QQbar(E[1][1][0][2]) +A +E +~~~ +{: .source .python} + + + +~~~ +[(-1/2*sqrt(2*sqrt(5) + 10) + 2, + [(1, 1/2*sqrt(2*sqrt(5) + 10), 1/2*sqrt(5) + 1/2)], + 1), + (1/2*sqrt(2*sqrt(5) + 10) + 2, + [(1, -1/2*sqrt(2*sqrt(5) + 10), 1/2*sqrt(5) + 1/2)], + 1), + (2, [(1, 0, -1/2*sqrt(5) + 1/2)], 1)] +~~~ +{: .output} + + + + +~~~ +# find PF eigenvector i.e. all coefficients of the same sign +for i in range(3): + tmp = E[i][1][0] + if all (x * tmp[0] > 0 for x in tmp): + print(tmp) + +~~~ +{: .source .python} + +~~~ +(1, 1/2*sqrt(2*sqrt(5) + 10), 1/2*sqrt(5) + 1/2) + +~~~ +{: .output} + + +~~~ +# find duals to roots (weights), construct two vectors from two-colouring of the graph and the PF evec just found; orthonormalise and project root system into this plane + +~~~ +{: .source .python} diff --git a/_episodes_ipynb/02-objects.ipynb b/_episodes_ipynb/01-introduction.ipynb similarity index 95% rename from _episodes_ipynb/02-objects.ipynb rename to _episodes_ipynb/01-introduction.ipynb index 7efa61f..f5f1402 100644 --- a/_episodes_ipynb/02-objects.ipynb +++ b/_episodes_ipynb/01-introduction.ipynb @@ -5,7 +5,7 @@ "metadata": {}, "source": [ "---\n", - "title: Objects\n", + "title: First session with SageMath\n", "teaching: 30\n", "exercises: 0\n", "questions:\n", @@ -14,8 +14,7 @@ "- \"...\"\n", "---\n", "\n", - "The rest of the lesson should be written as a normal RMarkdown file. You can\n", - "include chunk for codes, just like you'd normally do." + "Lesson text\n" ] }, { @@ -40,6 +39,29 @@ "1 + 1" ] }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[ -2 1]\n", + "[ 3/2 -1/2]" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "matrix([[1,2], [3,4]])^(-1)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -104,26 +126,62 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "For the challenges and their solutions, you need to pay attention to where the\n", - "`>` go and where to leave blank lines. You can include code chunks in both the\n", - "instructions and solutions. For instance this:\n", + "For the challenges\n", + "you need to pay attention to include `
`\n", + "before it and `<\\blockquote>` after it.\n", + "And for the solutions\n", + "you need to pay attention to include `
`\n", + "before it and `<\\blockquote>` after it.\n", + "**This hacks is necessary for allow include Jupyter cells on challenges and solutions.**" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "## Challenge: Can you do it?\n", + "\n", + "What is the output of this command?\n", + "\n", + "~~~\n", + "\"a\" + \"b\"\n", + "~~~\n", + "{: .source}\n", "\n", - "> ## Challenge: Can you do it?\n", - ">\n", - "> What is the output of this command?\n", - ">\n", - "> ~~~\n", - "> \"a\" + \"b\"\n", - "> ~~~\n", - "> {: .source}\n", - ">\n", - "> > ## Solution\n", - "> >\n", - "> > ~~~\n", - "> > ab\n", - "> > ~~~\n", - "> {: .solution}\n", - "{: .challenge}" + "
\n", + "\n", + "## Solution" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'ab'" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\"a\" + \"b\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "
\n", + "
" ] } ], diff --git a/_episodes_ipynb/02-multiply-matrix-and-vector.ipynb b/_episodes_ipynb/02-multiply-matrix-and-vector.ipynb new file mode 100644 index 0000000..4a3ef3d --- /dev/null +++ b/_episodes_ipynb/02-multiply-matrix-and-vector.ipynb @@ -0,0 +1,292 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Multiply a matrix and a vector\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let us define the 3 x 3 minus-identity matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "A = matrix([[-1,0,0], [0,-1,0], [0,0,-1]])\n", + "A" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Or simply" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "A = -identity_matrix(3)\n", + "A" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Define vector `v` to be the vector with coordinates `x`, `y`, `z`" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'y' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mv\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvector\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mz\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mNameError\u001b[0m: name 'y' is not defined" + ] + } + ], + "source": [ + "v = vector([x, y, z])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Didn't work... We need to define `y` (and `z`) as symbolic variables. Only `x` is defined by default when you launch Sage!" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "x, y, z = SR.var(\"x y z\")" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(x, y, z)" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v = vector([x, y, z])\n", + "v" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Multiply matrix and vector using `*`" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(-x, -y, -z)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "A * v" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(1, 0, 3)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "v.subs(x=1, y=0, z=3)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(-1, 0, -3)" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "A * v.subs(x=1, y=0, z=3)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(-x, -y, -z)" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "A * v" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(-1, 0, -3)" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "_.subs(x=1, y=0, z=3)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/03-matrix-group.ipynb b/_episodes_ipynb/03-matrix-group.ipynb new file mode 100644 index 0000000..9b54306 --- /dev/null +++ b/_episodes_ipynb/03-matrix-group.ipynb @@ -0,0 +1,253 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Matrix Group Closure\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---\n", + "\n", + "Multiply together till you achieve closure (of the group)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "([1 0 0]\n", + "[0 1 0]\n", + "[0 0 1], 2)\n", + "(0, 2)\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "(1, 1)\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n" + ] + } + ], + "source": [ + "count = 1\n", + "\n", + "g = [A]\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + " \n", + "# don't do this till later\n", + "I3 = identity_matrix(3) \n", + "tmp = identity_matrix(3)\n", + "for i in range(count):\n", + " for j in range(10):\n", + " tmp = tmp * g[i]\n", + " if (tmp - I3).norm().abs() < 0.01:\n", + " print(i,j+1)\n", + " print(g[i]^(j+1)) # comment out or assert \n", + " break\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Find the inverses to the group elements" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]\n", + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n" + ] + } + ], + "source": [ + "I3 = identity_matrix(3)\n", + "\n", + "g_inverse = []\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " if (I3-g[i]*g[j])<0.01:\n", + " g_inverse.append(g[j])\n", + "\n", + "for i in range(count):\n", + " print (g[i])\n", + " print (g_inverse[i])\n", + " print (g[i]*g_inverse[i])\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## From reflection formula find matrix?\n", + "\n", + "for x'=x-2x_parallel=x-2(x.n)n/(n.n), resolve for components x=(x1, x2, x3) and n=(n1, n2, n3) find 3x3 matrix" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "# TODO: n-dimensional case\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def reflection_matrix(v, normalize=True):\n", + " \"\"\"\n", + " Return the reflection matrix to the plane with normal vector v\n", + " \n", + " INPUT:\n", + " \n", + " - ``v`` -- vector or any iterable that can be turned into a vector\n", + " - ``normalize`` -- boolean (default: True)\n", + " \n", + " If ``normalize`` is ``False``, assume the vector is a unit vector and avoid normalizing.\n", + "\n", + " EXAMPLE:\n", + " \n", + " sage: a, b, c = SR.var(\"a b c\")\n", + " sage: A = reflection_matrix((a, b, c))\n", + " sage: A\n", + " [-a^2 + b^2 + c^2 -2*a*b -2*a*c]\n", + " [ -2*a*b a^2 - b^2 + c^2 -2*b*c]\n", + " [ -2*a*c -2*b*c a^2 + b^2 - c^2]\n", + " \"\"\"\n", + " v = vector(v)\n", + " m = matrix(v)\n", + " n = len(v)\n", + " R = v.base_ring()\n", + " if normalize:\n", + " return (identity_matrix(n) - 2/v.dot_product(v) * m.transpose() * m)\n", + " return (v.dot_product(v) * identity_matrix(n) - 2 * m.transpose() * m)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[-2*n1^2/(n1^2 + n2^2 + n3^2) + 1 -2*n1*n2/(n1^2 + n2^2 + n3^2) -2*n1*n3/(n1^2 + n2^2 + n3^2)]\n", + "[ -2*n1*n2/(n1^2 + n2^2 + n3^2) -2*n2^2/(n1^2 + n2^2 + n3^2) + 1 -2*n2*n3/(n1^2 + n2^2 + n3^2)]\n", + "[ -2*n1*n3/(n1^2 + n2^2 + n3^2) -2*n2*n3/(n1^2 + n2^2 + n3^2) -2*n3^2/(n1^2 + n2^2 + n3^2) + 1]" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "n1, n2, n3 = SR.var(\"n1 n2 n3\")\n", + "\n", + "A=reflection_matrix([n1, n2, n3])\n", + "\n", + "A" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "r = reflection_matrix\n", + "a, b, c = r((1, 0, 0)), r((-1/4*(1+sqrt(5)), -1/2, -1/4*(1-sqrt(5)))), r((0, 0, 1))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/04-more-matrix-groups.ipynb b/_episodes_ipynb/04-more-matrix-groups.ipynb new file mode 100644 index 0000000..eecf597 --- /dev/null +++ b/_episodes_ipynb/04-more-matrix-groups.ipynb @@ -0,0 +1,945 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Matrix Groups\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---\n", + "\n", + "Matrix groups involves $A1^3$, $A3$, $H3$.\n", + "\n", + "with Episode 5 - order of group, order of elements, inverses, traces, determinants" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A1^3 here: sub in simple roots into the general reflection formula above, then generate the group\n", + "\n", + "$A_1^3$: $\\alpha_1=(1,0,0)^T, \\alpha_2=(0,1,0)^T, \\alpha_3=(0,0,1)^T$\n" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false, + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "([1 0 0]\n", + "[0 1 0]\n", + "[0 0 1], 4)\n", + "([-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1], 5)\n", + "([-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1], 6)\n", + "([ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1], 7)\n", + "([-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1], 8)\n", + "(-1, 1, 1)\n", + "(-1, 1, 1)\n", + "(-1, 1, 1)\n", + "(1, 3, 0)\n", + "(1, -1, 1)\n", + "(1, -1, 1)\n", + "(1, -1, 1)\n", + "(-1, -3, 1)\n" + ] + } + ], + "source": [ + "g=[]\n", + "count=3\n", + "g.append(reflection_matrix([1, 0, 0]))\n", + "g.append(reflection_matrix([0, 1, 0]))\n", + "g.append(reflection_matrix([0, 0, 1]))\n", + "\n", + "g\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "\n", + "I3 = identity_matrix(3)\n", + "\n", + "g_inverse = []\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " if (I3-g[i]*g[j])<0.01:\n", + " g_inverse.append(g[j])\n", + "\n", + "I3 = identity_matrix(3) \n", + "tmp = identity_matrix(3)\n", + "for i in range(count):\n", + " for j in range(10):\n", + " tmp = tmp * g[i]\n", + " if (tmp - I3).norm().abs() < 0.01:\n", + " break\n", + " print(g[i].determinant(), g[i].trace(), j)\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('coset', 0, 0)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 1]\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 1]\n", + "('coset', 0, 1)\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "('coset', 0, 2)\n", + "[ 1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "[ 1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "('coset', 0, 3)\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "('coset', 1, 0)\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 1]\n", + "('coset', 1, 1)\n", + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "('coset', 1, 2)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "[ 1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "('coset', 1, 3)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "('coset', 2, 0)\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 1]\n", + "('coset', 2, 1)\n", + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "('coset', 2, 2)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "[ 1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "('coset', 2, 3)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "('coset', 3, 0)\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 1]\n", + "('coset', 3, 1)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "('coset', 3, 2)\n", + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1]\n", + "[ 1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "('coset', 3, 3)\n", + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n" + ] + } + ], + "source": [ + "# bit of conjugacy classes if you fancy - tidy up and do set of sets here?\n", + "\n", + "for i in range(4):\n", + " for j in range(4):\n", + " print(\"coset\", i, j)\n", + " print(g[i] * g[j] * g_inverse[i])\n", + " print(g[j])\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Do A3 next: sub in simple roots into the general reflection formula above, then generate the group\n", + "\n", + "$A_3$: $\\alpha_1=\\frac{1}{\\sqrt{2}}(-1,1,0)^T, \\alpha_2=\\frac{1}{\\sqrt{2}}(0,-1,1)^T, \\alpha_3=\\frac{1}{\\sqrt{2}}(1,1,0)^T$" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "([1 0 0]\n", + "[0 1 0]\n", + "[0 0 1], 4)\n", + "([0 0 1]\n", + "[1 0 0]\n", + "[0 1 0], 5)\n", + "([-1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 1], 6)\n", + "([0 1 0]\n", + "[0 0 1]\n", + "[1 0 0], 7)\n", + "([ 0 -1 0]\n", + "[ 0 0 1]\n", + "[-1 0 0], 8)\n", + "([0 0 1]\n", + "[0 1 0]\n", + "[1 0 0], 9)\n", + "([-1 0 0]\n", + "[ 0 0 1]\n", + "[ 0 -1 0], 10)\n", + "([ 0 0 -1]\n", + "[-1 0 0]\n", + "[ 0 1 0], 11)\n", + "([-1 0 0]\n", + "[ 0 0 -1]\n", + "[ 0 1 0], 12)\n", + "([ 0 0 -1]\n", + "[ 0 -1 0]\n", + "[ 1 0 0], 13)\n", + "([ 0 0 -1]\n", + "[ 0 1 0]\n", + "[-1 0 0], 14)\n", + "([ 0 -1 0]\n", + "[ 0 0 -1]\n", + "[ 1 0 0], 15)\n", + "([ 0 0 -1]\n", + "[ 1 0 0]\n", + "[ 0 -1 0], 16)\n", + "([ 0 0 1]\n", + "[ 0 -1 0]\n", + "[-1 0 0], 17)\n", + "([ 0 0 1]\n", + "[-1 0 0]\n", + "[ 0 -1 0], 18)\n", + "([ 0 1 0]\n", + "[ 0 0 -1]\n", + "[-1 0 0], 19)\n", + "([ 1 0 0]\n", + "[ 0 0 -1]\n", + "[ 0 -1 0], 20)\n", + "([-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1], 21)\n", + "([ 0 -1 0]\n", + "[ 1 0 0]\n", + "[ 0 0 -1], 22)\n", + "([ 0 1 0]\n", + "[-1 0 0]\n", + "[ 0 0 -1], 23)\n", + "([ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1], 24)\n", + "(0, -1, 1, 1)\n", + "(1, -1, 1, 1)\n", + "(2, -1, 1, 1)\n", + "(3, 1, 3, 0)\n", + "(4, 1, 0, 2)\n", + "(5, 1, -1, 1)\n", + "(6, 1, 0, 2)\n", + "(7, 1, 0, 2)\n", + "(8, -1, 1, 1)\n", + "(9, -1, -1, 3)\n", + "(10, 1, 0, 2)\n", + "(11, -1, -1, 3)\n", + "(12, -1, -1, 3)\n", + "(13, -1, 1, 1)\n", + "(14, 1, 0, 2)\n", + "(15, 1, 0, 2)\n", + "(16, -1, -1, 3)\n", + "(17, 1, 0, 2)\n", + "(18, 1, 0, 2)\n", + "(19, -1, 1, 1)\n", + "(20, 1, -1, 1)\n", + "(21, -1, -1, 3)\n", + "(22, -1, -1, 3)\n", + "(23, 1, -1, 1)\n" + ] + } + ], + "source": [ + "K. = NumberField(x^2 - 2, embedding=1.4)\n", + "g=[]\n", + "count=3\n", + "g.append(reflection_matrix([-1/r, 1/r, 0]))\n", + "g.append(reflection_matrix([0, -1/r, 1/r]))\n", + "g.append(reflection_matrix([1/r, 1/r, 0]))\n", + "\n", + "g\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "\n", + "I3 = identity_matrix(3)\n", + "\n", + "g_inverse = []\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " if (I3-g[i]*g[j])<0.01:\n", + " g_inverse.append(g[j])\n", + "\n", + "I3 = identity_matrix(3) \n", + "tmp = identity_matrix(3)\n", + "for i in range(count):\n", + " for j in range(10):\n", + " tmp = tmp * g[i]\n", + " if (tmp - I3).norm().abs() < 0.01:\n", + " break\n", + " print(i, g[i].determinant(), g[i].trace(), j)\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('coset', 0, 0)\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "('coset', 0, 1)\n", + "[0 0 1]\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "[0 1 0]\n", + "('coset', 0, 2)\n", + "[ 0 -1 0]\n", + "[-1 0 0]\n", + "[ 0 0 1]\n", + "[ 0 -1 0]\n", + "[-1 0 0]\n", + "[ 0 0 1]\n", + "('coset', 0, 3)\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "('coset', 1, 0)\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "('coset', 1, 1)\n", + "[0 0 1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "[0 1 0]\n", + "('coset', 1, 2)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "[ 0 -1 0]\n", + "[-1 0 0]\n", + "[ 0 0 1]\n", + "('coset', 1, 3)\n", + "[0 0 1]\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "('coset', 2, 0)\n", + "[ 0 0 1]\n", + "[-1 0 0]\n", + "[ 0 -1 0]\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "('coset', 2, 1)\n", + "[0 1 0]\n", + "[0 0 1]\n", + "[1 0 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "[0 1 0]\n", + "('coset', 2, 2)\n", + "[ 0 0 -1]\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 -1 0]\n", + "[-1 0 0]\n", + "[ 0 0 1]\n", + "('coset', 2, 3)\n", + "[-1 0 0]\n", + "[ 0 0 1]\n", + "[ 0 -1 0]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n", + "('coset', 3, 0)\n", + "[ 1 0 0]\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]\n", + "[0 1 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "('coset', 3, 1)\n", + "[ 0 -1 0]\n", + "[ 0 0 -1]\n", + "[ 1 0 0]\n", + "[1 0 0]\n", + "[0 0 1]\n", + "[0 1 0]\n", + "('coset', 3, 2)\n", + "[-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1]\n", + "[ 0 -1 0]\n", + "[-1 0 0]\n", + "[ 0 0 1]\n", + "('coset', 3, 3)\n", + "[ 0 -1 0]\n", + "[ 1 0 0]\n", + "[ 0 0 -1]\n", + "[1 0 0]\n", + "[0 1 0]\n", + "[0 0 1]\n" + ] + } + ], + "source": [ + "# bit of conjugacy classes if you fancy\n", + "\n", + "for i in range(4):\n", + " for j in range(4):\n", + " print(\"coset\", i, j)\n", + " print(g[i] * g[j] * g_inverse[i])\n", + " print(g[j])\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Do H3 next: sub in simple roots into the general reflection formula above, then generate the group\n", + "\n", + "$H_3$: $\\alpha_1=(0,1,0)^T, \\alpha_2=-\\frac{1}{2}(\\tau,1,(\\tau-1))^T, \\alpha_3=(0,0,1)^T$\n", + "\n", + "$\\tau$ is the golden ratio $\\tau = \\frac{1}{2}(1+\\sqrt{5})\\sim 1.618$ and satisfies the relation $\\tau^2=\\tau+1$.\n", + "\n", + "\n", + "You will need to modify the two earlier examples to either deal with $\\tau$ numerically (i.e. to within a certain error) or via the recursion relation. " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false, + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "([1 0 0]\n", + "[0 1 0]\n", + "[0 0 1], 4)\n", + "([ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 1/4*sqrt(5) - 1/4]\n", + "[ 1/2 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4], 5)\n", + "([-1 0 0]\n", + "[ 0 1 0]\n", + "[ 0 0 -1], 6)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4], 7)\n", + "([-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4], 8)\n", + "([ 1/4*sqrt(5) + 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 1/2], 9)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4], 10)\n", + "([-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4], 11)\n", + "([ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4], 12)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 1/4*sqrt(5) - 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4], 13)\n", + "([-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4], 14)\n", + "([ 1/4*sqrt(5) + 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 -1/2], 15)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4], 16)\n", + "([-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4], 17)\n", + "([ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4], 18)\n", + "([-1/4*sqrt(5) - 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 1/2], 19)\n", + "([-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4], 20)\n", + "([-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 1/4*sqrt(5) - 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4], 21)\n", + "([ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4], 22)\n", + "([-1/4*sqrt(5) - 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 -1/2], 23)\n", + "([-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4], 24)\n", + "([ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 -1/2 -1/4*sqrt(5) + 1/4], 25)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4], 26)\n", + "([ -1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 -1/2 -1/4*sqrt(5) + 1/4], 27)\n", + "([ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 -1/2 1/4*sqrt(5) - 1/4], 28)\n", + "([ 0 0 -1]\n", + "[-1 0 0]\n", + "[ 0 -1 0], 29)\n", + "([ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 -1/2 1/4*sqrt(5) - 1/4], 30)\n", + "([-1/4*sqrt(5) - 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 1/2], 31)\n", + "([ 1/4*sqrt(5) + 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 -1/2], 32)\n", + "([ 1/4*sqrt(5) + 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 1/2], 33)\n", + "([-1/4*sqrt(5) - 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 -1/2], 34)\n", + "([-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ 1/2 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4], 35)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4], 36)\n", + "([ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 -1/2 -1/4*sqrt(5) + 1/4], 37)\n", + "([-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4], 38)\n", + "([ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 1/4*sqrt(5) - 1/4], 39)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4], 40)\n", + "([ -1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 -1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 1/4*sqrt(5) - 1/4], 41)\n", + "([ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[-1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 -1/4*sqrt(5) + 1/4], 42)\n", + "([ 0 0 -1]\n", + "[-1 0 0]\n", + "[ 0 1 0], 43)\n", + "([ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 1/4*sqrt(5) + 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 1/2 -1/4*sqrt(5) + 1/4], 44)\n", + "([-1/4*sqrt(5) - 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 -1/2], 45)\n", + "([ 1/4*sqrt(5) + 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 1/2], 46)\n", + "([ 1/4*sqrt(5) + 1/4 1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 -1/2], 47)\n", + "([-1/4*sqrt(5) - 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 1/2], 48)\n", + "([-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 -1/2]\n", + "[ 1/4*sqrt(5) + 1/4 -1/2 1/4*sqrt(5) - 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 1/4*sqrt(5) + 1/4], 49)\n", + "([ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[-1/4*sqrt(5) - 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4], 50)\n", + "([ 1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4]\n", + "[ 1/4*sqrt(5) - 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 1/2 1/4*sqrt(5) - 1/4], 51)\n", + "([-1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4 1/2]\n", + "[ 1/4*sqrt(5) + 1/4 -1/2 -1/4*sqrt(5) + 1/4]\n", + "[ -1/2 -1/4*sqrt(5) + 1/4 -1/4*sqrt(5) - 1/4], 52)\n" + ] + } + ], + "source": [ + "\n", + "g = []\n", + "count = 3\n", + "\n", + "g.append(reflection_matrix([1, 0, 0]))\n", + "g.append(reflection_matrix([-1/4*(1+sqrt(5)), -1/2, -1/4*(1-sqrt(5))]))\n", + "g.append(reflection_matrix([0, 0, 1]))\n", + "\n", + "# Build g\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = (g[i] * g[j]).apply_map(expand)\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = (g[i] * g[j]).apply_map(expand)\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "\n", + "I3 = identity_matrix(3)\n", + "\n", + "g_inverse = []\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " if (I3-g[i]*g[j])<0.01:\n", + " g_inverse.append(g[j])\n", + "\n", + "I3 = identity_matrix(3) \n", + "tmp = identity_matrix(3)\n", + "for i in range(count):\n", + " for j in range(10):\n", + " tmp = tmp * g[i]\n", + " if (tmp - I3).norm().abs() < 0.01:\n", + " break\n", + " print(i, g[i].determinant(), g[i].trace(), j)\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "K5.
= NumberField(x^2 - x - 1, embedding=1.6)\n", + "\n", + "g=[]\n", + "count=3\n", + "g.append(reflection_matrix((1, 0, 0)))\n", + "g.append(reflection_matrix((-1/2*a, -1/2, -1/2*(1-a)))\n", + "g.append(reflection_matrix((0, 0, 1)))\n", + "\n", + "g\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "\n", + "I3 = identity_matrix(3)\n", + "\n", + "g_inverse = []\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " if (I3-g[i]*g[j])<0.01:\n", + " g_inverse.append(g[j])\n", + "\n", + "I3 = identity_matrix(3) \n", + "tmp = identity_matrix(3)\n", + "for i in range(count):\n", + " for j in range(10):\n", + " tmp = tmp * g[i]\n", + " if (tmp - I3).norm().abs() < 0.01:\n", + " break\n", + " print(i, g[i].determinant(), g[i].trace(), j+1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "K. = NumberField(x^2-5)\n", + "\n", + "g=[]\n", + "count=3\n", + "g.append(reflection_matrix((1, 0, 0))\n", + "g.append(reflection_matrix((-1/4*(1+a), -1/2, -1/4*(1-a)))\n", + "g.append(reflection_matrix((0, 0, 1))\n", + "\n", + "g\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " new = True\n", + " tmp = g[i] * g[j]\n", + " for k in range(count):\n", + " if (tmp - g[k]).norm().abs() < 0.01:\n", + " new = False\n", + " if new:\n", + " count += 1\n", + " g.append(tmp)\n", + " print(g[-1], count)\n", + "\n", + "\n", + "I3 = identity_matrix(3)\n", + "\n", + "g_inverse = []\n", + "\n", + "for i in range(count):\n", + " for j in range(count):\n", + " if (I3-g[i]*g[j])<0.01:\n", + " g_inverse.append(g[j])\n", + "\n", + "I3 = identity_matrix(3) \n", + "tmp = identity_matrix(3)\n", + "for i in range(count):\n", + " for j in range(10):\n", + " tmp = tmp * g[i]\n", + " if (tmp - I3).norm().abs() < 0.01:\n", + " break\n", + " print(i, g[i].determinant(), g[i].trace(), j+1)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/06-rotational-subgroup.ipynb b/_episodes_ipynb/06-rotational-subgroup.ipynb new file mode 100644 index 0000000..0bf0ad8 --- /dev/null +++ b/_episodes_ipynb/06-rotational-subgroup.ipynb @@ -0,0 +1,111 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Rotational Subgroup\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "g" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [], + "source": [ + "counteven=0\n", + "g_even = []\n", + "for i in range(count):\n", + " if (((g[i]).determinant()-1).abs() < 0.01):\n", + " counteven += 1\n", + " g_even.append(g[i])\n", + " print(g_even[-1], counteven) #\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "closed = false\n", + "\n", + "for i in range(counteven):\n", + " for j in range(counteven):\n", + "\n", + " tmp = g_even[i] * g_even[j]\n", + " new = true\n", + "\n", + " #create a function that compares to group elements and returns label k if it is contained in the group?\n", + " for k in range(counteven):\n", + " if (tmp - g_even[k]).norm().abs() < 0.01:\n", + " new = false\n", + " break\n", + " \n", + " if new: \n", + " print(\"not closed\")\n", + " closed = false\n", + " break\n", + "\n", + "if closed: \n", + " print (\"closed\")\n", + "\n", + "g_even_inverse = []\n", + "\n", + "#create a function that makes inverses\n", + "for i in range(counteven):\n", + " for j in range(counteven):\n", + " if (I3-g_even[i] * g_even[j])<0.01:\n", + " g_even_inverse.append(g[j])\n", + " print(g_even_inverse[-1]) #\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/07-orbits.ipynb b/_episodes_ipynb/07-orbits.ipynb new file mode 100644 index 0000000..381f43f --- /dev/null +++ b/_episodes_ipynb/07-orbits.ipynb @@ -0,0 +1,121 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Orbits\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---\n", + "\n", + "Make an icosahedron by picking a seed vector on a 5-fold axis" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "icosahedron_dupl = []\n", + "T5 = vector([0,1,1.618]) \n", + "seed = T5\n", + "for i in range(counteven):\n", + " icosahedron_dupl.append(g_even[i] * seed)\n", + "\n", + "\n", + "\n", + "# now delete duplicates - do ito golden ratio, or round or convert to set etc\n", + "\n", + "icosahedron_dupl\n", + "\n", + "icosahedron = []\n", + "\n", + "\n", + "# define function take orbit" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Make a dodecahedron by picking a seed vector on a 3-fold axis" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "dodecahedron = []\n", + "T3 = vector([1,1,1]) \n", + "seed = T3\n", + "for i in range(counteven):\n", + " dodecahedron.append(g_even[i] * seed)\n", + "\n", + "\n", + "\n", + "# now delete duplicates - do ito golden ratio, or round or convert to set etc\n", + "# define function take orbit" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Make a icosidodecahedron by picking a seed vector on a 2-fold axis" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "icosidodecahedron = []\n", + "T2 = vector([1,0,0]) \n", + "seed = T2\n", + "for i in range(counteven):\n", + " icosidodecahedron.append(g_even[i] * seed)\n", + "\n", + "# plot\n", + "# now delete duplicates - do ito golden ratio, or round or convert to set etc\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/08-polytopes.ipynb b/_episodes_ipynb/08-polytopes.ipynb new file mode 100644 index 0000000..5d5f68c --- /dev/null +++ b/_episodes_ipynb/08-polytopes.ipynb @@ -0,0 +1,96 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Display polytopes\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "point3d(icosahedron, size=100)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "icosahedron=[v.change_ring(RDF) for v in icosahedron]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "P=Polyhedron(icosahedron)\n", + "plot(P)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "point3d(dodecahedron, size=100)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "point3d(icosidodecahedron, size=100)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/09-idd.ipynb b/_episodes_ipynb/09-idd.ipynb new file mode 100644 index 0000000..6496d2f --- /dev/null +++ b/_episodes_ipynb/09-idd.ipynb @@ -0,0 +1,64 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: IDD\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---\n", + "\n", + "Show IDD is a root system." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "IDD=icosidodecahedron\n", + "\n", + "for points in IDD:\n", + " if not (-points in IDD):\n", + " print(\"first axiom violated\")\n", + "\n", + "for points in IDD:\n", + " for refl in IDD:\n", + " tmp = reflection_matrix(refl[1], n2=refl[2], n3=refl[3]) * points\n", + " if not (tmp in IDD):\n", + " print(\"second axiom violated\", tmp)\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/10-conjugacy-classes.ipynb b/_episodes_ipynb/10-conjugacy-classes.ipynb new file mode 100644 index 0000000..f05d35d --- /dev/null +++ b/_episodes_ipynb/10-conjugacy-classes.ipynb @@ -0,0 +1,59 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Conjugacy Classes\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "cc = []\n", + "\n", + "\n", + "\n", + "for i in range(4):\n", + " for j in range(4):\n", + " print(\"coset\", i, j)\n", + " print(g[i] * g[j] * g_inverse[i])\n", + " print(g[j])\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/11-number-and-dimensions-of-irreducible-representations.ipynb b/_episodes_ipynb/11-number-and-dimensions-of-irreducible-representations.ipynb new file mode 100644 index 0000000..63cbbe9 --- /dev/null +++ b/_episodes_ipynb/11-number-and-dimensions-of-irreducible-representations.ipynb @@ -0,0 +1,40 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Number and Dimensions of Irreducible Representations\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/12-pymol-visualisation.ipynb b/_episodes_ipynb/12-pymol-visualisation.ipynb new file mode 100644 index 0000000..1ca7d6c --- /dev/null +++ b/_episodes_ipynb/12-pymol-visualisation.ipynb @@ -0,0 +1,79 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: More advanced Caspar-Klug orbits and pymol visualisation\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[[0.904721509025590, 0.0879675935421300, 0.416822136685000],\n", + " [0.979660168810660, 0.0952540054366200, 0.176614348770000],\n", + " [0.894764055651420, 0.317512115546100, 0.313979842320000],\n", + " [0.986175314321600, 0.165705309322800, 0]]" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "seeds = [[ 0.904721509025590, 0.0879675935421300, 0.416822136685000], \n", + "[0.979660168810660, 0.0952540054366200, 0.176614348770000], \n", + "[0.894764055651420, 0.317512115546100, 0.313979842320000],\n", + "[0.986175314321600, 0.165705309322800, 0]]\n", + "seeds\n", + "\n", + "T4capsid = []\n", + "\n", + "for seed in seeds:\n", + " for i in range(count_even):\n", + " T4capsid.append(g_even[i] * seed)\n", + " \n", + "point3d(T4capsid, size=100)\n", + " \n", + " " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_episodes_ipynb/13-cartan-matrix.ipynb b/_episodes_ipynb/13-cartan-matrix.ipynb new file mode 100644 index 0000000..316bc52 --- /dev/null +++ b/_episodes_ipynb/13-cartan-matrix.ipynb @@ -0,0 +1,180 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "---\n", + "title: Cartan matrix and Perron-Frobenius eigenvector\n", + "teaching: 30\n", + "exercises: 0\n", + "questions:\n", + "- \"...\"\n", + "objectives:\n", + "- \"...\"\n", + "---" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# define Cartan matrix - function of arbitrary number of vectors?\n", + "\n", + "# find eigenvalues using SAGE routine\n", + "\n", + "# find the Perron-Frobenius eigenvalue\n", + "\n", + "def Cartan_matrix(Delta, symbolic=False):\n", + " \"\"\"\n", + " Return the Cartan matrix for a simple system\n", + " \n", + " INPUT:\n", + " \n", + " - ``Delta`` -- list of vectors or any iterable that can be turned into a vector\n", + " - \n", + "\n", + " EXAMPLES::\n", + "\n", + " sage: Delta = ((1, 0, 0)), ((0, 1, 0)), ((0, 0, 1))\n", + " sage: C = Cartan_matrix(Delta)\n", + " sage: C\n", + " [2 0 0]\n", + " [0 2 0]\n", + " [0 0 2]\n", + " \"\"\"\n", + " Delta=[vector(v) for v in Delta]\n", + "\n", + " M = matrix([[2 / w.dot_product(w) * v.dot_product(w) for w in Delta] for v in Delta])\n", + " \n", + " if symbolic:\n", + " M = M.apply_map(expand)\n", + " \n", + " return M" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[ 2 -1 0]\n", + "[ -1 2 -1/2*sqrt(5) - 1/2]\n", + "[ 0 -1/2*sqrt(5) - 1/2 2]" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Delta = ((0, 1, 0)), ((-1/4*(1+sqrt(5)), -1/2, 1/4*(1-sqrt(5)))), ((1, 0, 0))\n", + "\n", + "Delta\n", + "\n", + "C = Cartan_matrix(Delta, symbolic=True)\n", + "C" + ] + }, + { + "cell_type": "code", + "execution_count": 132, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[(-1/2*sqrt(2*sqrt(5) + 10) + 2,\n", + " [(1, 1/2*sqrt(2*sqrt(5) + 10), 1/2*sqrt(5) + 1/2)],\n", + " 1),\n", + " (1/2*sqrt(2*sqrt(5) + 10) + 2,\n", + " [(1, -1/2*sqrt(2*sqrt(5) + 10), 1/2*sqrt(5) + 1/2)],\n", + " 1),\n", + " (2, [(1, 0, -1/2*sqrt(5) + 1/2)], 1)]" + ] + }, + "execution_count": 132, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "E = C.eigenvectors_right()\n", + "E\n", + "\n", + " \n", + "A=QQbar(E[1][1][0][2])\n", + "A\n", + "E" + ] + }, + { + "cell_type": "code", + "execution_count": 142, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1, 1/2*sqrt(2*sqrt(5) + 10), 1/2*sqrt(5) + 1/2)\n" + ] + } + ], + "source": [ + "# find PF eigenvector i.e. all coefficients of the same sign\n", + "for i in range(3):\n", + " tmp = E[i][1][0]\n", + " if all (x * tmp[0] > 0 for x in tmp):\n", + " print(tmp)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# find duals to roots (weights), construct two vectors from two-colouring of the graph and the PF evec just found; orthonormalise and project root system into this plane\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "SageMath 7.4", + "language": "", + "name": "sagemath" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/_layouts/ipynb2md.tpl b/_layouts/ipynb2md.tpl index 5822b4d..805dc2b 100644 --- a/_layouts/ipynb2md.tpl +++ b/_layouts/ipynb2md.tpl @@ -26,7 +26,6 @@ {% endblock traceback_line %} {% block execute_result %} - {% block data_priority scoped %} {{ super() }} {% endblock %} @@ -34,7 +33,7 @@ {% block stream %} ~~~ -{{ output.text | indent }} +{{ output.text }} ~~~ {: .output} {% endblock stream %} @@ -64,7 +63,10 @@ {% endblock data_markdown %} {% block data_text scoped %} -{{ output.data['text/plain'] | indent }} +~~~ +{{ output.data['text/plain'] }} +~~~ +{: .output} {% endblock data_text %} {%- block markdowncell scoped -%}