| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 964 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{-298}:\\
\;\;\;\;\left(x \cdot 0.5\right) \cdot \frac{z}{\frac{y}{z}} - y \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (* x (sqrt (- (* y y) (* z z)))))
(FPCore (x y z) :precision binary64 (if (<= y -3.05e-307) (fma (- y) x (* z (* (/ z y) (* x 0.5)))) (+ (* x (* (* z (/ z y)) -0.5)) (* y x))))
double code(double x, double y, double z) {
return x * sqrt(((y * y) - (z * z)));
}
double code(double x, double y, double z) {
double tmp;
if (y <= -3.05e-307) {
tmp = fma(-y, x, (z * ((z / y) * (x * 0.5))));
} else {
tmp = (x * ((z * (z / y)) * -0.5)) + (y * x);
}
return tmp;
}
function code(x, y, z) return Float64(x * sqrt(Float64(Float64(y * y) - Float64(z * z)))) end
function code(x, y, z) tmp = 0.0 if (y <= -3.05e-307) tmp = fma(Float64(-y), x, Float64(z * Float64(Float64(z / y) * Float64(x * 0.5)))); else tmp = Float64(Float64(x * Float64(Float64(z * Float64(z / y)) * -0.5)) + Float64(y * x)); end return tmp end
code[x_, y_, z_] := N[(x * N[Sqrt[N[(N[(y * y), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[y, -3.05e-307], N[((-y) * x + N[(z * N[(N[(z / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]]
x \cdot \sqrt{y \cdot y - z \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -3.05 \cdot 10^{-307}:\\
\;\;\;\;\mathsf{fma}\left(-y, x, z \cdot \left(\frac{z}{y} \cdot \left(x \cdot 0.5\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(z \cdot \frac{z}{y}\right) \cdot -0.5\right) + y \cdot x\\
\end{array}
| Original | 24.6 |
|---|---|
| Target | 0.6 |
| Herbie | 0.3 |
if y < -3.04999999999999987e-307Initial program 24.5
Taylor expanded in y around -inf 3.2
Simplified3.2
Applied egg-rr30.5
Taylor expanded in z around 0 64.0
Simplified0.4
Applied egg-rr0.4
if -3.04999999999999987e-307 < y Initial program 24.8
Taylor expanded in y around inf 3.3
Simplified0.2
Applied egg-rr0.2
Final simplification0.3
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 964 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 964 |
| Alternative 3 | |
|---|---|
| Error | 0.5 |
| Cost | 836 |
| Alternative 4 | |
|---|---|
| Error | 0.6 |
| Cost | 388 |
| Alternative 5 | |
|---|---|
| Error | 29.6 |
| Cost | 192 |

herbie shell --seed 2022295
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, B"
:precision binary64
:herbie-target
(if (< y 2.5816096488251695e-278) (- (* x y)) (* x (* (sqrt (+ y z)) (sqrt (- y z)))))
(* x (sqrt (- (* y y) (* z z)))))