Skip to content

Commit 6de20ef

Browse files
authored
EV1 and EV2 sageplot 3d interactives (#1035)
* EV1 plot * Merge branch to fix xml:id error * EV2 interactive * Tweak
1 parent 542550f commit 6de20ef

7 files changed

Lines changed: 144 additions & 72 deletions

File tree

source/linear-algebra/source/01-LE/01.ptx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,15 @@ system). Otherwise it is <term>inconsistent</term>.<idx><h>inconsistent linear s
508508

509509
<figure xml:id="figure-intersecting-planes-one">
510510
<caption>Intersection of three planes at one point</caption>
511-
<image xml:id="LE1-image-intersection-planes-one" width="50%" component="print">
511+
<image xml:id="LE1-image-intersection-planes-one-print" width="50%" component="print">
512512
<sageplot variant="3d" aspect="1.0">
513513
<xi:include href="./sage/LE1-image-intersection-planes-one.sage" parse="text"/>
514514
</sageplot>
515515
<description>
516516
<p>Three planes are shown to intersect at a single point. An arrow points to the point of intersection at coordinates <m>(1,2,3)</m>.</p>
517517
</description>
518518
</image>
519-
<image xml:id="LE1-image-intersection-planes-one" component="html">
519+
<image xml:id="LE1-image-intersection-planes-one-html" component="html">
520520
<sageplot variant="3d" aspect="1.0">
521521
<xi:include href="./sage/LE1-image-intersection-planes-one.sage" parse="text"/>
522522
</sageplot>
@@ -528,15 +528,15 @@ system). Otherwise it is <term>inconsistent</term>.<idx><h>inconsistent linear s
528528

529529
<figure xml:id="figure-intersecting-planes-inf">
530530
<caption>Intersection of three planes at a line</caption>
531-
<image xml:id="LE1-image-intersection-planes-inf" width="50%" component="print">
531+
<image xml:id="LE1-image-intersection-planes-inf-print" width="50%" component="print">
532532
<sageplot variant="3d" aspect="1.0">
533533
<xi:include href="./sage/LE1-image-intersection-planes-inf.sage" parse="text"/>
534534
</sageplot>
535535
<description>
536536
<p>Three planes are shown to intersect along a line of points.</p>
537537
</description>
538538
</image>
539-
<image xml:id="LE1-image-intersection-planes-inf" component="html">
539+
<image xml:id="LE1-image-intersection-planes-inf-html" component="html">
540540
<sageplot variant="3d" aspect="1.0">
541541
<xi:include href="./sage/LE1-image-intersection-planes-inf.sage" parse="text"/>
542542
</sageplot>
@@ -548,15 +548,15 @@ system). Otherwise it is <term>inconsistent</term>.<idx><h>inconsistent linear s
548548

549549
<figure xml:id="figure-intersecting-planes-zero">
550550
<caption>Three non-mutually-intersecting planes</caption>
551-
<image xml:id="LE1-image-intersection-planes-zero" width="50%" component="print">
551+
<image xml:id="LE1-image-intersection-planes-zero-print" width="50%" component="print">
552552
<sageplot variant="3d" aspect="1.0">
553553
<xi:include href="./sage/LE1-image-intersection-planes-zero.sage" parse="text"/>
554554
</sageplot>
555555
<description>
556556
<p>Three planes are shown to intersect at no common point, although each pair of planes intersects along a line of points.</p>
557557
</description>
558558
</image>
559-
<image xml:id="LE1-image-intersection-planes-zero" component="html">
559+
<image xml:id="LE1-image-intersection-planes-zero-html" component="html">
560560
<sageplot variant="3d" aspect="1.0">
561561
<xi:include href="./sage/LE1-image-intersection-planes-zero.sage" parse="text"/>
562562
</sageplot>

source/linear-algebra/source/02-EV/01.ptx

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -221,27 +221,26 @@ we refer to this real number as a <term>scalar</term>.
221221
</p>
222222
</task>
223223
<task>
224-
<p component="html">
225-
Correct the SageMath code cell below to generate
226-
an illustration of several vectors belonging to
227-
<me>\vspan\left\{\left[\begin{array}{c}1\\2\end{array}\right],
228-
\left[\begin{array}{c}-1\\1\end{array}\right]\right\}=
229-
\setBuilder{a\left[\begin{array}{c}1\\2\end{array}\right]+
230-
b\left[\begin{array}{c}-1\\1\end{array}\right]}{a, b \in \IR}</me>
231-
in the <m>xy</m> plane.
232-
</p>
233-
<sage component="html">
234-
<input>
235-
<xi:include href="./code/ev1-planar-span.sage" parse="text" />
236-
</input>
237-
</sage>
238-
<p component="html">
239-
Based on this illustration, which of these geometrical objects
240-
best describes the span of these two vectors?
224+
<p>
225+
In addition to the combinations above, use the interactive below to graph an additional
226+
5 or more vectors belonging to
227+
<me>\vspan\left\{\left[\begin{array}{c}1\\2\end{array}\right],
228+
\left[\begin{array}{c}-1\\1\end{array}\right]\right\}=
229+
\setBuilder{a\left[\begin{array}{c}1\\2\end{array}\right]+
230+
b\left[\begin{array}{c}-1\\1\end{array}\right]}{a, b \in \IR}</me>
231+
in the <m>xy</m> plane.
241232
</p>
242-
<p component="print">
243-
Which of these geometrical objects
244-
best describes the span of these two vectors?
233+
<interactive label="EV1-interactive-span" platform="doenetml" width="100%">
234+
<slate surface="doenetml">
235+
<xi:include parse="text" href="doenet/EV1-span-two-vectors.xml"/>
236+
</slate>
237+
<description>
238+
<p>An interactive that graphs linear combinations of the vectors <m>\left[\begin{array}{c}1\\2\end{array}\right]</m> and
239+
<m> \left[\begin{array}{c}-1\\1\end{array}\right]</m>.</p>
240+
</description>
241+
</interactive>
242+
<p>
243+
Which of these geometrical objects best describes the span of these two vectors?
245244
</p>
246245
<ol marker="A." cols="4">
247246
<li>A line</li>
@@ -525,15 +524,15 @@ It is important to remember that
525524
</p>
526525
<p>
527526
For example,
528-
<me>
527+
<me>S=
529528
\setList
530529
{
531530
\left[\begin{array}{c} 1 \\ -1 \\ 2 \end{array}\right],
532531
\left[\begin{array}{c} 1 \\ 2 \\ 1 \end{array}\right]
533532
}
534533
</me>
535534
is a set containing exactly two vectors, while
536-
<me>
535+
<me>\vspan S =
537536
\vspan\setList
538537
{
539538
\left[\begin{array}{c} 1 \\ -1 \\ 2 \end{array}\right],
@@ -546,15 +545,34 @@ b\left[\begin{array}{c} 1 \\ 2 \\ 1 \end{array}\right]
546545
a,b\in\IR
547546
}
548547
</me>
549-
is a set containing infinitely-many vectors. </p>
550-
<p component="html">See the below
551-
Sage cell for an illustration.
552-
</p>
553-
<sage language="sage" component="html">
554-
<input>
555-
<xi:include href="./code/ev1-remark-span.sage" parse="text" />
556-
</input>
557-
</sage>
548+
is a set containing infinitely-many vectors.
549+
</p>
550+
<figure>
551+
<sidebyside widths="45% 45%">
552+
<image>
553+
<sageplot variant="3d" aspect="1.0">
554+
<xi:include href="./code/ev1-remark-span1.sage" parse="text" />
555+
</sageplot>
556+
<description><p>An interactive 3-D plot showing the two vectors in <m>S</m></p></description>
557+
</image>
558+
<image>
559+
<sageplot variant="3d" aspect="1.0">
560+
<xi:include href="./code/ev1-remark-span2.sage" parse="text" />
561+
</sageplot>
562+
<description><p>An interactive 3-D plot showing the vectors in <m>\vspan S</m></p></description>
563+
</image>
564+
</sidebyside>
565+
<caption>
566+
<p component="html">
567+
Two interactive 3-D plots showing the two vectors in <m>S</m> on the
568+
left and <m>\vspan S</m> on the right.
569+
</p>
570+
<p component="print">
571+
Two plots showing the two vectors in <m>S</m> on the
572+
left and <m>\vspan S</m> on the right.
573+
</p>
574+
</caption>
575+
</figure>
558576
</remark>
559577

560578
</subsection>

source/linear-algebra/source/02-EV/02.ptx

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -262,31 +262,21 @@ The vector does not belong to the span.
262262
</p>
263263
</answer>
264264
</task>
265-
<task component="html">
266-
<statement>
267-
<p>
268-
Fix the SageMath code below to visualize
265+
</activity>
266+
<observation>
267+
<p>We can use technology to visualize
269268
<m>\vspan\left\{\left[\begin{array}{c}1\\-1\\0\end{array}\right],
270269
\left[\begin{array}{c}-2\\0\\1\end{array}\right],\left[\begin{array}{c}-2\\-2\\2\end{array}\right]\right\}</m>.
271-
</p>
272-
<sage>
273-
<input>
270+
</p>
271+
<image width="70%">
272+
<sageplot variant="3d" aspect="1.0">
274273
<xi:include href="./code/ev2-span-visual.sage" parse="text" />
275-
</input>
276-
</sage>
277-
</statement>
278-
<answer>
279-
<program language="sage">
280-
<code>
281-
v2 = vector([-2,0,1])
282-
v3 = vector([-2,-2,2])
283-
# ...
284-
linear_combo = a*v1 + b*v2 + c*v3
285-
</code>
286-
</program>
287-
</answer>
288-
</task>
289-
</activity>
274+
</sageplot>
275+
<description><p>An interactive 3-D plot showing the span</p></description>
276+
</image>
277+
<p component="html">Rotate the plot to see that the vectors all lie in the same plane.</p>
278+
<p component="print">Note that the vectors all lie in the same plane.</p>
279+
</observation>
290280
<activity>
291281
<introduction>
292282
<p>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
v1 = vector([1,-1,2])
2+
v2 = vector([1,2,1])
3+
4+
# illustrate set of two vectors
5+
6+
p = plot(v1,thickness=5)
7+
p += plot(v2,thickness=5)
8+
p=p.rotate([1,0,0],3*pi/4)
9+
p

source/linear-algebra/source/02-EV/code/ev1-remark-span.sage renamed to source/linear-algebra/source/02-EV/code/ev1-remark-span2.sage

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
v1 = vector([1,-1,2])
22
v2 = vector([1,2,1])
33

4-
# illustrate set of two vectors
54

6-
p = plot(v1)
7-
p += plot(v2)
8-
show(p)
9-
10-
# illustrate the *span* that set
5+
# illustrate the *span*
116

127
p = plot([])
138
for _ in range(1000):
149
a = randrange(-99,100)
1510
b = randrange(-99,100)
16-
p += plot(a*v1+b*v2)
17-
show(p)
11+
p += plot(a*v1+b*v2, thickness=15)
12+
p=p.rotate([1,0,0],3*pi/4)
13+
p

source/linear-algebra/source/02-EV/code/ev2-span-visual.sage

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ p = plot([])
33

44
# define three vectors
55
v1 = vector([1,-1,0])
6-
v2 = vector(FIXME)
7-
v3 = vector(FIXME)
6+
v2 = vector([-2,0,1])
7+
v3 = vector([-2,-2,2])
88

99
# do this 100 times
1010
for _ in range(100):
@@ -13,9 +13,9 @@ for _ in range(100):
1313
b = randrange(-9,10)
1414
c = randrange(-9,10)
1515
# create linear combination
16-
linear_combo = a*v1 + b*v2 + FIXME
16+
linear_combo = a*v1 + b*v2 + c*v3
1717
# add it to the plot
18-
p += plot(linear_combo)
18+
p += plot(linear_combo,thickness=2)
1919

2020
# show the plot
21-
show(p)
21+
p
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<p>
2+
Enter several pairs of coefficients <m>(a,b)</m>, separated by commas:
3+
<mathInput name="in" minwidth="500" prefill="(1,1),(-2,1),(-1,-2)" />
4+
</p>
5+
6+
<setup>
7+
<math name="v"> (1,2)</math>
8+
<math name="w"> (-1,1)</math>
9+
<mathList name="l">$in</mathList>
10+
<sampleRandomNumbers numSamples="10" from="-6" to="6" name="a" asList="true"/>
11+
<sampleRandomNumbers numSamples="10" from="-6" to="6" name="b" asList="true"/>
12+
</setup>
13+
14+
<triggerSet>
15+
<!--<callAction actionName="deleteChildren" target="$g" number="1000"/>-->
16+
<callAction actionName="addChildren" target="$g">
17+
<vector draggable="false" styleNumber="1" head="$v" />
18+
<label anchor="$v" positionFromAnchor="right">
19+
<m>\left[\begin{array}{c} $v.x \\ $v.y\end{array}\right]</m>
20+
</label>
21+
<vector draggable="false" styleNumber="2" head="$w" />
22+
<label anchor="$w" positionFromAnchor="left">
23+
<m>\left[\begin{array}{c} $w.x \\ $w.y\end{array}\right]</m>
24+
</label>
25+
<repeat for="$l" valueName="c">
26+
<vector draggable="false" styleNumber="3" head="$c.x*$v+$c.y*$w"/>
27+
</repeat>
28+
</callAction>
29+
30+
<label>Plot the above linear combinations</label>
31+
</triggerSet>
32+
33+
<callAction actionName="deleteChildren" target="$g" number="1000"><label>Reset plot</label></callAction>
34+
35+
<triggerSet>
36+
<label>Add 10 random linear combinations</label>
37+
38+
<callAction target="$a" actionName="resample"/>
39+
<callAction target="$b" actionName="resample"/>
40+
<callAction actionName="addChildren" target="$g">
41+
<repeatForSequence from="0" to="10" step="1" valueName="i">
42+
<vector draggable="false" styleNumber="4" head="$a[$i]*$v+$b[$i]*$w"/>
43+
</repeatForSequence>
44+
</callAction>
45+
</triggerSet>
46+
47+
<graph name="g" xmin="-10" ymin="-10" xmax="10" ymax="10">
48+
<description>Graph of two vectors and linear combinations thereof</description>
49+
50+
<vector draggable="false" styleNumber="1" head="$v" />
51+
<label anchor="$v" positionFromAnchor="right">
52+
<m>\left[\begin{array}{c} $v.x \\ $v.y\end{array}\right]</m>
53+
</label>
54+
<vector draggable="false" styleNumber="2" head="$w" />
55+
<label anchor="$w" positionFromAnchor="left">
56+
<m>\left[\begin{array}{c} $w.x \\ $w.y\end{array}\right]</m>
57+
</label>
58+
59+
</graph>

0 commit comments

Comments
 (0)