| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 836 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-264}:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + \frac{-0.5 \cdot z}{\frac{y}{z}}\right)\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (* x (sqrt (- (* y y) (* z z)))))
(FPCore (x y z) :precision binary64 (if (<= y -2.3e-264) (* y (- x)) (fma y x (* -0.5 (* x (/ z (/ y z)))))))
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 <= -2.3e-264) {
tmp = y * -x;
} else {
tmp = fma(y, x, (-0.5 * (x * (z / (y / z)))));
}
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 <= -2.3e-264) tmp = Float64(y * Float64(-x)); else tmp = fma(y, x, Float64(-0.5 * Float64(x * Float64(z / Float64(y / z))))); 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, -2.3e-264], N[(y * (-x)), $MachinePrecision], N[(y * x + N[(-0.5 * N[(x * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x \cdot \sqrt{y \cdot y - z \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-264}:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, -0.5 \cdot \left(x \cdot \frac{z}{\frac{y}{z}}\right)\right)\\
\end{array}
| Original | 61.1% |
|---|---|
| Target | 99.1% |
| Herbie | 99.2% |
if y < -2.30000000000000012e-264Initial program 61.2%
Taylor expanded in y around -inf 99.1%
Simplified99.1%
[Start]99.1 | \[ -1 \cdot \left(y \cdot x\right)
\] |
|---|---|
associate-*r* [=>]99.1 | \[ \color{blue}{\left(-1 \cdot y\right) \cdot x}
\] |
mul-1-neg [=>]99.1 | \[ \color{blue}{\left(-y\right)} \cdot x
\] |
if -2.30000000000000012e-264 < y Initial program 61.0%
Taylor expanded in y around inf 94.2%
Simplified99.3%
[Start]94.2 | \[ -0.5 \cdot \frac{{z}^{2} \cdot x}{y} + y \cdot x
\] |
|---|---|
+-commutative [=>]94.2 | \[ \color{blue}{y \cdot x + -0.5 \cdot \frac{{z}^{2} \cdot x}{y}}
\] |
fma-def [=>]94.2 | \[ \color{blue}{\mathsf{fma}\left(y, x, -0.5 \cdot \frac{{z}^{2} \cdot x}{y}\right)}
\] |
associate-/l* [=>]90.1 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \color{blue}{\frac{{z}^{2}}{\frac{y}{x}}}\right)
\] |
unpow2 [=>]90.1 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \frac{\color{blue}{z \cdot z}}{\frac{y}{x}}\right)
\] |
associate-/r/ [=>]94.9 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \color{blue}{\left(\frac{z \cdot z}{y} \cdot x\right)}\right)
\] |
associate-/l* [=>]99.3 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \left(\color{blue}{\frac{z}{\frac{y}{z}}} \cdot x\right)\right)
\] |
Final simplification99.2%
| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 836 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.0% |
| Cost | 388 |
| Alternative 3 | |
|---|---|
| Accuracy | 53.4% |
| Cost | 192 |
herbie shell --seed 2023141
(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)))))