| Alternative 1 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 20608 |
\[\frac{1 - 5 \cdot \left(v \cdot v\right)}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}\right)}
\]

(FPCore (v t) :precision binary64 (/ (- 1.0 (* 5.0 (* v v))) (* (* (* PI t) (sqrt (* 2.0 (- 1.0 (* 3.0 (* v v)))))) (- 1.0 (* v v)))))
(FPCore (v t) :precision binary64 (/ (- 1.0 (* 5.0 (* v v))) (* t (* (* PI (- 1.0 (* v v))) (sqrt (fma (* v v) -6.0 2.0))))))
double code(double v, double t) {
return (1.0 - (5.0 * (v * v))) / (((((double) M_PI) * t) * sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)));
}
double code(double v, double t) {
return (1.0 - (5.0 * (v * v))) / (t * ((((double) M_PI) * (1.0 - (v * v))) * sqrt(fma((v * v), -6.0, 2.0))));
}
function code(v, t) return Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(Float64(pi * t) * sqrt(Float64(2.0 * Float64(1.0 - Float64(3.0 * Float64(v * v)))))) * Float64(1.0 - Float64(v * v)))) end
function code(v, t) return Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(t * Float64(Float64(pi * Float64(1.0 - Float64(v * v))) * sqrt(fma(Float64(v * v), -6.0, 2.0))))) end
code[v_, t_] := N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(Pi * t), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(1.0 - N[(3.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[v_, t_] := N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * N[(N[(Pi * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(v * v), $MachinePrecision] * -6.0 + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)}
\begin{array}{l}
\\
\frac{1 - 5 \cdot \left(v \cdot v\right)}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\mathsf{fma}\left(v \cdot v, -6, 2\right)}\right)}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 99.5%
Simplified99.5%
[Start]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)}
\] |
|---|---|
associate-*l* [=>]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\color{blue}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)\right)}}
\] |
sub-neg [=>]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \color{blue}{\left(1 + \left(-3 \cdot \left(v \cdot v\right)\right)\right)}} \cdot \left(1 - v \cdot v\right)\right)}
\] |
distribute-lft-in [=>]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\pi \cdot t\right) \cdot \left(\sqrt{\color{blue}{2 \cdot 1 + 2 \cdot \left(-3 \cdot \left(v \cdot v\right)\right)}} \cdot \left(1 - v \cdot v\right)\right)}
\] |
metadata-eval [=>]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\pi \cdot t\right) \cdot \left(\sqrt{\color{blue}{2} + 2 \cdot \left(-3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)\right)}
\] |
*-commutative [=>]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 + 2 \cdot \left(-\color{blue}{\left(v \cdot v\right) \cdot 3}\right)} \cdot \left(1 - v \cdot v\right)\right)}
\] |
distribute-rgt-neg-in [=>]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 + 2 \cdot \color{blue}{\left(\left(v \cdot v\right) \cdot \left(-3\right)\right)}} \cdot \left(1 - v \cdot v\right)\right)}
\] |
metadata-eval [=>]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 + 2 \cdot \left(\left(v \cdot v\right) \cdot \color{blue}{-3}\right)} \cdot \left(1 - v \cdot v\right)\right)}
\] |
Taylor expanded in t around 0 99.5%
Simplified99.6%
[Start]99.5% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(t \cdot \left(\left(1 - {v}^{2}\right) \cdot \pi\right)\right) \cdot \sqrt{-6 \cdot {v}^{2} + 2}}
\] |
|---|---|
associate-*l* [=>]99.6% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\color{blue}{t \cdot \left(\left(\left(1 - {v}^{2}\right) \cdot \pi\right) \cdot \sqrt{-6 \cdot {v}^{2} + 2}\right)}}
\] |
*-commutative [=>]99.6% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{t \cdot \left(\color{blue}{\left(\pi \cdot \left(1 - {v}^{2}\right)\right)} \cdot \sqrt{-6 \cdot {v}^{2} + 2}\right)}
\] |
unpow2 [=>]99.6% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{t \cdot \left(\left(\pi \cdot \left(1 - \color{blue}{v \cdot v}\right)\right) \cdot \sqrt{-6 \cdot {v}^{2} + 2}\right)}
\] |
*-commutative [=>]99.6% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{{v}^{2} \cdot -6} + 2}\right)}
\] |
unpow2 [=>]99.6% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{\left(v \cdot v\right)} \cdot -6 + 2}\right)}
\] |
fma-udef [<=]99.6% | \[ \frac{1 - 5 \cdot \left(v \cdot v\right)}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{\color{blue}{\mathsf{fma}\left(v \cdot v, -6, 2\right)}}\right)}
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 20608 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 20608 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.3% |
| Cost | 14464 |
| Alternative 4 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 13952 |
| Alternative 5 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 13696 |
| Alternative 6 | |
|---|---|
| Accuracy | 98.4% |
| Cost | 13696 |
| Alternative 7 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 13568 |
| Alternative 8 | |
|---|---|
| Accuracy | 97.8% |
| Cost | 13184 |
| Alternative 9 | |
|---|---|
| Accuracy | 98.3% |
| Cost | 13184 |
| Alternative 10 | |
|---|---|
| Accuracy | 97.8% |
| Cost | 13056 |
herbie shell --seed 2023167
(FPCore (v t)
:name "Falkner and Boettcher, Equation (20:1,3)"
:precision binary64
(/ (- 1.0 (* 5.0 (* v v))) (* (* (* PI t) (sqrt (* 2.0 (- 1.0 (* 3.0 (* v v)))))) (- 1.0 (* v v)))))