| Alternative 1 | |
|---|---|
| Accuracy | 97.1% |
| Cost | 13504 |
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
(FPCore (x y z)
:precision binary64
(if (<= z -80000000.0)
(/ (/ 1.0 z) (* x (* z y)))
(if (<= z 1.3e+106)
(/ (/ (/ 1.0 x) y) (+ 1.0 (* z z)))
(/ -1.0 (* (* z y) (- (* z x)))))))double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
double code(double x, double y, double z) {
double tmp;
if (z <= -80000000.0) {
tmp = (1.0 / z) / (x * (z * y));
} else if (z <= 1.3e+106) {
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
} else {
tmp = -1.0 / ((z * y) * -(z * x));
}
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 = (1.0d0 / x) / (y * (1.0d0 + (z * 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 (z <= (-80000000.0d0)) then
tmp = (1.0d0 / z) / (x * (z * y))
else if (z <= 1.3d+106) then
tmp = ((1.0d0 / x) / y) / (1.0d0 + (z * z))
else
tmp = (-1.0d0) / ((z * y) * -(z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
public static double code(double x, double y, double z) {
double tmp;
if (z <= -80000000.0) {
tmp = (1.0 / z) / (x * (z * y));
} else if (z <= 1.3e+106) {
tmp = ((1.0 / x) / y) / (1.0 + (z * z));
} else {
tmp = -1.0 / ((z * y) * -(z * x));
}
return tmp;
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
def code(x, y, z): tmp = 0 if z <= -80000000.0: tmp = (1.0 / z) / (x * (z * y)) elif z <= 1.3e+106: tmp = ((1.0 / x) / y) / (1.0 + (z * z)) else: tmp = -1.0 / ((z * y) * -(z * x)) return tmp
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function code(x, y, z) tmp = 0.0 if (z <= -80000000.0) tmp = Float64(Float64(1.0 / z) / Float64(x * Float64(z * y))); elseif (z <= 1.3e+106) tmp = Float64(Float64(Float64(1.0 / x) / y) / Float64(1.0 + Float64(z * z))); else tmp = Float64(-1.0 / Float64(Float64(z * y) * Float64(-Float64(z * x)))); end return tmp end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -80000000.0) tmp = (1.0 / z) / (x * (z * y)); elseif (z <= 1.3e+106) tmp = ((1.0 / x) / y) / (1.0 + (z * z)); else tmp = -1.0 / ((z * y) * -(z * x)); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[z, -80000000.0], N[(N[(1.0 / z), $MachinePrecision] / N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.3e+106], N[(N[(N[(1.0 / x), $MachinePrecision] / y), $MachinePrecision] / N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 / N[(N[(z * y), $MachinePrecision] * (-N[(z * x), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \leq -80000000:\\
\;\;\;\;\frac{\frac{1}{z}}{x \cdot \left(z \cdot y\right)}\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{+106}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\left(z \cdot y\right) \cdot \left(-z \cdot x\right)}\\
\end{array}
Results
| Original | 90.3% |
|---|---|
| Target | 92.3% |
| Herbie | 97.4% |
if z < -8e7Initial program 81.4%
Taylor expanded in z around inf 81.4%
Simplified89.8%
[Start]81.4 | \[ \frac{\frac{1}{x}}{y \cdot {z}^{2}}
\] |
|---|---|
*-commutative [=>]81.4 | \[ \frac{\frac{1}{x}}{\color{blue}{{z}^{2} \cdot y}}
\] |
unpow2 [=>]81.4 | \[ \frac{\frac{1}{x}}{\color{blue}{\left(z \cdot z\right)} \cdot y}
\] |
associate-*r* [<=]89.8 | \[ \frac{\frac{1}{x}}{\color{blue}{z \cdot \left(z \cdot y\right)}}
\] |
Taylor expanded in x around 0 80.3%
Simplified90.7%
[Start]80.3 | \[ \frac{1}{y \cdot \left({z}^{2} \cdot x\right)}
\] |
|---|---|
associate-/r* [=>]80.5 | \[ \color{blue}{\frac{\frac{1}{y}}{{z}^{2} \cdot x}}
\] |
unpow2 [=>]80.5 | \[ \frac{\frac{1}{y}}{\color{blue}{\left(z \cdot z\right)} \cdot x}
\] |
associate-/r* [=>]81.9 | \[ \color{blue}{\frac{\frac{\frac{1}{y}}{z \cdot z}}{x}}
\] |
associate-/r* [=>]90.7 | \[ \frac{\color{blue}{\frac{\frac{\frac{1}{y}}{z}}{z}}}{x}
\] |
Taylor expanded in y around 0 80.3%
Simplified95.6%
[Start]80.3 | \[ \frac{1}{y \cdot \left({z}^{2} \cdot x\right)}
\] |
|---|---|
unpow2 [=>]80.3 | \[ \frac{1}{y \cdot \left(\color{blue}{\left(z \cdot z\right)} \cdot x\right)}
\] |
associate-*l* [=>]88.3 | \[ \frac{1}{y \cdot \color{blue}{\left(z \cdot \left(z \cdot x\right)\right)}}
\] |
associate-*r* [=>]95.0 | \[ \frac{1}{\color{blue}{\left(y \cdot z\right) \cdot \left(z \cdot x\right)}}
\] |
associate-/l/ [<=]95.3 | \[ \color{blue}{\frac{\frac{1}{z \cdot x}}{y \cdot z}}
\] |
associate-/r* [=>]95.9 | \[ \frac{\color{blue}{\frac{\frac{1}{z}}{x}}}{y \cdot z}
\] |
associate-/r* [<=]95.6 | \[ \color{blue}{\frac{\frac{1}{z}}{x \cdot \left(y \cdot z\right)}}
\] |
if -8e7 < z < 1.3000000000000001e106Initial program 98.6%
Simplified98.5%
[Start]98.6 | \[ \frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\] |
|---|---|
associate-/r* [=>]98.5 | \[ \color{blue}{\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}}
\] |
if 1.3000000000000001e106 < z Initial program 76.6%
Taylor expanded in z around inf 76.6%
Simplified89.2%
[Start]76.6 | \[ \frac{\frac{1}{x}}{y \cdot {z}^{2}}
\] |
|---|---|
*-commutative [=>]76.6 | \[ \frac{\frac{1}{x}}{\color{blue}{{z}^{2} \cdot y}}
\] |
unpow2 [=>]76.6 | \[ \frac{\frac{1}{x}}{\color{blue}{\left(z \cdot z\right)} \cdot y}
\] |
associate-*r* [<=]89.2 | \[ \frac{\frac{1}{x}}{\color{blue}{z \cdot \left(z \cdot y\right)}}
\] |
Applied egg-rr76.6%
[Start]89.2 | \[ \frac{\frac{1}{x}}{z \cdot \left(z \cdot y\right)}
\] |
|---|---|
associate-/l/ [=>]88.7 | \[ \color{blue}{\frac{1}{\left(z \cdot \left(z \cdot y\right)\right) \cdot x}}
\] |
associate-/r* [=>]89.2 | \[ \color{blue}{\frac{\frac{1}{z \cdot \left(z \cdot y\right)}}{x}}
\] |
/-rgt-identity [<=]89.2 | \[ \frac{\frac{1}{z \cdot \left(z \cdot y\right)}}{\color{blue}{\frac{x}{1}}}
\] |
frac-2neg [=>]89.2 | \[ \frac{\frac{1}{z \cdot \left(z \cdot y\right)}}{\color{blue}{\frac{-x}{-1}}}
\] |
associate-/r/ [=>]89.2 | \[ \color{blue}{\frac{\frac{1}{z \cdot \left(z \cdot y\right)}}{-x} \cdot \left(-1\right)}
\] |
associate-*r* [=>]76.6 | \[ \frac{\frac{1}{\color{blue}{\left(z \cdot z\right) \cdot y}}}{-x} \cdot \left(-1\right)
\] |
*-commutative [=>]76.6 | \[ \frac{\frac{1}{\color{blue}{y \cdot \left(z \cdot z\right)}}}{-x} \cdot \left(-1\right)
\] |
metadata-eval [=>]76.6 | \[ \frac{\frac{1}{y \cdot \left(z \cdot z\right)}}{-x} \cdot \color{blue}{-1}
\] |
Simplified96.3%
[Start]76.6 | \[ \frac{\frac{1}{y \cdot \left(z \cdot z\right)}}{-x} \cdot -1
\] |
|---|---|
associate-/l/ [=>]76.4 | \[ \color{blue}{\frac{1}{\left(-x\right) \cdot \left(y \cdot \left(z \cdot z\right)\right)}} \cdot -1
\] |
associate-*l/ [=>]76.4 | \[ \color{blue}{\frac{1 \cdot -1}{\left(-x\right) \cdot \left(y \cdot \left(z \cdot z\right)\right)}}
\] |
metadata-eval [=>]76.4 | \[ \frac{\color{blue}{-1}}{\left(-x\right) \cdot \left(y \cdot \left(z \cdot z\right)\right)}
\] |
distribute-lft-neg-out [=>]76.4 | \[ \frac{-1}{\color{blue}{-x \cdot \left(y \cdot \left(z \cdot z\right)\right)}}
\] |
*-commutative [=>]76.4 | \[ \frac{-1}{-\color{blue}{\left(y \cdot \left(z \cdot z\right)\right) \cdot x}}
\] |
associate-*r* [=>]88.7 | \[ \frac{-1}{-\color{blue}{\left(\left(y \cdot z\right) \cdot z\right)} \cdot x}
\] |
*-commutative [<=]88.7 | \[ \frac{-1}{-\left(\color{blue}{\left(z \cdot y\right)} \cdot z\right) \cdot x}
\] |
associate-*l* [=>]96.3 | \[ \frac{-1}{-\color{blue}{\left(z \cdot y\right) \cdot \left(z \cdot x\right)}}
\] |
*-commutative [<=]96.3 | \[ \frac{-1}{-\left(z \cdot y\right) \cdot \color{blue}{\left(x \cdot z\right)}}
\] |
distribute-rgt-neg-in [=>]96.3 | \[ \frac{-1}{\color{blue}{\left(z \cdot y\right) \cdot \left(-x \cdot z\right)}}
\] |
*-commutative [=>]96.3 | \[ \frac{-1}{\color{blue}{\left(y \cdot z\right)} \cdot \left(-x \cdot z\right)}
\] |
*-commutative [=>]96.3 | \[ \frac{-1}{\left(y \cdot z\right) \cdot \left(-\color{blue}{z \cdot x}\right)}
\] |
Final simplification97.4%
| Alternative 1 | |
|---|---|
| Accuracy | 97.1% |
| Cost | 13504 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 1736 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 1220 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.3% |
| Cost | 969 |
| Alternative 5 | |
|---|---|
| Accuracy | 97.2% |
| Cost | 968 |
| Alternative 6 | |
|---|---|
| Accuracy | 96.8% |
| Cost | 841 |
| Alternative 7 | |
|---|---|
| Accuracy | 96.2% |
| Cost | 836 |
| Alternative 8 | |
|---|---|
| Accuracy | 54.9% |
| Cost | 320 |
| Alternative 9 | |
|---|---|
| Accuracy | 54.9% |
| Cost | 320 |
herbie shell --seed 2023138
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< (* y (+ 1.0 (* z z))) (- INFINITY)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x)) (if (< (* y (+ 1.0 (* z z))) 8.680743250567252e+305) (/ (/ 1.0 x) (* (+ 1.0 (* z z)) y)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x))))
(/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))