| Alternative 1 | |
|---|---|
| Accuracy | 81.4% |
| Cost | 13252 |
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
(FPCore (x y z) :precision binary64 (if (<= y 1.15e-243) (* 2.0 (sqrt (* (+ y z) x))) (* 2.0 (* (sqrt (+ y x)) (sqrt z)))))
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 <= 1.15e-243) {
tmp = 2.0 * sqrt(((y + z) * x));
} else {
tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.15d-243) then
tmp = 2.0d0 * sqrt(((y + z) * x))
else
tmp = 2.0d0 * (sqrt((y + x)) * sqrt(z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.15e-243) {
tmp = 2.0 * Math.sqrt(((y + z) * x));
} else {
tmp = 2.0 * (Math.sqrt((y + x)) * Math.sqrt(z));
}
return tmp;
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
def code(x, y, z): tmp = 0 if y <= 1.15e-243: tmp = 2.0 * math.sqrt(((y + z) * x)) else: tmp = 2.0 * (math.sqrt((y + x)) * math.sqrt(z)) 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 <= 1.15e-243) tmp = Float64(2.0 * sqrt(Float64(Float64(y + z) * x))); else tmp = Float64(2.0 * Float64(sqrt(Float64(y + x)) * sqrt(z))); end return tmp end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.15e-243) tmp = 2.0 * sqrt(((y + z) * x)); else tmp = 2.0 * (sqrt((y + x)) * sqrt(z)); end tmp_2 = 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, 1.15e-243], N[(2.0 * N[Sqrt[N[(N[(y + z), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(y + x), $MachinePrecision]], $MachinePrecision] * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\begin{array}{l}
\mathbf{if}\;y \leq 1.15 \cdot 10^{-243}:\\
\;\;\;\;2 \cdot \sqrt{\left(y + z\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\right)\\
\end{array}
Results
| Original | 68.9% |
|---|---|
| Target | 82.2% |
| Herbie | 82.7% |
if y < 1.15e-243Initial program 69.1%
Simplified69.1%
[Start]69.1 | \[ 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\] |
|---|---|
distribute-lft-out [=>]69.1 | \[ 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z}
\] |
Taylor expanded in x around inf 67.3%
if 1.15e-243 < y Initial program 68.8%
Simplified68.8%
[Start]68.8 | \[ 2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\] |
|---|---|
distribute-lft-out [=>]68.8 | \[ 2 \cdot \sqrt{\color{blue}{x \cdot \left(y + z\right)} + y \cdot z}
\] |
Applied egg-rr68.8%
[Start]68.8 | \[ 2 \cdot \sqrt{x \cdot \left(y + z\right) + y \cdot z}
\] |
|---|---|
add-cube-cbrt [=>]68.8 | \[ 2 \cdot \sqrt{\color{blue}{\left(\sqrt[3]{x \cdot \left(y + z\right)} \cdot \sqrt[3]{x \cdot \left(y + z\right)}\right) \cdot \sqrt[3]{x \cdot \left(y + z\right)}} + y \cdot z}
\] |
pow3 [=>]68.8 | \[ 2 \cdot \sqrt{\color{blue}{{\left(\sqrt[3]{x \cdot \left(y + z\right)}\right)}^{3}} + y \cdot z}
\] |
Taylor expanded in y around 0 34.7%
Applied egg-rr68.0%
[Start]34.7 | \[ 2 \cdot \sqrt{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z}
\] |
|---|---|
rem-cbrt-cube [<=]34.7 | \[ 2 \cdot \sqrt{{\color{blue}{\left(\sqrt[3]{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3}}\right)}}^{3} + y \cdot z}
\] |
unpow1/3 [<=]34.7 | \[ 2 \cdot \sqrt{{\color{blue}{\left({\left({\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3}\right)}^{0.3333333333333333}\right)}}^{3} + y \cdot z}
\] |
unpow1/3 [=>]34.7 | \[ 2 \cdot \sqrt{{\color{blue}{\left(\sqrt[3]{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3}}\right)}}^{3} + y \cdot z}
\] |
rem-cube-cbrt [=>]34.7 | \[ 2 \cdot \sqrt{\color{blue}{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3}} + y \cdot z}
\] |
pow1/2 [=>]34.7 | \[ 2 \cdot \color{blue}{{\left({\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z\right)}^{0.5}}
\] |
add-cube-cbrt [=>]34.4 | \[ 2 \cdot {\color{blue}{\left(\left(\sqrt[3]{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z} \cdot \sqrt[3]{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z}\right) \cdot \sqrt[3]{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z}\right)}}^{0.5}
\] |
pow3 [=>]34.4 | \[ 2 \cdot {\color{blue}{\left({\left(\sqrt[3]{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z}\right)}^{3}\right)}}^{0.5}
\] |
pow-pow [=>]34.4 | \[ 2 \cdot \color{blue}{{\left(\sqrt[3]{{\left({\left(z \cdot x\right)}^{0.3333333333333333}\right)}^{3} + y \cdot z}\right)}^{\left(3 \cdot 0.5\right)}}
\] |
pow-pow [=>]68.0 | \[ 2 \cdot {\left(\sqrt[3]{\color{blue}{{\left(z \cdot x\right)}^{\left(0.3333333333333333 \cdot 3\right)}} + y \cdot z}\right)}^{\left(3 \cdot 0.5\right)}
\] |
metadata-eval [=>]68.0 | \[ 2 \cdot {\left(\sqrt[3]{{\left(z \cdot x\right)}^{\color{blue}{1}} + y \cdot z}\right)}^{\left(3 \cdot 0.5\right)}
\] |
pow1 [<=]68.0 | \[ 2 \cdot {\left(\sqrt[3]{\color{blue}{z \cdot x} + y \cdot z}\right)}^{\left(3 \cdot 0.5\right)}
\] |
*-commutative [=>]68.0 | \[ 2 \cdot {\left(\sqrt[3]{z \cdot x + \color{blue}{z \cdot y}}\right)}^{\left(3 \cdot 0.5\right)}
\] |
distribute-lft-out [=>]68.0 | \[ 2 \cdot {\left(\sqrt[3]{\color{blue}{z \cdot \left(x + y\right)}}\right)}^{\left(3 \cdot 0.5\right)}
\] |
metadata-eval [=>]68.0 | \[ 2 \cdot {\left(\sqrt[3]{z \cdot \left(x + y\right)}\right)}^{\color{blue}{1.5}}
\] |
Applied egg-rr99.4%
[Start]68.0 | \[ 2 \cdot {\left(\sqrt[3]{z \cdot \left(x + y\right)}\right)}^{1.5}
\] |
|---|---|
pow1/3 [=>]63.0 | \[ 2 \cdot {\color{blue}{\left({\left(z \cdot \left(x + y\right)\right)}^{0.3333333333333333}\right)}}^{1.5}
\] |
pow-pow [=>]68.7 | \[ 2 \cdot \color{blue}{{\left(z \cdot \left(x + y\right)\right)}^{\left(0.3333333333333333 \cdot 1.5\right)}}
\] |
metadata-eval [=>]68.7 | \[ 2 \cdot {\left(z \cdot \left(x + y\right)\right)}^{\color{blue}{0.5}}
\] |
pow1/2 [<=]68.7 | \[ 2 \cdot \color{blue}{\sqrt{z \cdot \left(x + y\right)}}
\] |
*-commutative [=>]68.7 | \[ 2 \cdot \sqrt{\color{blue}{\left(x + y\right) \cdot z}}
\] |
sqrt-prod [=>]99.4 | \[ 2 \cdot \color{blue}{\left(\sqrt{x + y} \cdot \sqrt{z}\right)}
\] |
Simplified99.4%
[Start]99.4 | \[ 2 \cdot \left(\sqrt{x + y} \cdot \sqrt{z}\right)
\] |
|---|---|
+-commutative [<=]99.4 | \[ 2 \cdot \left(\sqrt{\color{blue}{y + x}} \cdot \sqrt{z}\right)
\] |
Final simplification82.7%
| Alternative 1 | |
|---|---|
| Accuracy | 81.4% |
| Cost | 13252 |
| Alternative 2 | |
|---|---|
| Accuracy | 68.9% |
| Cost | 7104 |
| Alternative 3 | |
|---|---|
| Accuracy | 67.7% |
| Cost | 6980 |
| Alternative 4 | |
|---|---|
| Accuracy | 68.7% |
| Cost | 6980 |
| Alternative 5 | |
|---|---|
| Accuracy | 66.5% |
| Cost | 6852 |
| Alternative 6 | |
|---|---|
| Accuracy | 35.1% |
| Cost | 6720 |
herbie shell --seed 2023142
(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)))))