-
Notifications
You must be signed in to change notification settings - Fork 2
/
Examples.html
96 lines (96 loc) · 32.5 KB
/
Examples.html
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
<h2 id='welcome'>Welcome</h2>
<p>Create documents with working, well-documented calculations!</p>
<p>This is a live text editor. You can click anywhere and start typing. The calculation cells are also live. You can click on one and edit it. They will all update if you close a calculation cell with <strong>Enter</strong>.</p>
<h2 id='calculations'>Calculations</h2>
<p>To create a calculation cell, select a spot and type <strong>Alt+C</strong> or hit the <img src="./images/C.svg" alt="C" class="inline"> button. Write your calculation into the cell and write a “?” sign where the result should appear. Hit the <strong>Enter</strong> key and a completed calculation will appear, like these:</p>
<p><span class='hurmet-calc' data-entry='1//8 × 0.375 × 13.5² = ?'><math><mrow><mstyle displaystyle="false" scriptlevel="0"><mfrac><mn>1</mn><mn>8</mn></mfrac></mstyle><mo>×</mo></mrow><mrow><mn>0.375</mn><mo>×</mo></mrow><mrow><mn>13</mn><mi>.</mi><msup><mn>5</mn><mn>2</mn></msup><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo></mrow></math></span></p>
<p>You can assign a result to a variable:</p>
<p><span class='hurmet-calc' data-entry='L = 24 + 17/2 = ?'><math><mrow><mi>L</mi><mo>=</mo></mrow><mrow><mn>24</mn><mo>+</mo></mrow><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>17</mn><mn>2</mn></mfrac></mstyle><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo></mrow></math></span></p>
<p>… and then use the variable in a calculation:</p>
<p><span class='hurmet-calc' data-entry='L_2 = 2 L + 4 = ?'><math><mrow><mi>L</mi><msub><mrow></mrow><mtext>2</mtext></msub><mo>=</mo></mrow><mrow><mn>2</mn><mspace width="0.1667em"></mspace><mi>L</mi><mo>+</mo></mrow><mrow><mn>4</mn><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo></mrow></math></span></p>
<h2 id='rounding-results'>Rounding Results</h2>
<p>You can define how numeric results are rounded. The next line specifies that subsequent decimal fractions will be rounded so that no more than 3 significant digits appear.</p>
<p><span class='hurmet-calc' data-entry='format = "h3"'><math><mrow><mrow><mrow><mi mathvariant="normal">f</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow><mo>=</mo></mrow><mrow><mtext>h3</mtext></mrow></math></span></p>
<h2 id='unit-aware-calculations'>Unit-Aware Calculations</h2>
<p>Physical units can be part of your calculations. Hurmet will automatically convert the units.<br>Write unit names between single quotes, as in <code>'meter'</code>, and write a <code>??</code> where you want the result of a unit-aware calc.</p>
<p><span class='hurmet-calc' data-entry='P = 10000 'V'·20 'amps' = ?? kW'><math><mrow><mi>P</mi><mo>=</mo></mrow><mrow><mn>10</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>000</mn><mspace width="0.2778em"></mspace><mtext>V</mtext><mo>⋅</mo></mrow><mrow><mn>20</mn><mspace width="0.2778em"></mspace><mtext>amps</mtext><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo><mspace width="0.1667em"></mspace><mrow><mrow><mi mathvariant="normal">k</mi></mrow><mrow><mi mathvariant="normal">W</mi></mrow></mrow></mrow></math></span></p>
<p><span class='hurmet-calc' data-entry='A = 4 'acres''><math><mrow><mi>A</mi><mo>=</mo></mrow><mrow><mn>4</mn><mspace width="0.2778em"></mspace><mtext>acres</mtext></mrow></math></span></p>
<p><span class='hurmet-calc' data-entry='L = A/100 'feet' = ?? m'><math><mrow><mi>L</mi><mo>=</mo></mrow><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mi>A</mi><mrow><mn>100</mn><mspace width="0.2778em"></mspace><mtext>feet</mtext></mrow></mfrac></mstyle><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo><mi>m</mi></mrow></math></span></p>
<p><span class='hurmet-calc' data-entry='L_square = √A = ?? m'><math><mrow><mi>L</mi><msub><mrow></mrow><mtext>square</mtext></msub><mo>=</mo></mrow><mrow><msqrt><mi>A</mi></msqrt><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo><mi>m</mi></mrow></math></span></p>
<p><span class='hurmet-calc' data-entry='F = 200 'lbf/ft'· 100 'm/min'· 2 'hrs' = ?? kN'><math><mrow><mi>F</mi><mo>=</mo></mrow><mrow><mn>200</mn><mspace width="0.2778em"></mspace><mtext>lbf⁄ft</mtext><mo>⋅</mo></mrow><mrow><mn>100</mn><mspace width="0.2778em"></mspace><mtext>m⁄min</mtext><mo>⋅</mo></mrow><mrow><mn>2</mn><mspace width="0.2778em"></mspace><mtext>hrs</mtext><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo><mspace width="0.1667em"></mspace><mrow><mrow><mi mathvariant="normal">k</mi></mrow><mrow><mi mathvariant="normal">N</mi></mrow></mrow></mrow></math></span></p>
<p>Hurmet also does a unit-compatibility check.</p>
<p><span class='hurmet-calc' data-entry='oops = 3 'm' + 2 'hours' = ??'><math><mrow><mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">s</mi></mrow></mrow><mo>=</mo></mrow><mrow><mn>3</mn><mspace width="0.2778em"></mspace><mtext>m</mtext><mo>+</mo></mrow><mrow><mn>2</mn><mspace width="0.2778em"></mspace><mtext>hours</mtext><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo></mrow></math></span></p>
<h2 id='vectors'>Vectors</h2>
<p>Calculations<img src="images/IsoTankCourses.svg" alt="Tank Iso" class="right" width="230"> can be done on vectors. Say that we want to build a cylindrical water tank in 5-foot courses.</p>
<table class="nogrid"><tr><td style="width: 204px"><p><span class='hurmet-calc' data-entry='D = 25 'ft''><math><mrow><mi>D</mi><mo>=</mo></mrow><mrow><mn>25</mn><mspace width="0.2778em"></mspace><mtext>ft</mtext></mrow></math></span>, tank diameter</p>
</td><td><p><span class='hurmet-calc' data-entry='h = 5 'ft''><math><mrow><mi>h</mi><mo>=</mo></mrow><mrow><mn>5</mn><mspace width="0.2778em"></mspace><mtext>ft</mtext></mrow></math></span>, course height</p>
</td></tr>
<tr><td style="width: 204px"><p><span class='hurmet-calc' data-entry='H = 20 'ft''><math><mrow><mi>H</mi><mo>=</mo></mrow><mrow><mn>20</mn><mspace width="0.2778em"></mspace><mtext>ft</mtext></mrow></math></span>, tank height</p>
</td><td><p><span class='hurmet-calc' data-entry='γ_w = 62.4 'lbf/ft3''><math><mrow><mi>γ</mi><msub><mrow></mrow><mtext>w</mtext></msub><mo>=</mo></mrow><mrow><mn>62.4</mn><mspace width="0.2778em"></mspace><msup><mtext>lbf⁄ft</mtext><mn>3</mn></msup></mrow></math></span>, water density</p>
</td></tr>
</table>
<p>We’ll calculate values for each course, all at once, using vectors. Each vector element represents one course.</p>
<p>The next line creates a vector. The syntax is <code>[start:step:end...]</code>.</p>
<p><span class='hurmet-calc' data-entry='𝐡 = [h:h:H...] = ? ft'><math><mrow><mi>𝐡</mi><mo>=</mo></mrow><mrow><mo form="prefix" stretchy="false">[</mo><mi>h</mi><mo lspace="0em" rspace="0em">:</mo></mrow><mrow><mi>h</mi><mo lspace="0em" rspace="0em">:</mo></mrow><mrow><mi>H</mi><mo>…</mo><mspace width="0.1667em"></mspace></mrow><mrow><mo form="postfix" stretchy="false">]</mo><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mspace width="0.1667em"></mspace><mrow><mrow><mi mathvariant="normal">f</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow></mrow></math></span>, water depth at the bottom of each course</p>
<p><span class='hurmet-calc' data-entry='𝐩_hydro = γ_w· 𝐡 = ?? psf'><math><mrow><mrow><mi mathvariant="normal">𝐩</mi><msub><mrow></mrow><mtext>hydro</mtext></msub></mrow><mo>=</mo></mrow><mrow><mi>γ</mi><msub><mrow></mrow><mtext>w</mtext></msub><mo>⋅</mo></mrow><mrow><mi>𝐡</mi><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo><mspace width="0.1667em"></mspace><mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">s</mi></mrow><mrow><mi mathvariant="normal">f</mi></mrow></mrow></mrow></math></span>, lateral hydrostatic pressure</p>
<p><span class='hurmet-calc' data-entry='𝐭_h= 𝐩_hydro D = ?? kips/ft'><math><mrow><mrow><mi mathvariant="normal">𝐭</mi><msub><mrow></mrow><mtext>h</mtext></msub></mrow><mo>=</mo></mrow><mrow><mrow><mi mathvariant="normal">𝐩</mi><msub><mrow></mrow><mtext>hydro</mtext></msub></mrow><mspace width="0.1667em"></mspace><mi>D</mi><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo><mspace width="0.1667em"></mspace><mstyle displaystyle="true" scriptlevel="0"><mfrac><mrow><mrow><mi mathvariant="normal">k</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">s</mi></mrow></mrow><mrow><mrow><mi mathvariant="normal">f</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow></mfrac></mstyle></mrow></math></span>, hoop tension in each course</p>
<p>Vectors can replace many spreadsheet calculations. Then all of the expressions and values are open to view. That extra information helps you to avoid the errors that creep into spreadsheets.</p>
<h2 id='data-frames'>Data Frames</h2>
<p>Data can be stored in a tabular format: <span class='hurmet-calc' data-entry='rebar = ``
#size diameter area
in in²
#3 0.375 0.11
#4 0.5 0.2
#5 0.625 0.31
#6 0.75 0.44``'><math><mrow><mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">b</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow></mrow><mo>=</mo></mrow><mrow><mtable columnalign="left right right" class="tml-array"><mtr><mtd style="text-align:-webkit-left;border-right:0.06em solid;"><mtext>size</mtext></mtd><mtd style="text-align:-webkit-right;"><mtext>diameter</mtext></mtd><mtd style="text-align:-webkit-right;"><mtext>area</mtext></mtd></mtr><mtr class="tml-hline-solid"><mtd style="text-align:-webkit-left;border-right:0.06em solid;"><mrow></mrow></mtd><mtd style="text-align:-webkit-right;"><mtext>in</mtext></mtd><mtd style="text-align:-webkit-right;"><msup><mtext>in</mtext><mn>2</mn></msup></mtd></mtr><mtr><mtd style="text-align:-webkit-left;border-right:0.06em solid;"><mtext>#3</mtext></mtd><mtd style="text-align:-webkit-right;"><mn>0.375</mn></mtd><mtd style="text-align:-webkit-right;"><mn>0.11</mn></mtd></mtr><mtr><mtd style="text-align:-webkit-left;border-right:0.06em solid;"><mtext>#4</mtext></mtd><mtd style="text-align:-webkit-right;"><mrow><mn>0.5</mn><mphantom><mn>00</mn></mphantom></mrow></mtd><mtd style="text-align:-webkit-right;"><mrow><mn>0.2</mn><mphantom><mn>0</mn></mphantom></mrow></mtd></mtr><mtr><mtd style="text-align:-webkit-left;border-right:0.06em solid;"><mtext>#5</mtext></mtd><mtd style="text-align:-webkit-right;"><mn>0.625</mn></mtd><mtd style="text-align:-webkit-right;"><mn>0.31</mn></mtd></mtr><mtr><mtd style="text-align:-webkit-left;border-right:0.06em solid;"><mtext>#6</mtext></mtd><mtd style="text-align:-webkit-right;"><mrow><mn>0.75</mn><mphantom><mn>0</mn></mphantom></mrow></mtd><mtd style="text-align:-webkit-right;"><mn>0.44</mn></mtd></mtr></mtable></mrow></math></span></p>
<p>Later, you can access the data:<br><span class='hurmet-calc' data-entry='A = rebar["#3"].area = ?? in²'><math><mrow><mi>A</mi><mo>=</mo></mrow><mrow><mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">b</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow></mrow><mo form="prefix" stretchy="false">[</mo><mtext>#3</mtext><mo form="postfix" stretchy="false">]</mo><mi>.</mi><mtext>area</mtext><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo><mo form="postfix" stretchy="false">?</mo><msup><mrow><mspace width="0.2778em"></mspace><mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow></mrow><mspace width="0.2778em"></mspace></mrow><mn>2</mn></msup></mrow></math></span></p>
<h2 id='rational-numbers'>Rational Numbers</h2>
<p>Hurmet numbers are rational numbers of arbitrary precision. Unlike most programming languages, Hurmet will do the following comparison correctly:</p>
<p><span class='hurmet-calc' data-entry='(0.2 + 0.1 == 0.3) = ?'><math><mrow><mo form="prefix" stretchy="false">(</mo><mn>0.2</mn><mo>+</mo></mrow><mrow><mn>0.1</mn><mo>⩵</mo></mrow><mrow><mn>0.3</mn><mo form="postfix" stretchy="false">)</mo><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo></mrow></math></span></p>
<p>Hurmet can handle bigger numbers than many languages:</p>
<p><span class='hurmet-calc' data-entry='569936821221962380720³+ (-569936821113563493509)³ + (-472715493453327032)³= ?'><math><mrow><mn>569</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>936</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>821</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>221</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>962</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>380</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>72</mn><msup><mn>0</mn><mn>3</mn></msup><mo>+</mo></mrow><mrow><mo form="prefix" stretchy="false">(</mo><mtext>-</mtext><mn>569</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>936</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>821</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>113</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>563</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>493</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>509</mn><msup><mo form="postfix" stretchy="false">)</mo><mn>3</mn></msup><mo>+</mo></mrow><mrow><mo form="prefix" stretchy="false">(</mo><mtext>-</mtext><mn>472</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>715</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>493</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>453</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>327</mn><mo separator="true" lspace="0em" rspace="0em">,</mo></mrow><mrow><mn>032</mn><msup><mo form="postfix" stretchy="false">)</mo><mn>3</mn></msup><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo></mrow></math></span></p>
<h3 id='<strong>matrix-inversion</strong>'><strong>Matrix Inversion</strong></h3>
<p>Hurmet can solve a system of linear equations via matrix inversion.</p>
<p>The system: <span class='hurmet-calc' data-entry='{:3x + 2y + z = 39; 2x + 3y + z = 34; x + 2y + 3z = 26}'><math><mtable columnalign="center"><mtr><mtd><mrow><mn>3</mn><mi>x</mi><mo>+</mo><mn>2</mn><mi>y</mi><mo>+</mo><mi>z</mi><mo>=</mo><mn>39</mn></mrow></mtd></mtr><mtr><mtd><mrow><mn>2</mn><mi>x</mi><mo>+</mo><mn>3</mn><mi>y</mi><mo>+</mo><mi>z</mi><mo>=</mo><mn>34</mn></mrow></mtd></mtr><mtr><mtd><mrow><mi>x</mi><mo>+</mo><mn>2</mn><mi>y</mi><mo>+</mo><mn>3</mn><mi>z</mi><mo>=</mo><mn>26</mn></mrow></mtd></mtr></mtable></math></span> when restated in matrix format is: <span class='hurmet-calc' data-entry='(3, 2, 1; 2, 3, 1; 1, 2, 3) [x; y; z] = [39; 34; 26]'><math><mrow><mrow><mo fence="true" form="prefix">(</mo><mtable columnalign="center center center"><mtr><mtd><mn>3</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>1</mn></mtd></mtr><mtr><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd><mtd><mn>1</mn></mtd></mtr><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd></mtr></mtable><mo fence="true" form="postfix">)</mo></mrow><mrow><mo fence="true" form="prefix">[</mo><mtable columnalign="center"><mtr><mtd><mi>x</mi></mtd></mtr><mtr><mtd><mi>y</mi></mtd></mtr><mtr><mtd><mi>z</mi></mtd></mtr></mtable><mo fence="true" form="postfix">]</mo></mrow><mo>=</mo></mrow><mrow><mrow><mo fence="true" form="prefix">[</mo><mtable columnalign="center"><mtr><mtd><mn>39</mn></mtd></mtr><mtr><mtd><mn>34</mn></mtd></mtr><mtr><mtd><mn>26</mn></mtd></mtr></mtable><mo fence="true" form="postfix">]</mo></mrow></mrow></math></span></p>
<p>We can invert the first matrix and multiply it times both sides. That solves for each variable.</p>
<p><span class='hurmet-calc' data-entry='[x; y; z] = (3, 2, 1; 2, 3, 1; 1, 2, 3)⁻¹ [39; 34; 26] = ?'><math><mrow><mrow><mo fence="true" form="prefix">[</mo><mtable columnalign="center"><mtr><mtd><mi>x</mi></mtd></mtr><mtr><mtd><mi>y</mi></mtd></mtr><mtr><mtd><mi>z</mi></mtd></mtr></mtable><mo fence="true" form="postfix">]</mo></mrow><mo>=</mo></mrow><mrow><msup><mrow><mo fence="true" form="prefix">(</mo><mtable columnalign="center center center"><mtr><mtd><mn>3</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>1</mn></mtd></mtr><mtr><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd><mtd><mn>1</mn></mtd></mtr><mtr><mtd><mn>1</mn></mtd><mtd><mn>2</mn></mtd><mtd><mn>3</mn></mtd></mtr></mtable><mo fence="true" form="postfix">)</mo></mrow><mrow><mo>−</mo><mn>1</mn></mrow></msup><mrow><mo fence="true" form="prefix">[</mo><mtable columnalign="center"><mtr><mtd><mn>39</mn></mtd></mtr><mtr><mtd><mn>34</mn></mtd></mtr><mtr><mtd><mn>26</mn></mtd></mtr></mtable><mo fence="true" form="postfix">]</mo></mrow><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo></mrow></math></span></p>
<h2 id='reviews'>Reviews</h2>
<aside class="comment">Don’t forget diffs.</aside><p>Reviewers can write comments that are visibly different than the document.</p>
<p>You can save a document snapshot and later display the difference between the snapshot and the current document.</p>
<h2 id='user-defined-functions'>User-Defined Functions</h2>
<p>You can write your own Hurmet functions. The one below implements an infinite series developed by Francois Viète in 1597, to estimate the value of π. He derived this series:</p>
<div class="indented"><p><span class='hurmet-calc' data-entry='2/π = √2/2 · (√(2+ √2))/2 · √(2 + √(2+ √2))/2 \cdots'><math><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mi>π</mi></mfrac></mstyle><mo>=</mo></mrow><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><msqrt><mn>2</mn></msqrt><mn>2</mn></mfrac></mstyle><mo>⋅</mo></mrow><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><msqrt><mrow><mn>2</mn><mo>+</mo><msqrt><mn>2</mn></msqrt></mrow></msqrt><mn>2</mn></mfrac></mstyle><mo>⋅</mo></mrow><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><msqrt><mrow><mn>2</mn><mo>+</mo><msqrt><mrow><mn>2</mn><mo>+</mo><msqrt><mn>2</mn></msqrt></mrow></msqrt></mrow></msqrt><mn>2</mn></mfrac></mstyle><mo>⋯</mo></mrow></math></span></p>
</div><p>Here’s the function:</p>
<p><span class='hurmet-calc' data-entry='function viete(numTerms)
product = 1
radicand = 0
for i in 1:numTerms
radicand = √(2.0 + radicand)
product = product × (radicand / 2)
end
return product
end'><math><mtable columnalign="left" rowspacing="0em"><mtr><mtd style="text-align:left;"><mrow><mrow><mrow><mi mathvariant="normal">f</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow></mrow><mspace width="0.1667em"></mspace><mspace width="0.1667em"></mspace><mi>viete</mi><mo></mo></mrow><mrow><mo form="prefix" stretchy="false">(</mo><mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">T</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">s</mi></mrow></mrow><mo form="postfix" stretchy="false">)</mo></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow><mo>=</mo></mrow><mrow><mn>1</mn></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow></mrow><mo>=</mo></mrow><mrow><mn>0</mn></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mspace width="0.2778em"></mspace><mrow><mrow><mi mathvariant="normal">f</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow></mrow><mspace width="0.2778em"></mspace></mrow><mi>i</mi><mrow><mspace width="0.2778em"></mspace><mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow></mrow><mspace width="0.2778em"></mspace></mrow><mn>1</mn><mo lspace="0em" rspace="0em">:</mo></mrow><mrow><mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">T</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">s</mi></mrow></mrow></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow></mrow><mo>=</mo></mrow><mrow><msqrt><mrow><mn>2.0</mn><mo>+</mo><mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow></mrow></mrow></msqrt></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow><mo>=</mo></mrow><mrow><mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow><mo>×</mo></mrow><mrow><mrow><mo fence="true" form="prefix">(</mo><mstyle displaystyle="true" scriptlevel="0"><mfrac><mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow></mrow><mn>2</mn></mfrac></mstyle><mo fence="true" form="postfix">)</mo></mrow></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow></mrow></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mspace width="0.2778em"></mspace><mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow></mrow><mspace width="0.2778em"></mspace></mrow><mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">u</mi></mrow><mrow><mi mathvariant="normal">c</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow></mrow></mrow></mtd></mtr></mtable></math></span></p>
<p>… and now we’ll call the function and tell it to calculate the first ten terms of the series:</p>
<p><span class='hurmet-calc' data-entry='format = "h8"'><math><mrow><mrow><mrow><mi mathvariant="normal">f</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow><mo>=</mo></mrow><mrow><mtext>h8</mtext></mrow></math></span></p>
<p><span class='hurmet-calc' data-entry='approximatePi = 2/viete(10) = ?'><math><mrow><mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">x</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">P</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow></mrow><mo>=</mo></mrow><mrow><mstyle displaystyle="true" scriptlevel="0"><mfrac><mn>2</mn><mrow><mspace width="0.1667em"></mspace><mi>viete</mi><mo></mo><mo form="prefix" stretchy="false">(</mo><mn>10</mn><mo form="postfix" stretchy="false">)</mo></mrow></mfrac></mstyle><mo>=</mo></mrow><mrow><mo form="postfix" stretchy="false">?</mo></mrow></math></span>, good to 6 significant digits. Not bad for ten terms.</p>
<h2 id='drawings'>Drawings</h2>
<p>Hurmet’s <em>draw</em> environment enables function plotting. For instance, to get a sine wave, one can write the following code into a math zone:</p>
<table class="nogrid"><tr><td style="width: 298px"><pre><code>draw()
title "sin x"
frame 250, 150
view -5, 5, -3
axes 2, 1, "labels"
strokewidth 2
plot sin(x), 51
text [1.6, 1.35], "sin x"
end</code></pre></td><td><p><span class='hurmet-calc' data-entry='draw()
title "sin x"
frame 250, 150
view -5, 5, -3
axes 2, 1, "labels"
strokewidth 2
plot sin(x), 51
text [1.6, 1.35], "sin x"
end'><math><mtable columnalign="left" rowspacing="0em"><mtr><mtd style="text-align:left;"><mrow><mi>draw</mi><mo></mo></mrow><mrow><mo form="prefix" stretchy="false">(</mo><mo form="postfix" stretchy="false">)</mo></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">l</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow></mrow><mtext>sin x</mtext></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">f</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">m</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow></mrow><mspace width="0.1667em"></mspace><mn>250</mn><mo separator="true">,</mo><mspace width="0.2222em"></mspace></mrow><mrow><mn>150</mn></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">v</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">w</mi></mrow></mrow><mo>−</mo></mrow><mrow><mn>5</mn><mo separator="true">,</mo><mspace width="0.2222em"></mspace></mrow><mrow><mn>5</mn><mo separator="true">,</mo><mspace width="0.2222em"></mspace></mrow><mrow><mtext>-</mtext><mn>3</mn></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">a</mi></mrow><mrow><mi mathvariant="normal">x</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">s</mi></mrow></mrow><mspace width="0.1667em"></mspace><mn>2</mn><mo separator="true">,</mo><mspace width="0.2222em"></mspace></mrow><mrow><mn>1</mn><mo separator="true">,</mo><mspace width="0.2222em"></mspace></mrow><mrow><mtext>labels</mtext></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">s</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">r</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">k</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">w</mi></mrow><mrow><mi mathvariant="normal">i</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">h</mi></mrow></mrow><mspace width="0.1667em"></mspace><mn>2</mn></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">p</mi></mrow><mrow><mi mathvariant="normal">l</mi></mrow><mrow><mi mathvariant="normal">o</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow><mspace width="0.1667em"></mspace><mrow><mspace width="0.1667em"></mspace><mi>sin</mi><mo></mo></mrow><mo form="prefix" stretchy="false">(</mo><mi>x</mi><mo form="postfix" stretchy="false">)</mo><mo separator="true">,</mo><mspace width="0.2222em"></mspace></mrow><mrow><mn>51</mn></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mspace width="1em"></mspace><mspace width="1em"></mspace><mspace width="1em"></mspace><mrow><mrow><mi mathvariant="normal">t</mi></mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">x</mi></mrow><mrow><mi mathvariant="normal">t</mi></mrow></mrow><mspace width="0.1667em"></mspace><mrow><mo fence="true" form="prefix">[</mo><mtable columnalign="center center"><mtr><mtd><mn>1.6</mn></mtd><mtd><mn>1.35</mn></mtd></mtr></mtable><mo fence="true" form="postfix">]</mo></mrow><mo separator="true">,</mo><mspace width="0.2222em"></mspace></mrow><mrow><mtext>sin x</mtext></mrow><mo linebreak="newline"></mo></mtd></mtr><mtr><mtd style="text-align:left;"><mrow><mrow><mrow><mi mathvariant="normal">e</mi></mrow><mrow><mi mathvariant="normal">n</mi></mrow><mrow><mi mathvariant="normal">d</mi></mrow></mrow></mrow></mtd></mtr></mtable></math></span></p>
</td></tr>
</table>