Skip to content

Commit 60e3ebf

Browse files
committed
Pass on basically all documentation pages
1 parent cee8775 commit 60e3ebf

File tree

10 files changed

+422
-390
lines changed

10 files changed

+422
-390
lines changed

www/doc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ <h2>Documentation</h2>
3535
<ul>
3636
<li><a href="doc/latest/input.html">Input format</a>: what sorts of expressions Herbie supports.</li>
3737
<li><a href="doc/latest/options.html">Command-line flags</a>: modifying Herbie's behavior.</li>
38+
<li><a href="doc/latest/error.html">What is error?</a>: how Herbie measures floating-point error.</li>
3839
<li><a href="doc/latest/faq.html">FAQ</a>: troubleshooting Herbie.</li>
3940
<li><a href="doc/latest/release-notes.html">Release Notes</a>: the biggest and latest changes to Herbie.</li>
4041
</ul>

www/doc/2.0/docker.html

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ <h2>Installing Herbie via Docker</h2>
4848

4949
<pre>docker run -it uwplse/herbie shell</pre>
5050

51-
<p>This will read input from the standard input.</p>
51+
<p>This will download the Herbie image and then run
52+
its <a href="options.html">shell tool</a>.</p>
5253

53-
<p>Note that Herbie in Docker is more limited; for example, it will
54-
not recognize plugins installed outside the Docker container.</p>
54+
<p>Herbie in Docker is more limited; for example, it will not
55+
recognize plugins installed outside the Docker container.</p>
5556

5657
<h2>Running the web interface</h2>
5758

@@ -113,30 +114,51 @@ <h2>Generating files and reports</h2>
113114
have the correct permissions set.
114115
</p>
115116

116-
<h2>For developers: updating the Docker image + Dockerfile</h2>
117+
<h2>Building the Docker image</h2>
118+
119+
<p>This section is primarily of interest for the Herbie developers.</p>
117120

118121
<p>
119-
For building and testing, first clone the repo and confirm that Herbie builds correctly with <code>make install</code>.
122+
Clone the repo and confirm that Herbie builds correctly
123+
with <code>make install</code>.
120124
</p>
125+
121126
<p>
122-
Next, examine the Dockerfile and Makefile together. The Dockerfile should follow a process exactly like the Makefile, except a clean initial environment is assumed. The build may be split into 2 or more stages to limit the size of the resulting image. Each stage consists of a <code>FROM</code> command and a series of further commands to build up the desired environment, and later stages can refer to earlier stages by name--for example, <code>COPY --from=earlier-stage ...</code> can copy files compiled in earlier images. You may need to do things like bumping the version of Rust used for binary compilation or the version of Racket used in production, or adjusting paths to match the newest version of the repo.
123-
</p>
124-
<p>
125-
Once you are ready to build:
126-
<pre class="shell">docker build -t herbie-testbuild .</pre>
127-
from the repo's main directory will build a new test image with the tag <code>herbie-testbuild</code>. You can run this image with
128-
<pre class="shell">docker run -p 8000:80 -it herbie-testbuild</pre>
129-
and see the web demo in the host machine's browser at <code>http://localhost:8000</code>.
127+
Next, examine the Dockerfile and Makefile together. The Dockerfile
128+
should follow a process exactly like the Makefile, except a clean
129+
initial environment is assumed. The build may be split into 2 or
130+
more stages to limit the size of the resulting image. Each stage
131+
consists of a <code>FROM</code> command and a series of further
132+
commands to build up the desired environment, and later stages can
133+
refer to earlier stages by name&mdash;for example, <code>COPY
134+
--from=earlier-stage ...</code> can copy files compiled in earlier
135+
images. You may need to do things like bumping the version of Rust
136+
used for binary compilation or the version of Racket used in
137+
production, or adjusting paths to match the newest version of the
138+
repo.
130139
</p>
140+
141+
<p>Once you are ready to build, run this command from the repository root:</p>
142+
143+
<pre class="shell">docker build -t uwplse/herbie:test .</pre>
144+
145+
<p>This builds a new test image and tags
146+
it <code>uwplse/herbie:test</code>. You can run this image with:</p>
147+
148+
<pre class="shell">docker run -p 8000:80 -it uwplse/herbie:test</pre>
149+
150+
<p>The web demo should now be visiable at <code>http://localhost:8000</code>.</p>
131151

132-
<p>
133-
To open a shell in a running container for testing, first get the container ID with
152+
<p>To open a shell in a running container for testing, first get the container ID with:</p>
153+
134154
<pre class="shell">docker ps</pre>
135-
and then open a shell in the container as root with
155+
156+
<p>Then open a root shell in that container with</p>
157+
136158
<pre class="shell">docker exec -it &lt;CONTAINER ID&gt; sh</pre>
137159

138-
The code and egg-herbie binaries should be under <code>/src</code>.
139-
</p>
160+
<p>The code and egg-herbie binaries should be
161+
under <code>/src</code>.</p>
140162

141163
</body>
142164
</html>

www/doc/2.0/error.html

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ <h1>What is Error?</h1>
2020
<p>
2121
<a href="../../">Herbie</a> helps you identify and correct floating
2222
point error in your numeric programs. But what is floating point
23-
error, how does Herbie measure it, and how does it address it?
23+
error, and how does Herbie measure it?
2424
</p>
2525

2626
<h2>The summary</h2>
2727

28-
When Herbie reports a "percentage accuracy" number like 92.3%, it's
28+
<p>When Herbie reports a "percentage accuracy" number like 92.3%, it's
2929
usually best to think of that as the percentage of floating-point
30-
inputs where the expression is reasonably accurate.
30+
inputs where the expression is reasonably accurate.</p>
3131

32-
What exactly that means can vary: the impact of this error on your
33-
application will depend a lot on <em>which</em> 7.7% of points have
34-
error, and what kind of error that is. If you have more information
35-
about which types of points are important, the best way to communicate
36-
that to Herbie is by using ranges or preconditions to restrict the
37-
inputs Herbie is considering.
32+
<p>The impact of this error on your application will depend a lot
33+
on <em>which</em> 7.7% of inputs are inaccurate, and what kind of
34+
error that is. You can find this out using
35+
the <a href="report.html">accuracy graph in Herbie reports</a>. You
36+
can also use preconditions to restrict the inputs Herbie is
37+
considering.</p>
3838

3939
<h2>Why rounding matters</h2>
4040

@@ -46,11 +46,10 @@ <h2>Why rounding matters</h2>
4646
be <em>rounded</em> to a representable one.</p>
4747

4848
<p>Take an extreme example: the code <code>1e100 + 1</code>, which
49-
increments a huge number, in IEEE 754 double-precision floating-point
50-
(which Herbie calls <code>binary64</code>). There's an exact
51-
real-number answer to this (a one followed by 99 zeros and then
52-
another 1), but the closest <em>floating-point</em> value is the same
53-
as for <code>1e100</code>.</p>
49+
increments a huge number in IEEE 754 double-precision floating-point.
50+
There's an exact real-number answer, a one followed by 99 zeros and
51+
then another 1, but the closest <em>floating-point</em> value is the
52+
same as <code>1e100</code>.</p>
5453

5554
<p>Errors like this can cause problems. In the example above, the
5655
answers differ by one part per googol, which is pretty small. But the
@@ -110,38 +109,39 @@ <h2>Percentage accuracy</h2>
110109
percentage across many randomly-sampled valid inputs.</p>
111110

112111
<p>Typically, inputs points are either very accurate or not accurate
113-
at all. So when computing average error, Herbie's averaging a lot of
114-
points with near-100% accuracy and a lot of points with near-0%
115-
accuracy. In that sense, you can think of average error as measuring
116-
mostly what percentage <em>of inputs</em> are accurate. If Herbie says
117-
your computation is 75% accurate what it's really saying is that about
118-
a quarter of inputs produce usable outputs.</p>
119-
120-
<p>Interpreting average error also requires understanding which inputs
121-
are valid and how they are sampled.</p>
112+
at all. So when computing percentage accuracy, Herbie's averaging a
113+
lot of points with near-100% accuracy and a lot of points with near-0%
114+
accuracy. In that sense, you can think of percentage accuracy as
115+
measuring mostly what percentage <em>of inputs</em> are accurate. If
116+
Herbie says your computation is 75% accurate what it's really saying
117+
is that about a quarter of inputs produce usable outputs.</p>
122118

123119
<h2>Valid inputs</h2>
124120

125-
<p>Herbie considers an input valid if its true, real-number output 1)
126-
exists; 2) rounds to a finite number; 3) can be computed; and 4)
127-
satisfies the user's precondition. Let's dive into each
128-
requirement.</p>
121+
<p>Since percentage accuracy averages over many points, it depends on
122+
what points it is averaging over, and how is samples among them.
123+
Herbie samples among <em>valid</em> inputs, uniformly distributed.</p>
124+
125+
<p>Herbie considers an input valid if it is a floating-point value in
126+
the appropriate precision and its true, real-number output 1) exists;
127+
2) satisfies the user's precondition; and 3) can be computed. Let's
128+
dive into each requirement.</p>
129129

130130
<ol>
131131
<li>An output can fail to exist for an input if that input does
132132
something like divide by zero or take the square root of a
133133
negative number. Then that input is invalid.</li>
134-
<li>An output can fail to satisfy the user's precondition.
134+
<li>An input can fail to satisfy the user's precondition.
135135
Preconditions can be basically anything, but most often they
136136
specify a range of inputs. For example, if the precondition
137137
is <code>(&lt; 1 x 2)</code>, then the input <code>x = 3</code> is
138138
invalid.</li>
139-
<li>Finally, and most rarely, an output can fail to be computed in
140-
some rare situations. For example, the computation <code>(/ (exp
139+
<li>Finally, and most rarely, Herbie can fail to compute the output
140+
for a particular input. For example, the computation <code>(/ (exp
141141
1e9) (exp 1e9))</code>, which divides two identical but gargantuan
142-
numbers, does have an exact real-number answer (one) but that
143-
exact answer can't be computed by Herbie because the intermediate
144-
steps are too large. This input is also invalid.</li>
142+
numbers, does have an exact real-number answer (one), but Herbie
143+
can't compute that exact answer because the intermediate steps are
144+
too large. This input is also invalid.</li>
145145
</ol>
146146

147147
<p>Herbie's percentage accuracy metric only averages over valid

www/doc/2.0/input.html

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,21 @@ <h1>The Input Format</h1>
2626
input program, and has extensive options for precisely describing
2727
its context.
2828
</p>
29+
30+
<h2>Math format</h2>
31+
32+
<p>The Herbie web shell takes input in a subset of
33+
the <a href="https://mathjs.org/docs/expressions/syntax.html">math.js
34+
syntax</a>. The web shell automatically checks for syntax errors,
35+
and provides a graphical user interface for specifying the input
36+
domain. The web shell converts the mathematical expression and input
37+
ranges into FPCore before sending it to Herbie.</p>
2938

30-
<h2 id="sec1">General format</h2>
39+
<h2 id="sec1">FPCore format</h2>
3140

32-
<p><a href="http://fpbench.org">FPCore</a> format looks like this:</p>
41+
<p>Herbie's command-line and batch-mode tools
42+
use <a href="http://fpbench.org">FPCore</a> format to describe
43+
mathematical expressions. FPCore looks like this:</p>
3344

3445
<pre>(FPCore (<var>inputs ...</var>) <var>properties ...</var> <var>expression</var>)</pre>
3546
<pre>(FPCore <var>name</var> (<var>inputs ...</var>) <var>properties ...</var> <var>expression</var>)</pre>
@@ -38,7 +49,6 @@ <h2 id="sec1">General format</h2>
3849
Each <var>input</var> is a variable name, like <code>x</code>,
3950
used in the <var>expression</var>. Properties are used to specify
4051
additional information about the <var>expression</var>'s context.
41-
As of version 1.5, Herbie supports named functions.
4252
If <var>name</var> is specified, the function can be referenced in
4353
subsequent FPCore declarations in the file.
4454
</p>
@@ -90,13 +100,9 @@ <h2>Supported functions</h2>
90100

91101
<p>Herbie links against your computer's <code>libm</code> to
92102
evaluate these functions. So, each function has the same behavior in
93-
Herbie as in your code.</p>
94-
95-
<p>On Windows, the Bessel functions are not available in the
96-
system <code>libm</code>, so Herbie will use a fallback
97-
implementation and print a warning. Turn off the
98-
the <kbd>precision:fallback</kbd> <a href="options.html">option</a>
99-
to disable those functions instead.</p>
103+
Herbie as in your code. You can instead use
104+
the <a href="#precisions"><code>racket</code> precision</a> if you
105+
instead want reproducible behavior.</p>
100106

101107
<h2 id="conditionals">Conditionals</h2>
102108

@@ -117,14 +123,15 @@ <h2 id="conditionals">Conditionals</h2>
117123
<dd>The two boolean values</dd>
118124
</dl>
119125

120-
<p>The comparison functions implement chained comparisons with more than two arguments.</p>
126+
<p>The comparison functions support chained comparisons with more than two arguments.</p>
121127

122128
<h2 id="intermediates">Intermediate variables</h2>
123129

124130
<p>Intermediate variables can be defined
125131
using <code>let</code> and <code>let*</code>:</p>
126132

127133
<pre>(let ([<var>variable</var> <var>value</var>] <var>...</var>) <var>body</var>)</pre>
134+
<pre>(let* ([<var>variable</var> <var>value</var>] <var>...</var>) <var>body</var>)</pre>
128135

129136
<p>In both <code>let</code> and <code>let*</code>,
130137
each <var>variable</var> is bound to its <var>value</var> and can be
@@ -145,10 +152,31 @@ <h2 id="intermediates">Intermediate variables</h2>
145152
values can refer to earlier variables.</dd>
146153
</dl>
147154

148-
<p>Note that Herbie treats intermediate values only as a notational
149-
convenience, and inlines their values before improving the formula's
150-
accuracy. Using intermediate variables will not help Herbie improve
151-
a formula's accuracy or speed up its run-time.</p>
155+
<p>Unless you have a lot of Lisp experience, you'll probably
156+
find <code>let*</code> more intuitive.</p>
157+
158+
<p>Internally, Herbie treats intermediate values only as a
159+
notational convenience, and inlines their values before improving
160+
the formula's accuracy. Using intermediate variables will therefore
161+
not produce a more accurate result or help Herbie run faster.</p>
162+
163+
<h2 id="specs">Specifications</h2>
164+
165+
<p>In some cases, your input program is an approximation of some
166+
more complex mathematical expression. The <code>:spec</code> (for
167+
“specification”) lets you specify the more complex ideal case.
168+
Herbie will then try to modify the input program to make it more
169+
accurately evaluate the specification.</p>
170+
171+
<p>For example, suppose you want to evaluate <code>sin(1/x)</code>
172+
via a series expansion. Write:</p>
173+
174+
<pre>(FPCore (x)
175+
:spec (sin (/ 1 x))
176+
(+ (/ 1 x) (/ 1 (* 6 (pow x 3)))))</pre>
177+
178+
<p>Herbie will only use the <code>:spec</code> expression to
179+
evaluate error, not to search for accurate expressions.</p>
152180

153181
<h2 id="preconditions">Preconditions</h2>
154182

@@ -186,41 +214,19 @@ <h2 id="precisions">Precisions</h2>
186214
a <a href="plugins.html">plugin system</a> to load additional
187215
precisions.</p>
188216

189-
<h2 id="conversions">Conversions</h2>
190-
191-
<p>Herbie supports conversions between different precisions.
192-
All conversions are assumed to be bi-directional. You can
193-
specify conversions with the <code>:herbie-conversions</code>
194-
property.</p>
217+
<p>Herbie won't produce mixed-precision code unless you allow it to
218+
do so, using the <code>:herbie-conversions</code> property:</p>
195219

196220
<dl class="function-list">
197221
<dt><code>:herbie-conversions<br/>([<var>prec1</var> <var>prec2</var>] ...)</code></dt>
198-
<dd>If an expression is computed with precision <code>prec1</code>,
199-
Herbie is allowed to rewrite all (or some) of the expression so it
200-
is computed with precision <code>prec2</code> and vice versa.</dd>
222+
<dd>Expressions in precision <code>prec1</code>, can be rewriten
223+
to use precision <code>prec2</code>, and vice versa.</dd>
201224
</dl>
202225

203-
<p>For example, to let Herbie introduce single-precision
204-
code when <code>:precision</code> is set to <code>binary64</code> or vice versa,
205-
specify <code>:herbie-conversions ((binary64 binary32))</code></p>
206-
207-
<h2 id="specs">Specifications</h2>
208-
209-
<p>In some cases, your input program is an approximation of some
210-
more complex mathematical expression. The <code>:spec</code> (for
211-
“specification”) lets you specify the more complex ideal case.
212-
Herbie will then try to modify the input program to make it more
213-
accurately evaluate the specification.</p>
214-
215-
<p>For example, suppose you want to evaluate <code>sin(1/x)</code>
216-
via a series expansion. Write:</p>
217-
218-
<pre>(FPCore (x)
219-
:spec (sin (/ 1 x))
220-
(+ (/ 1 x) (/ 1 (* 6 (pow x 3)))))</pre>
221-
222-
<p>Herbie will only use the <code>:spec</code> expression to
223-
evaluate error, not to search for accurate expressions.</p>
226+
<p>All conversions are assumed to be bidirectional. For example, if
227+
you specify <code>:herbie-conversions ([binary64 binary32])</code>,
228+
Herbie will be able to add conversions between single- and
229+
double-precision floating-point.</p>
224230

225231
<h2 id="properties">Miscellaneous Properties</h2>
226232

@@ -245,7 +251,7 @@ <h2 id="properties">Miscellaneous Properties</h2>
245251

246252
<p>Herbie's benchmark suite also uses properties such
247253
as <code>:herbie-target</code> for continuous integration, but these
248-
are not supported and their use is discouraged.</p>
254+
are not officially supported and their use is discouraged.</p>
249255

250256
</body>
251257
</html>

0 commit comments

Comments
 (0)