Skip to content

Commit 5c04bb4

Browse files
committed
Add compiled files
1 parent 0708456 commit 5c04bb4

16 files changed

+1384
-41
lines changed

_episodes/01-first-session.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

_episodes/02-objects.md renamed to _episodes/01-introduction.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Objects
2+
title: First session with SageMath
33
teaching: 30
44
exercises: 0
55
questions:
@@ -8,8 +8,8 @@ objectives:
88
- "..."
99
---
1010

11-
The rest of the lesson should be written as a normal RMarkdown file. You can
12-
include chunk for codes, just like you'd normally do.
11+
Lesson text
12+
1313

1414

1515
~~~
@@ -25,6 +25,22 @@ include chunk for codes, just like you'd normally do.
2525
{: .output}
2626

2727

28+
29+
30+
~~~
31+
matrix([[1,2], [3,4]])^(-1)
32+
~~~
33+
{: .source .python}
34+
35+
36+
37+
~~~
38+
[ -2 1]
39+
[ 3/2 -1/2]
40+
~~~
41+
{: .output}
42+
43+
2844
Output with error message:
2945

3046

@@ -36,7 +52,7 @@ x[10]
3652
~~~
3753
---------------------------------------------------------------------------
3854
TypeError Traceback (most recent call last)
39-
<ipython-input-2-084faa554d6d> in <module>()
55+
<ipython-input-3-084faa554d6d> in <module>()
4056
----> 1 x[Integer(10)]
4157
4258
TypeError: 'sage.symbolic.expression.Expression' object does not support indexing
@@ -52,7 +68,7 @@ plot(sin, (0,10))
5268

5369

5470

55-
![png](../02-objects_files/02-objects_5_0.png)
71+
![png](../01-introduction_files/01-introduction_6_0.png)
5672

5773

5874
For the challenges
25.9 KB
Loading
26 KB
Loading
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
title: Multiply a matrix and a vector
3+
teaching: 30
4+
exercises: 0
5+
questions:
6+
- "..."
7+
objectives:
8+
- "..."
9+
---
10+
Let us define the 3 x 3 minus-identity matrix
11+
12+
13+
~~~
14+
A = matrix([[-1,0,0], [0,-1,0], [0,0,-1]])
15+
A
16+
~~~
17+
{: .source .python}
18+
19+
20+
21+
~~~
22+
[-1 0 0]
23+
[ 0 -1 0]
24+
[ 0 0 -1]
25+
~~~
26+
{: .output}
27+
28+
29+
Or simply
30+
31+
32+
~~~
33+
A = -identity_matrix(3)
34+
A
35+
~~~
36+
{: .source .python}
37+
38+
39+
40+
~~~
41+
[-1 0 0]
42+
[ 0 -1 0]
43+
[ 0 0 -1]
44+
~~~
45+
{: .output}
46+
47+
48+
Define vector `v` to be the vector with coordinates `x`, `y`, `z`
49+
50+
51+
~~~
52+
v = vector([x, y, z])
53+
~~~
54+
{: .source .python}
55+
56+
~~~
57+
---------------------------------------------------------------------------
58+
NameError Traceback (most recent call last)
59+
<ipython-input-3-74f33ececb47> in <module>()
60+
----> 1 v = vector([x, y, z])
61+
62+
NameError: name 'y' is not defined
63+
~~~
64+
{: .error}
65+
Didn't work... We need to define `y` (and `z`) as symbolic variables. Only `x` is defined by default when you launch Sage!
66+
67+
68+
~~~
69+
x, y, z = SR.var("x y z")
70+
~~~
71+
{: .source .python}
72+
73+
74+
~~~
75+
v = vector([x, y, z])
76+
v
77+
~~~
78+
{: .source .python}
79+
80+
81+
82+
~~~
83+
(x, y, z)
84+
~~~
85+
{: .output}
86+
87+
88+
Multiply matrix and vector using `*`
89+
90+
91+
~~~
92+
A * v
93+
~~~
94+
{: .source .python}
95+
96+
97+
98+
~~~
99+
(-x, -y, -z)
100+
~~~
101+
{: .output}
102+
103+
104+
105+
106+
~~~
107+
v.subs(x=1, y=0, z=3)
108+
~~~
109+
{: .source .python}
110+
111+
112+
113+
~~~
114+
(1, 0, 3)
115+
~~~
116+
{: .output}
117+
118+
119+
120+
121+
~~~
122+
A * v.subs(x=1, y=0, z=3)
123+
~~~
124+
{: .source .python}
125+
126+
127+
128+
~~~
129+
(-1, 0, -3)
130+
~~~
131+
{: .output}
132+
133+
134+
135+
136+
~~~
137+
A * v
138+
~~~
139+
{: .source .python}
140+
141+
142+
143+
~~~
144+
(-x, -y, -z)
145+
~~~
146+
{: .output}
147+
148+
149+
150+
151+
~~~
152+
_.subs(x=1, y=0, z=3)
153+
~~~
154+
{: .source .python}
155+
156+
157+
158+
~~~
159+
(-1, 0, -3)
160+
~~~
161+
{: .output}
162+
163+
-26.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)