-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmandistudent.dtx
2166 lines (2141 loc) · 65.8 KB
/
mandistudent.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
% !TEX program = lualatexmk
%
% Copyright (C) 2021-2024 by Paul J. Heafner <heafnerj@gmail.com>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the conditions of the
% LaTeX Project Public License, either version 1.3c of this license or (at
% your option) any later version. The latest version of this license is in
% https://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX version
% 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Paul J. Heafner.
%
% This work consists of the files mandi.dtx
% mandistudent.dtx
% mandiexp.dtx
% mandi.ins
% mandi.pdf
% README.md
%
% and includes the derived files mandi.sty
% mandistudent.sty
% mandiexp.sty
% vdemo.py (not needed)
% ---------------------------------------------------------------------------
%
%<*vdemo>
from vpython import *
scene.width = 400
scene.height = 760
# constants and data
g = 9.8 # m/s^2
mball = 0.03 # kg
Lo = 0.26 # m
ks = 1.8 # N/m
deltat = 0.01 # s
# objects (origin is at ceiling)
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01,
width=0.2)
ball = sphere(pos=vector(0,-0.3,0),radius=0.025,
color=color.orange)
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos,
color=color.cyan,thickness=0.003,coils=40,
radius=0.010)
# initial values
pball = mball * vector(0,0,0) # kg m/s
Fgrav = mball * g * vector(0,-1,0) # N
t = 0
# improve the display
scene.autoscale = False # turn off automatic camera zoom
scene.center = vector(0,-Lo,0) # move camera down
scene.waitfor('click') # wait for a mouse click
# initial calculation loop
# calculation loop
while t < 10:
rate(100)
# we need the stretch
s = mag(ball.pos) - Lo
# we need the spring force
Fspring = ks * s * -norm(spring.axis)
Fnet = Fgrav + Fspring
pball = pball + Fnet * deltat
ball.pos = ball.pos + (pball / mball) * deltat
spring.axis = ball.pos - ceiling.pos
t = t + deltat
%</vdemo>
%
%<*driver>
\ProvidesFile{mandistudent.dtx}
\DisableCrossrefs % index descriptions only
\PageIndex % index refers to page numbers
\CodelineNumbered % number source lines
\RecordChanges % record changes
\begin{document} % main document
\DocInput{\jobname.dtx} %
\PrintIndex %
\end{document} % end main document
%</driver>
% \fi
%
% ^^A DO NOT TRY TO COMPILE THIS DTX FILE BY ITSELF. IT WILL FAIL.
%
% \section{The \mandistudent{} Package}\setplace{sec:mandib}
%
% \mandi{} comes with an accessory package \mandistudent,
% which extends \mandi{} with a collection of commands physics
% students can use for writing problem solutions. This package
% focuses on the most frequently needed tools. These commands
% should always be used in math mode. \mandistudent{} requires,
% and loads, \mandi{} but \mandi{} doesn't require, and doesn't
% load, \mandistudent.
%
% Load \mandistudent{} as you would any package in your preamble.
% There are no package options.
%
%\iffalse
%<*example>
%\fi
\begin{dispListing*}{sidebyside = false,listing only}
\usepackage{mandistudent}
\end{dispListing*}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommand}{mandistudentversion}{}
Typesets the current version and build date.
\end{docCommand}
\begin{dispExample*}{sidebyside = false}
The version is \mandistudentversion{} and is a stable build.
\end{dispExample*}
%\iffalse
%</example>
%\fi
%
% \subsection{Traditional Vector Notation}
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc updated = 2021-09-18,%
doc parameter = \marg{symbol}\oarg{labels},%
]%
{%
{%
doc name = vec,%
doc description = use this variant for boldface notation,%
},%
{%
doc name = vec*,%
doc description = use this variant for arrow notation,%
}%
}%
Powerful and intelligent command for symbolic vector notation. The
mandatory argument is the symbol for the vector quantity. The optional
label(s) consists of superscripts and/or subscripts and can be
mathematical or textual in nature. If textual, be sure to wrap them in
|\symup{...}| for proper typesetting. The starred variant gives arrow
notation whereas without the star you get boldface notation. Subscript
and superscript labels can be arbitrarily mixed, and order doesn't matter.
This command redefines the default \LaTeXe |\vec| command.
\end{docCommands}
\begin{dispExample*}{lefthand ratio = 0.6}
\( \vec{p} \) \\
\( \vec{p}_{2} \) \\
\( \vec{p}^{\symup{ball}} \) \\
\( \vec{p}_{\symup{final}} \) \\
\( \vec{p}^{\symup{ball}}_{\symup{final}} \) \\
\( \vec{p}^{\symup{final}}_{\symup{ball}} \) \\
\( \vec*{p} \) \\
\( \vec*{p}_{2} \) \\
\( \vec*{p}^{\symup{ball}} \) \\
\( \vec*{p}_{\symup{final}} \) \\
\( \vec*{p}^{\symup{ball}}_{\symup{final}} \) \\
\( \vec*{p}^{\symup{final}}_{\symup{ball}} \)
\end{dispExample*}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc updated = 2021-09-18,%
doc parameter = \marg{symbol}\oarg{labels},%
]%
{%
{%
doc name = dirvec,%
doc description = use this variant for boldface notation,%
},%
{%
doc name = dirvec*,%
doc description = use this variant for arrow notation,%
}%
}%
Powerful and intelligent command for typesetting the direction of
a vector. The options are the same as those for \refCom{vec}.
\end{docCommands}
\begin{dispExample*}{lefthand ratio = 0.65}
\( \dirvec{p} \) \\
\( \dirvec{p}_{2} \) \\
\( \dirvec{p}^{\symup{ball}} \) \\
\( \dirvec{p}_{\symup{final}} \) \\
\( \dirvec{p}^{\symup{ball}}_{\symup{final}} \) \\
\( \dirvec{p}^{\symup{final}}_{\symup{ball}} \) \\
\( \dirvec*{p} \) \\
\( \dirvec*{p}_{2} \) \\
\( \dirvec*{p}^{\symup{ball}} \) \\
\( \dirvec*{p}_{\symup{final}} \) \\
\( \dirvec*{p}^{\symup{ball}}_{\symup{final}} \) \\
\( \dirvec*{p}^{\symup{final}}_{\symup{ball}} \)
\end{dispExample*}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}
{%
{%
doc name = zerovec,%
doc description = use this variant for boldface notation,%
},%
{%
doc name = zerovec*,%
doc description = use this variant for arrow notation,%
},%
}%
Command for typesetting the zero vector. The starred variant gives
arrow notation. Without the star you get boldface notation.
\end{docCommands}
\begin{dispExample}
\( \zerovec \) \\
\( \zerovec* \)
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommand}{changein}{}%
Semantic alias for |\Delta|.
\end{docCommand}
\begin{dispExample}
\( \changein t \) \\
\( \changein \vec{p} \)
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc new = 2021-02-21,%
doc parameter = \oarg{size}\marg{quantity},%
]%
{%
{%
doc name = doublebars,%
doc description = double bars,%
},%
{%
doc name = doublebars*,%
doc description = double bars for fractions,%
},%
{%
doc name = singlebars,%
doc description = single bars,%
},%
{%
doc name = singlebars*,%
doc description = single bars for fractions,%
},%
{%
doc name = anglebrackets,%
doc description = angle brackets,%
},%
{%
doc name = anglebrackets*,%
doc description = angle brackets for fractions,%
},%
{%
doc name = parentheses,%
doc description = parentheses,%
},%
{%
doc name = parentheses*,%
doc description = parentheses for fractions,%
},%
{%
doc name = squarebrackets,%
doc description = square brackets,%
},%
{%
doc name = squarebrackets*,%
doc description = square brackets for fractions,%
},%
{%
doc name = curlybraces,%
doc description = curly braces,%
},%
{%
doc name = curlybraces*,%
doc description = curly braces for fractions,%
},%
}%
If no argument is given, a placeholder is provided.
Sizers like |\big|,|\Big|,|\bigg|, and |\Bigg| can
be optionally specified. Beginners are encouraged
not to use them. See the
\href{https://www.ctan.org/pkg/mathtools}{\pkg{mathtools}} package
documentation for details.
\end{docCommands}
\begin{dispExample}
\[ \doublebars{} \]
\[ \doublebars{\vec{a}} \]
\[ \doublebars*{\frac{\vec{a}}{3}} \]
\[ \doublebars[\Bigg]{\frac{\vec{a}}{3}} \]
\end{dispExample}
\begin{dispExample}
\[ \singlebars{} \]
\[ \singlebars{x} \]
\[ \singlebars*{\frac{x}{3}} \]
\[ \singlebars[\Bigg]{\frac{x}{3}} \]
\end{dispExample}
\begin{dispExample}
\[ \anglebrackets{} \]
\[ \anglebrackets{\vec{a}} \]
\[ \anglebrackets*{\frac{\vec{a}}{3}} \]
\[ \anglebrackets[\Bigg]{\frac{\vec{a}}{3}} \]
\end{dispExample}
\begin{dispExample}
\[ \parentheses{} \]
\[ \parentheses{x} \]
\[ \parentheses*{\frac{x}{3}} \]
\[ \parentheses[\Bigg]{\frac{x}{3}} \]
\end{dispExample}
\begin{dispExample}
\[ \squarebrackets{} \]
\[ \squarebrackets{x} \]
\[ \squarebrackets*{\frac{x}{3}} \]
\[ \squarebrackets[\Bigg]{\frac{x}{3}} \]
\end{dispExample}
\begin{dispExample}
\[ \curlybraces{} \]
\[ \curlybraces{x} \]
\[ \curlybraces*{\frac{x}{3}} \]
\[ \curlybraces[\Bigg]{\frac{x}{3}} \]
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc new = 2021-02-21,%
doc parameter = \oarg{size}\marg{quantity},%
]%
{%
{%
doc name = magnitude,%
doc description = alias for double bars,%
},%
{%
doc name = magnitude*,%
doc description = alias for double bars for fractions,%
},%
{%
doc name = norm,%
doc description = alias for double bars,%
},%
{%
doc name = norm*,%
doc description = alias for double bars for fractions,%
},%
{%
doc name = absolutevalue,%
doc description = alias for single bars,%
},%
{%
doc name = absolutevalue*,%
doc description = alias for single bars for fractions,%
},%
}%
Semantic aliases. Use \refCom{magnitude} or \refCom{magnitude*} to
typeset the magnitude of a vector.
\end{docCommands}
\begin{dispExample}
\[ \magnitude{\vec{p}} \]
\[ \magnitude{\vec*{p}} \]
\[ \magnitude*{\vec{p}_{\symup{final}}} \]
\[ \magnitude*{\vec*{p}_{\symup{final}}} \]
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc new = 2021-04-06,%
]%
{%
{%
doc name = parallelto,%
},%
{%
doc name = perpendicularto,%
},%
}%
Commands for geometric relationships, mainly
intended for subscripts.
\end{docCommands}
\begin{dispExample*}{lefthand ratio = 0.6}
\( \vec{F}_{\parallelto} + \vec{F}_{\perpendicularto} \)
\end{dispExample*}
%\iffalse
%</example>
%\fi
%
% \subsection{Problems and Annotated Problem Solutions}
%
%\iffalse
%<*example>
%\fi
\begin{docEnvironments}[%
doc updated = 2023-08-01,%
doc parameter = \marg{title},%
doclang/environment content = problem,%
]%
{%
{%
doc name = physicsproblem,%
doc description = use this variant for vertical lists,%
},%
{%
doc name = physicsproblem*,%
doc description = use this variant for in-line lists,%
},%
{%
doc name = parts,%
doc description = provides problem parts,%
},%
}%
Provides an environment for stating physics problems. Each problem will
begin on a new page. See the examples for how to handle single and
multiple part problems. Due to incompatibilities with \textsc{beamer}
and the \pkg{enumitem} package, these environments are not defined if
\textsc{beamer} is loaded.
\end{docEnvironments}
\begin{docCommand}[doc updated = 2023-08-01]{problempart}{}
Denotes a part of a problem within a \refEnv{parts}
environment. This command is not defined if \textsc{beamer}
is loaded.
\end{docCommand}
\begin{dispExample*}{sidebyside = false}
\begin{physicsproblem}{Problem 1}
This is a physics problem with no parts.
\end{physicsproblem}
\end{dispExample*}
\begin{dispExample*}{sidebyside = false}
\begin{physicsproblem}{Problem 2}
This is a physics problem with multiple parts.
The list is vertical.
\begin{parts}
\problempart This is the first part.
\problempart This is the second part.
\problempart This is the third part.
\end{parts}
\end{physicsproblem}
\end{dispExample*}
\begin{dispExample*}{sidebyside = false}
\begin{physicsproblem*}{Problem 3}
This is a physics problem with multiple parts.
The list is in-line.
\begin{parts}
\problempart This is the first part.
\problempart This is the second part.
\problempart This is the third part.
\end{parts}
\end{physicsproblem*}
\end{dispExample*}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docEnvironments}[%
doc updated = 2021-02-26,%
doc parameter = {},%
doclang/environment content = solution steps,%
]%
{%
{%
doc name = physicssolution,%
doc description = use this variant for numbered steps,%
},%
{%
doc name = physicssolution*,%
doc description = use this variant for unnumbered steps,%
},%
}%
This environment is only for mathematical solutions. The starred
variant omits numbering of steps. See the examples.
\end{docEnvironments}
\begin{dispExample}
\begin{physicssolution}
x &= y + z \\
z &= x - y \\
y &= x - z
\end{physicssolution}
\begin{physicssolution*}
x &= y + z \\
z &= x - y \\
y &= x - z
\end{physicssolution*}
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommand}[doc updated = 2021-02-26]{reason}{\marg{reason}}
Provides an annotation in a step-by-step solution.
Keep reasons short and to the point. Wrap mathematical
content in math mode.
\end{docCommand}
\begin{dispExample}
\begin{physicssolution}
x &= y + z \reason{This is a reason.} \\
z &= x - y \reason{This is a reason too.} \\
y &= x - z \reason{final answer}
\end{physicssolution}
\begin{physicssolution*}
x &= y + z \reason{This is a reason.} \\
z &= x - y \reason{This is a reason too.} \\
y &= x - z \reason{final answer}
\end{physicssolution*}
\end{dispExample}
%\iffalse
%</example>
%\fi
%
% When writing solutions, remember that the \refEnv{physicssolution}
% environment is \emph{only} for mathematical content, not textual
% content or explanations.
%
%\iffalse
%<*example>
%\fi
\begin{dispListing*}{sidebyside = false,listing only}
\begin{physicsproblem}{Combined Problem and Solution}
This is an interesting physics problem.
\begin{physicssolution}
The solution goes here.
\end{physicssolution}
\end{physicsproblem}
\end{dispListing*}
\begin{dispListing*}{sidebyside = false,listing only}
\begin{physicsproblem}{Combined Multipart Problem with Solutions}
This is a physics problem with multiple parts.
\begin{parts}
\problempart This is the first part.
\begin{physicssolution}
The solution goes here.
\end{physicssolution}
\problempart This is the second part.
\begin{physicssolution}
The solution goes here.
\end{physicssolution}
\problempart This is the third part.
\begin{physicssolution}
The solution goes here.
\end{physicssolution}
\end{parts}
\end{physicsproblem}
\end{dispListing*}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommand}[doc updated = 2023-08-01]{hilite}{%
\oarg{color}\marg{target}\oarg{shape}
}%
Hilites the desired target, which can be an entire mathematical expression
or a part thereof. The default color is magenta and the default shape is a
rectangle. This command is not defined if \textsc{beamer} is loaded.
\end{docCommand}
\begin{dispListing*}{sidebyside = false,listing only}
\begin{align*}
(\Delta s)^2 &= -(\Delta t)^2 + (\Delta x)^2 + (\Delta y)^2 +
(\Delta z)^2 \\
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rounded rectangle] +
(\Delta y)^2 + (\Delta z)^2 \\
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rectangle] +
(\Delta y)^2 + (\Delta z)^2 \\
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[ellipse] +
(\Delta y)^2 + (\Delta z)^2 \\
(\Delta s)^{\hilite{2}[circle]} &= \hilite[green]{-}[circle]
(\Delta t)^{\hilite[cyan]{2}[circle]}+
(\Delta x)^{\hilite[orange]{2}[circle]} +
(\Delta y)^{\hilite[blue!50]{2}[circle]} +
(\Delta z)^{\hilite[violet!45]{2}[circle]}
\end{align*}
\end{dispListing*}
\begin{align*}
(\Delta s)^2 &= -(\Delta t)^2 + (\Delta x)^2 + (\Delta y)^2 +
(\Delta z)^2 \\
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rounded rectangle] +
(\Delta y)^2 + (\Delta z)^2 \\
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rectangle] +
(\Delta y)^2 + (\Delta z)^2 \\
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[ellipse] +
(\Delta y)^2 + (\Delta z)^2 \\
(\Delta s)^{\hilite{2}[circle]} &= \hilite[green]{-}[circle]
(\Delta t)^{\hilite[cyan]{2}[circle]}+
(\Delta x)^{\hilite[orange]{2}[circle]} +
(\Delta y)^{\hilite[blue!50]{2}[circle]} +
(\Delta z)^{\hilite[violet!45]{2}[circle]}
\end{align*}
\begin{dispListing*}{sidebyside = false,listing only}
\begin{align*}
\Delta\vec{p} &= \vec{F}_{\sumup{net}}\Delta t \\
\hilite[orange]{\Delta\vec{p}}[circle] &= \vec{F}_{\symup{net}}\Delta t \\
\Delta\vec{p} &= \hilite[yellow!50]{\vec{F}_{\symup{net}}}
[rounded rectangle]\Delta t \\
\Delta\vec{p} &= \vec{F}_{\symup{net}}\hilite[olive!50]
{\Delta t}[rectangle] \\
\Delta\vec{p} &= \hilite[cyan!50]{\vec{F}_{\symup{net}}\Delta t}
[ellipse] \\
\hilite{\Delta\vec{p}}[rectangle] &= \vec{F}_{\symup{net}}\Delta t
\end{align*}
\end{dispListing*}
\begin{align*}
\Delta\vec{p} &= \vec{F}_{\symup{net}}\Delta t \\
\hilite[orange]{\Delta\vec{p}}[circle] &= \vec{F}_{\symup{net}}
\Delta t \\
\Delta\vec{p} &= \hilite[yellow!50]{\vec{F}_{\symup{net}}}
[rounded rectangle]\Delta t \\
\Delta\vec{p} &= \vec{F}_{\symup{net}}\hilite[olive!50]{\Delta t}
[rectangle] \\
\Delta\vec{p} &= \hilite[cyan!50]{\vec{F}_{\symup{net}}\Delta t}
[ellipse] \\
\hilite{\Delta\vec{p}}[rectangle] &= \vec{F}_{\symup{net}}\Delta t
\end{align*}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommand}[doc updated = 2021-09-18]{image}{%
\oarg{options}\marg{caption}\marg{label}\marg{image}
}%
Simplified interface for importing an image. The images are treated
as floats, so they may not appear at the most logically intuitive
place.
\end{docCommand}
\begin{dispListing*}{sidebyside = false,listing only,verbatim ignore percent}
\image[scale=0.20]{example-image-1x1}
{Image shown 20 percent actual size.}{reffig1}
\end{dispListing*}
\image[scale=0.20]{example-image-1x1}
{Image shown 20 percent actual size.}{reffig1}
\begin{dispExample*}{sidebyside=false}
Figure \ref{reffig1} is nice.
It's captioned \nameref{reffig1} and is on page \pageref{reffig1}.
\end{dispExample*}
\begin{dispListing*}{sidebyside = false,listing only,verbatim ignore percent}
\image[scale=0.20,angle=45]{example-image-1x1}
{Image shown 20 percent actual size and rotated.}{reffig1}
\end{dispListing*}
\image[scale=0.20,angle=45]{example-image-1x1}
{Image shown 20 percent actual size and rotated.}{reffig2}
\begin{dispExample*}{sidebyside = false}
Figure \ref{reffig2} is nice.
It's captioned \nameref{reffig2} and is on page \pageref{reffig2}.
\end{dispExample*}
%\iffalse
%</example>
%\fi
%
% \subsection{Coordinate-Free and Index Notation}
%
% Beyond the current level of introductory physics, we need intelligent
% commands for typesetting vector and tensor symbols and components
% suitable for both coordinate-free and index notations.
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc parameter = \oarg{delimiter}\marg{\( c_{1},\dots,c_{n} \)},%
]%
{%
{%
doc name = colvec,%
},%
{%
doc name = rowvec,%
},%
}%
Typesets column vectors and row vectors as numeric or symbolic components.
There can be more than three components. The delimiter used in the list of
components can be specified; the default is a comma. Units are not
supported, so these are mainly for symbolic work.
\end{docCommands}
\begin{dispExample}
\[ \colvec{1,2,3} \]
\[ \rowvec{1,2,3} \]
\[ \colvec{x^{0},x^{1},x^{2},x^{3}} \]
\[ \rowvec{x_{0},x_{1},x_{2},x_{3}} \]
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc parameter = \marg{symbol},%
]%
{%
{%
doc name = veccomp,%
doc description = use this variant for coordinate-free vector notation,%
},%
{%
doc name = veccomp*,%
doc description = use this variant for index vector notation,%
},%
{%
doc name = tencomp,%
doc description = use this variant for coordinate-free tensor notation,%
},%
{%
doc name = tencomp*,%
doc description = use this variant for index tensor notation,%
},%
}%
Conforms to ISO 80000-2 notation.
\end{docCommands}
\begin{dispExample}
\( \veccomp{r} \) \\
\( \veccomp*{r} \) \\
\( \tencomp{r} \) \\
\( \tencomp*{r} \)
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc parameter = \marg{index}\marg{index},%
]%
{%
{%
doc name = valence,%
},%
{%
doc name = valence*,%
},%
}%
Typesets tensor valence. The starred variant typesets it horizontally.
\end{docCommands}
\begin{dispExample}
A vector is a \( \valence{1}{0} \) tensor. \\
A vector is a \( \valence*{1}{0} \) tensor.
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}[%
doc parameter = \marg{slot,slot},%
]%
{%
{%
doc name = contraction,%
},%
{%
doc name = contraction*,%
},%
}%
Typesets tensor contraction in coordinate-free notation. There
is no standard for this so we assert one here.
\end{docCommands}
\begin{dispExample}
\( \contraction{1,2} \) \\
\( \contraction*{1,2} \)
\end{dispExample}
%\iffalse
%</example>
%\fi
%
%\iffalse
%<*example>
%\fi
\begin{docCommands}%
{%
{%
doc name = slot,%
doc parameter = \oarg{vector},%
},%
{%
doc name = slot*,%
doc parameter = \oarg{vector},%
},%
}%
An intelligent slot command for coordinate-free vector
and tensor notation. The starred variants suppress the
underscore.
\end{docCommands}
\begin{dispExample}
\( (\slot) \) \\
\( (\slot[\vec{a}]) \) \\
\( (\slot*) \) \\
\( (\slot*[\vec{a}]) \)
\end{dispExample}
%\iffalse
%</example>
%\fi
%
% \changes{v3.1.0}{2022-01-27}
% {\linktoplace{sec:mandib}{mandistudent} \cs{diff} renamed to
% \refCom{df} for compatibility with the \pkg{numerica} package}
%\iffalse
%<*example>
%\fi
\begin{docCommand}[doc updated = 2022-01-27]{df}{}%
Intelligent differential and exterior derivative
operator.
\end{docCommand}
\begin{dispExample}
\[
\int x\,dx
\]
\[
\int x\,\df{x}
\]
\[
\int x\,\df*{x}
\]
\end{dispExample}
%\iffalse
%</example>
%\fi
%
% \changes{v3.1.0}{2022-01-27}
% {\linktoplace{sec:mandib}{mandistudent} All instances of
% \texttt{GlowScript} have been changed to \texttt{Web VPython}}
% \subsection{\WebVPython{} and \VPython{} Program Listings}
%
% \href{https://\gsurl}{\WebVPython}
% \footnote{On November 9, 2021 \texttt{GlowScript} was renamed to
% \WebVPython. The website was changed to
% \href{https://\gsurl}{https://\gsurl}.}
% and
% \href{https://\vpurl}{VPython}\footnote{\href{https://\vpurl}{https://\vpurl}}
% are programming environments (both use \href{https://www.python.org}{Python})
% frequently used in introductory physics to introduce students
% for modeling physical systems. \mandi{} makes including code listings
% very simple for students.
%
% \subsection{The \texttt{\small webvpythonblock} Environment}
%
%\iffalse
%<*example>
%\fi
\begin{docEnvironments}[%
doc parameter = {\oarg{options}(\meta{link})\marg{caption}},%
doclang/environment content=WebVPython code,%
]%
{%
{%
doc updated = 2023-08-01,%
doc name = webvpythonblock,%
doc description = now includes a QR code,%
},%
{%
doc updated = 2023-08-01,%
doc name = webvpythonblock*,%
doc description = use this variant to omit QR code,%
},%
}%
Code placed here is nicely formatted and optionally linked to its source on
\href{https://\gsurl}{\WebVPythonorg}, which must be in a public (not private)
folder. Clicking anywhere in the code window (between the black horizontal bars)
or on the URL will open the link in the default browser. A caption is mandatory,
and a label is internally generated. The listing always begins on a new page.
A URL shortening utility is recommended to keep the URL from getting unruly
especially if it generates an overfull box error. For convenience, |https://|
is automatically prepended to the URL and can be omitted. The |#| character
in a URL should not cause problems. The default URL is that of the \WebVPython{}
home page.
\end{docEnvironments}
\begin{dispListing*}{sidebyside = false}
\begin{webvpythonblock}
(glowscript.org/#/user/heafnerj/folder/mandidemo/program/mandidemo)
{Example With QR Code}
Web VPython 3.2
scene.width = 400
scene.height = 760
# constants and data
g = 9.8 # m/s^2
mball = 0.03 # kg
Lo = 0.26 # m
ks = 1.8 # N/m
deltat = 0.01 # s
# objects (origin is at ceiling)
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01,
width=0.2)
ball = sphere(pos=vector(0,-0.3,0),radius=0.025,
color=color.orange)
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos,
color=color.cyan,thickness=0.003,coils=40,
radius=0.010)
# initial values
pball = mball * vector(0,0,0) # kg m/s
Fgrav = mball * g * vector(0,-1,0) # N
t = 0
# improve the display
scene.autoscale = False # turn off automatic camera zoom
scene.center = vector(0,-Lo,0) # move camera down
scene.waitfor('click') # wait for a mouse click
# initial calculation loop
# calculation loop
while t < 10:
rate(100)
# we need the stretch
s = mag(ball.pos) - Lo
# we need the spring force
Fspring = ks * s * -norm(spring.axis)
Fnet = Fgrav + Fspring
pball = pball + Fnet * deltat
ball.pos = ball.pos + (pball / mball) * deltat
spring.axis = ball.pos - ceiling.pos
t = t + deltat
\end{webvpythonblock}
\end{dispListing*}
\begin{webvpythonblock}
(glowscript.org/#/user/heafnerj/folder/mandidemo/program/mandidemo)
{Example With QR Code}
Web VPython 3.2
scene.width = 400
scene.height = 760
# constants and data
g = 9.8 # m/s^2
mball = 0.03 # kg
Lo = 0.26 # m
ks = 1.8 # N/m
deltat = 0.01 # s
# objects (origin is at ceiling)
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01,
width=0.2)
ball = sphere(pos=vector(0,-0.3,0),radius=0.025,
color=color.orange)
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos,
color=color.cyan,thickness=0.003,coils=40,
radius=0.010)
# initial values
pball = mball * vector(0,0,0) # kg m/s
Fgrav = mball * g * vector(0,-1,0) # N
t = 0
# improve the display
scene.autoscale = False # turn off automatic camera zoom
scene.center = vector(0,-Lo,0) # move camera down
scene.waitfor('click') # wait for a mouse click
# initial calculation loop
# calculation loop
while t < 10:
rate(100)