| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 836 |
\[\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-218}:\\
\;\;\;\;y \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + z \cdot \left(z \cdot \frac{-0.5}{y}\right)\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-218) (* 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-218) {
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-218) 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-218], 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^{-218}:\\
\;\;\;\;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 | 60.6% |
|---|---|
| Target | 99.0% |
| Herbie | 98.5% |
if y < -2.29999999999999995e-218Initial program 60.5%
Taylor expanded in y around -inf 98.9%
Simplified98.9%
[Start]98.9 | \[ -1 \cdot \left(y \cdot x\right)
\] |
|---|---|
associate-*r* [=>]98.9 | \[ \color{blue}{\left(-1 \cdot y\right) \cdot x}
\] |
mul-1-neg [=>]98.9 | \[ \color{blue}{\left(-y\right)} \cdot x
\] |
if -2.29999999999999995e-218 < y Initial program 60.7%
Taylor expanded in y around inf 93.6%
Simplified98.1%
[Start]93.6 | \[ -0.5 \cdot \frac{{z}^{2} \cdot x}{y} + y \cdot x
\] |
|---|---|
+-commutative [=>]93.6 | \[ \color{blue}{y \cdot x + -0.5 \cdot \frac{{z}^{2} \cdot x}{y}}
\] |
fma-def [=>]93.6 | \[ \color{blue}{\mathsf{fma}\left(y, x, -0.5 \cdot \frac{{z}^{2} \cdot x}{y}\right)}
\] |
associate-/l* [=>]90.0 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \color{blue}{\frac{{z}^{2}}{\frac{y}{x}}}\right)
\] |
unpow2 [=>]90.0 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \frac{\color{blue}{z \cdot z}}{\frac{y}{x}}\right)
\] |
associate-/r/ [=>]94.3 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \color{blue}{\left(\frac{z \cdot z}{y} \cdot x\right)}\right)
\] |
associate-/l* [=>]98.1 | \[ \mathsf{fma}\left(y, x, -0.5 \cdot \left(\color{blue}{\frac{z}{\frac{y}{z}}} \cdot x\right)\right)
\] |
Final simplification98.5%
| Alternative 1 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 836 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.2% |
| Cost | 388 |
| Alternative 3 | |
|---|---|
| Accuracy | 52.5% |
| Cost | 192 |
herbie shell --seed 2023130
(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)))))