| Alternative 1 | |
|---|---|
| Accuracy | 83.3% |
| Cost | 13572 |
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
(FPCore (x y z)
:precision binary64
(if (<= y -3.4e+60)
(* 2.0 (exp (+ (* 0.5 (log (- (- z) x))) (* -0.5 (log (/ -1.0 y))))))
(if (<= y 8.6e-277)
(* 2.0 (pow (fma x (+ y z) (* y z)) 0.5))
(* 2.0 (* (sqrt z) (sqrt y))))))double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+60) {
tmp = 2.0 * exp(((0.5 * log((-z - x))) + (-0.5 * log((-1.0 / y)))));
} else if (y <= 8.6e-277) {
tmp = 2.0 * pow(fma(x, (y + z), (y * z)), 0.5);
} else {
tmp = 2.0 * (sqrt(z) * sqrt(y));
}
return tmp;
}
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+60) tmp = Float64(2.0 * exp(Float64(Float64(0.5 * log(Float64(Float64(-z) - x))) + Float64(-0.5 * log(Float64(-1.0 / y)))))); elseif (y <= 8.6e-277) tmp = Float64(2.0 * (fma(x, Float64(y + z), Float64(y * z)) ^ 0.5)); else tmp = Float64(2.0 * Float64(sqrt(z) * sqrt(y))); end return tmp end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[y, -3.4e+60], N[(2.0 * N[Exp[N[(N[(0.5 * N[Log[N[((-z) - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e-277], N[(2.0 * N[Power[N[(x * N[(y + z), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+60}:\\
\;\;\;\;2 \cdot e^{0.5 \cdot \log \left(\left(-z\right) - x\right) + -0.5 \cdot \log \left(\frac{-1}{y}\right)}\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{-277}:\\
\;\;\;\;2 \cdot {\left(\mathsf{fma}\left(x, y + z, y \cdot z\right)\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\
\end{array}
| Original | 69.7% |
|---|---|
| Target | 82.8% |
| Herbie | 94.3% |
if y < -3.4e60Initial program 47.5%
Simplified47.5%
[Start]47.5 | \[ 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\] |
|---|---|
distribute-lft-out [=>]47.5 | \[ 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z}
\] |
Applied egg-rr11.8%
[Start]47.5 | \[ 2 \cdot \sqrt{x \cdot \left(y + z\right) + y \cdot z}
\] |
|---|---|
pow1/2 [=>]47.5 | \[ 2 \cdot \color{blue}{{\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{0.5}}
\] |
metadata-eval [<=]47.5 | \[ 2 \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\color{blue}{\left(0.25 + 0.25\right)}}
\] |
metadata-eval [<=]47.5 | \[ 2 \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(\color{blue}{0.5 \cdot 0.5} + 0.25\right)}
\] |
metadata-eval [<=]47.5 | \[ 2 \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(0.5 \cdot 0.5 + \color{blue}{0.5 \cdot 0.5}\right)}
\] |
pow-prod-up [<=]47.2 | \[ 2 \cdot \color{blue}{\left({\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(0.5 \cdot 0.5\right)} \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(0.5 \cdot 0.5\right)}\right)}
\] |
pow-prod-down [=>]11.8 | \[ 2 \cdot \color{blue}{{\left(\left(x \cdot \left(y + z\right) + y \cdot z\right) \cdot \left(x \cdot \left(y + z\right) + y \cdot z\right)\right)}^{\left(0.5 \cdot 0.5\right)}}
\] |
pow2 [=>]11.8 | \[ 2 \cdot {\color{blue}{\left({\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{2}\right)}}^{\left(0.5 \cdot 0.5\right)}
\] |
fma-def [=>]11.8 | \[ 2 \cdot {\left({\color{blue}{\left(\mathsf{fma}\left(x, y + z, y \cdot z\right)\right)}}^{2}\right)}^{\left(0.5 \cdot 0.5\right)}
\] |
metadata-eval [=>]11.8 | \[ 2 \cdot {\left({\left(\mathsf{fma}\left(x, y + z, y \cdot z\right)\right)}^{2}\right)}^{\color{blue}{0.25}}
\] |
Taylor expanded in y around -inf 43.1%
Simplified86.2%
[Start]43.1 | \[ 2 \cdot e^{0.25 \cdot \left(\log \left({\left(-1 \cdot z + -1 \cdot x\right)}^{2}\right) + -2 \cdot \log \left(\frac{-1}{y}\right)\right)}
\] |
|---|---|
distribute-lft-in [=>]43.1 | \[ 2 \cdot e^{\color{blue}{0.25 \cdot \log \left({\left(-1 \cdot z + -1 \cdot x\right)}^{2}\right) + 0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{y}\right)\right)}}
\] |
log-pow [=>]86.2 | \[ 2 \cdot e^{0.25 \cdot \color{blue}{\left(2 \cdot \log \left(-1 \cdot z + -1 \cdot x\right)\right)} + 0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{y}\right)\right)}
\] |
associate-*r* [=>]86.2 | \[ 2 \cdot e^{\color{blue}{\left(0.25 \cdot 2\right) \cdot \log \left(-1 \cdot z + -1 \cdot x\right)} + 0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{y}\right)\right)}
\] |
metadata-eval [=>]86.2 | \[ 2 \cdot e^{\color{blue}{0.5} \cdot \log \left(-1 \cdot z + -1 \cdot x\right) + 0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{y}\right)\right)}
\] |
mul-1-neg [=>]86.2 | \[ 2 \cdot e^{0.5 \cdot \log \left(-1 \cdot z + \color{blue}{\left(-x\right)}\right) + 0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{y}\right)\right)}
\] |
unsub-neg [=>]86.2 | \[ 2 \cdot e^{0.5 \cdot \log \color{blue}{\left(-1 \cdot z - x\right)} + 0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{y}\right)\right)}
\] |
mul-1-neg [=>]86.2 | \[ 2 \cdot e^{0.5 \cdot \log \left(\color{blue}{\left(-z\right)} - x\right) + 0.25 \cdot \left(-2 \cdot \log \left(\frac{-1}{y}\right)\right)}
\] |
associate-*r* [=>]86.2 | \[ 2 \cdot e^{0.5 \cdot \log \left(\left(-z\right) - x\right) + \color{blue}{\left(0.25 \cdot -2\right) \cdot \log \left(\frac{-1}{y}\right)}}
\] |
metadata-eval [=>]86.2 | \[ 2 \cdot e^{0.5 \cdot \log \left(\left(-z\right) - x\right) + \color{blue}{-0.5} \cdot \log \left(\frac{-1}{y}\right)}
\] |
if -3.4e60 < y < 8.59999999999999981e-277Initial program 80.5%
Simplified80.5%
[Start]80.5 | \[ 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\] |
|---|---|
distribute-lft-out [=>]80.5 | \[ 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z}
\] |
Applied egg-rr80.5%
[Start]80.5 | \[ 2 \cdot \sqrt{x \cdot \left(y + z\right) + y \cdot z}
\] |
|---|---|
pow1/2 [=>]80.5 | \[ 2 \cdot \color{blue}{{\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{0.5}}
\] |
fma-def [=>]80.5 | \[ 2 \cdot {\color{blue}{\left(\mathsf{fma}\left(x, y + z, y \cdot z\right)\right)}}^{0.5}
\] |
if 8.59999999999999981e-277 < y Initial program 71.3%
Simplified71.3%
[Start]71.3 | \[ 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\] |
|---|---|
distribute-lft-out [=>]71.3 | \[ 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z}
\] |
Applied egg-rr40.8%
[Start]71.3 | \[ 2 \cdot \sqrt{x \cdot \left(y + z\right) + y \cdot z}
\] |
|---|---|
pow1/2 [=>]71.3 | \[ 2 \cdot \color{blue}{{\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{0.5}}
\] |
metadata-eval [<=]71.3 | \[ 2 \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\color{blue}{\left(0.25 + 0.25\right)}}
\] |
metadata-eval [<=]71.3 | \[ 2 \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(\color{blue}{0.5 \cdot 0.5} + 0.25\right)}
\] |
metadata-eval [<=]71.3 | \[ 2 \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(0.5 \cdot 0.5 + \color{blue}{0.5 \cdot 0.5}\right)}
\] |
pow-prod-up [<=]70.8 | \[ 2 \cdot \color{blue}{\left({\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(0.5 \cdot 0.5\right)} \cdot {\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{\left(0.5 \cdot 0.5\right)}\right)}
\] |
pow-prod-down [=>]40.8 | \[ 2 \cdot \color{blue}{{\left(\left(x \cdot \left(y + z\right) + y \cdot z\right) \cdot \left(x \cdot \left(y + z\right) + y \cdot z\right)\right)}^{\left(0.5 \cdot 0.5\right)}}
\] |
pow2 [=>]40.8 | \[ 2 \cdot {\color{blue}{\left({\left(x \cdot \left(y + z\right) + y \cdot z\right)}^{2}\right)}}^{\left(0.5 \cdot 0.5\right)}
\] |
fma-def [=>]40.8 | \[ 2 \cdot {\left({\color{blue}{\left(\mathsf{fma}\left(x, y + z, y \cdot z\right)\right)}}^{2}\right)}^{\left(0.5 \cdot 0.5\right)}
\] |
metadata-eval [=>]40.8 | \[ 2 \cdot {\left({\left(\mathsf{fma}\left(x, y + z, y \cdot z\right)\right)}^{2}\right)}^{\color{blue}{0.25}}
\] |
Taylor expanded in x around 0 21.5%
Applied egg-rr41.4%
[Start]21.5 | \[ 2 \cdot {\left({\left(y \cdot z\right)}^{2}\right)}^{0.25}
\] |
|---|---|
pow-pow [=>]31.4 | \[ 2 \cdot \color{blue}{{\left(y \cdot z\right)}^{\left(2 \cdot 0.25\right)}}
\] |
metadata-eval [=>]31.4 | \[ 2 \cdot {\left(y \cdot z\right)}^{\color{blue}{0.5}}
\] |
pow1/2 [<=]31.4 | \[ 2 \cdot \color{blue}{\sqrt{y \cdot z}}
\] |
*-commutative [=>]31.4 | \[ 2 \cdot \sqrt{\color{blue}{z \cdot y}}
\] |
sqrt-prod [=>]41.4 | \[ 2 \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{y}\right)}
\] |
Final simplification62.8%
| Alternative 1 | |
|---|---|
| Accuracy | 83.3% |
| Cost | 13572 |
| Alternative 2 | |
|---|---|
| Accuracy | 83.1% |
| Cost | 13252 |
| Alternative 3 | |
|---|---|
| Accuracy | 69.7% |
| Cost | 7104 |
| Alternative 4 | |
|---|---|
| Accuracy | 68.4% |
| Cost | 6980 |
| Alternative 5 | |
|---|---|
| Accuracy | 69.3% |
| Cost | 6980 |
| Alternative 6 | |
|---|---|
| Accuracy | 67.4% |
| Cost | 6916 |
| Alternative 7 | |
|---|---|
| Accuracy | 67.4% |
| Cost | 6852 |
| Alternative 8 | |
|---|---|
| Accuracy | 35.4% |
| Cost | 6720 |
herbie shell --seed 2023157
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
:precision binary64
:herbie-target
(if (< z 7.636950090573675e+176) (* 2.0 (sqrt (+ (* (+ x y) z) (* x y)))) (* (* (+ (* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z))) (* (pow z 0.25) (pow y 0.25))) (+ (* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z))) (* (pow z 0.25) (pow y 0.25)))) 2.0))
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))