| Alternative 1 | |
|---|---|
| Accuracy | 97.0% |
| Cost | 13504 |
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
(FPCore (x y z) :precision binary64 (if (<= (* y (+ 1.0 (* z z))) 4e+304) (/ 1.0 (* x (+ y (* z (* z y))))) (/ (/ 1.0 (* z x)) (* z y))))
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 ((y * (1.0 + (z * z))) <= 4e+304) {
tmp = 1.0 / (x * (y + (z * (z * y))));
} else {
tmp = (1.0 / (z * x)) / (z * y);
}
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 ((y * (1.0d0 + (z * z))) <= 4d+304) then
tmp = 1.0d0 / (x * (y + (z * (z * y))))
else
tmp = (1.0d0 / (z * x)) / (z * y)
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 ((y * (1.0 + (z * z))) <= 4e+304) {
tmp = 1.0 / (x * (y + (z * (z * y))));
} else {
tmp = (1.0 / (z * x)) / (z * y);
}
return tmp;
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
def code(x, y, z): tmp = 0 if (y * (1.0 + (z * z))) <= 4e+304: tmp = 1.0 / (x * (y + (z * (z * y)))) else: tmp = (1.0 / (z * x)) / (z * y) 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 (Float64(y * Float64(1.0 + Float64(z * z))) <= 4e+304) tmp = Float64(1.0 / Float64(x * Float64(y + Float64(z * Float64(z * y))))); else tmp = Float64(Float64(1.0 / Float64(z * x)) / Float64(z * y)); 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 ((y * (1.0 + (z * z))) <= 4e+304) tmp = 1.0 / (x * (y + (z * (z * y)))); else tmp = (1.0 / (z * x)) / (z * y); 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[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4e+304], N[(1.0 / N[(x * N[(y + N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(z * x), $MachinePrecision]), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision]]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 4 \cdot 10^{+304}:\\
\;\;\;\;\frac{1}{x \cdot \left(y + z \cdot \left(z \cdot y\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z \cdot x}}{z \cdot y}\\
\end{array}
Results
| Original | 90.0% |
|---|---|
| Target | 92.2% |
| Herbie | 97.3% |
if (*.f64 y (+.f64 1 (*.f64 z z))) < 3.9999999999999998e304Initial program 97.1%
Applied egg-rr54.3%
[Start]97.1 | \[ \frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\] |
|---|---|
distribute-rgt-in [=>]97.1 | \[ \frac{\frac{1}{x}}{\color{blue}{1 \cdot y + \left(z \cdot z\right) \cdot y}}
\] |
*-un-lft-identity [<=]97.1 | \[ \frac{\frac{1}{x}}{\color{blue}{y} + \left(z \cdot z\right) \cdot y}
\] |
flip-+ [=>]58.7 | \[ \frac{\frac{1}{x}}{\color{blue}{\frac{y \cdot y - \left(\left(z \cdot z\right) \cdot y\right) \cdot \left(\left(z \cdot z\right) \cdot y\right)}{y - \left(z \cdot z\right) \cdot y}}}
\] |
associate-/r/ [=>]52.1 | \[ \color{blue}{\frac{\frac{1}{x}}{y \cdot y - \left(\left(z \cdot z\right) \cdot y\right) \cdot \left(\left(z \cdot z\right) \cdot y\right)} \cdot \left(y - \left(z \cdot z\right) \cdot y\right)}
\] |
inv-pow [=>]52.1 | \[ \frac{\color{blue}{{x}^{-1}}}{y \cdot y - \left(\left(z \cdot z\right) \cdot y\right) \cdot \left(\left(z \cdot z\right) \cdot y\right)} \cdot \left(y - \left(z \cdot z\right) \cdot y\right)
\] |
associate-*l* [=>]52.1 | \[ \frac{{x}^{-1}}{y \cdot y - \color{blue}{\left(z \cdot \left(z \cdot y\right)\right)} \cdot \left(\left(z \cdot z\right) \cdot y\right)} \cdot \left(y - \left(z \cdot z\right) \cdot y\right)
\] |
associate-*l* [=>]52.1 | \[ \frac{{x}^{-1}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \color{blue}{\left(z \cdot \left(z \cdot y\right)\right)}} \cdot \left(y - \left(z \cdot z\right) \cdot y\right)
\] |
associate-*l* [=>]54.3 | \[ \frac{{x}^{-1}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)} \cdot \left(y - \color{blue}{z \cdot \left(z \cdot y\right)}\right)
\] |
Simplified48.8%
[Start]54.3 | \[ \frac{{x}^{-1}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)} \cdot \left(y - z \cdot \left(z \cdot y\right)\right)
\] |
|---|---|
associate-*l/ [=>]54.8 | \[ \color{blue}{\frac{{x}^{-1} \cdot \left(y - z \cdot \left(z \cdot y\right)\right)}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}}
\] |
unpow-1 [=>]54.8 | \[ \frac{\color{blue}{\frac{1}{x}} \cdot \left(y - z \cdot \left(z \cdot y\right)\right)}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
associate-*l/ [=>]54.9 | \[ \frac{\color{blue}{\frac{1 \cdot \left(y - z \cdot \left(z \cdot y\right)\right)}{x}}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
sub-neg [=>]54.9 | \[ \frac{\frac{1 \cdot \color{blue}{\left(y + \left(-z \cdot \left(z \cdot y\right)\right)\right)}}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
distribute-lft-in [=>]54.9 | \[ \frac{\frac{\color{blue}{1 \cdot y + 1 \cdot \left(-z \cdot \left(z \cdot y\right)\right)}}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
*-lft-identity [=>]54.9 | \[ \frac{\frac{\color{blue}{y} + 1 \cdot \left(-z \cdot \left(z \cdot y\right)\right)}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
*-commutative [<=]54.9 | \[ \frac{\frac{y + \color{blue}{\left(-z \cdot \left(z \cdot y\right)\right) \cdot 1}}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
cancel-sign-sub-inv [<=]54.9 | \[ \frac{\frac{\color{blue}{y - \left(z \cdot \left(z \cdot y\right)\right) \cdot 1}}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
*-rgt-identity [=>]54.9 | \[ \frac{\frac{y - \color{blue}{z \cdot \left(z \cdot y\right)}}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(z \cdot \left(z \cdot y\right)\right)}
\] |
associate-*r* [=>]54.1 | \[ \frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \color{blue}{\left(\left(z \cdot z\right) \cdot y\right)}}
\] |
unpow2 [<=]54.1 | \[ \frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \left(z \cdot \left(z \cdot y\right)\right) \cdot \left(\color{blue}{{z}^{2}} \cdot y\right)}
\] |
associate-*r* [=>]52.7 | \[ \frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \color{blue}{\left(\left(z \cdot \left(z \cdot y\right)\right) \cdot {z}^{2}\right) \cdot y}}
\] |
Applied egg-rr41.9%
[Start]48.8 | \[ \frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \left(y \cdot {z}^{4}\right) \cdot y}
\] |
|---|---|
expm1-log1p-u [=>]39.3 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \left(y \cdot {z}^{4}\right) \cdot y}\right)\right)}
\] |
expm1-udef [=>]23.5 | \[ \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{y - z \cdot \left(z \cdot y\right)}{x}}{y \cdot y - \left(y \cdot {z}^{4}\right) \cdot y}\right)} - 1}
\] |
Simplified98.5%
[Start]41.9 | \[ e^{\mathsf{log1p}\left(\frac{1}{\left(y + z \cdot \left(y \cdot z\right)\right) \cdot x}\right)} - 1
\] |
|---|---|
expm1-def [=>]79.1 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\left(y + z \cdot \left(y \cdot z\right)\right) \cdot x}\right)\right)}
\] |
expm1-log1p [=>]98.5 | \[ \color{blue}{\frac{1}{\left(y + z \cdot \left(y \cdot z\right)\right) \cdot x}}
\] |
*-commutative [=>]98.5 | \[ \frac{1}{\color{blue}{x \cdot \left(y + z \cdot \left(y \cdot z\right)\right)}}
\] |
*-commutative [=>]98.5 | \[ \frac{1}{x \cdot \left(y + z \cdot \color{blue}{\left(z \cdot y\right)}\right)}
\] |
if 3.9999999999999998e304 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 71.5%
Simplified79.1%
[Start]71.5 | \[ \frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\] |
|---|---|
associate-/r* [=>]79.1 | \[ \color{blue}{\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}}
\] |
Taylor expanded in z around inf 77.9%
Simplified91.6%
[Start]77.9 | \[ \frac{1}{y \cdot \left({z}^{2} \cdot x\right)}
\] |
|---|---|
associate-/r* [=>]78.1 | \[ \color{blue}{\frac{\frac{1}{y}}{{z}^{2} \cdot x}}
\] |
unpow2 [=>]78.1 | \[ \frac{\frac{1}{y}}{\color{blue}{\left(z \cdot z\right)} \cdot x}
\] |
associate-*l* [=>]91.6 | \[ \frac{\frac{1}{y}}{\color{blue}{z \cdot \left(z \cdot x\right)}}
\] |
Applied egg-rr94.0%
[Start]91.6 | \[ \frac{\frac{1}{y}}{z \cdot \left(z \cdot x\right)}
\] |
|---|---|
*-un-lft-identity [=>]91.6 | \[ \frac{\color{blue}{1 \cdot \frac{1}{y}}}{z \cdot \left(z \cdot x\right)}
\] |
*-commutative [=>]91.6 | \[ \frac{1 \cdot \frac{1}{y}}{\color{blue}{\left(z \cdot x\right) \cdot z}}
\] |
times-frac [=>]94.7 | \[ \color{blue}{\frac{1}{z \cdot x} \cdot \frac{\frac{1}{y}}{z}}
\] |
associate-/l/ [=>]94.0 | \[ \frac{1}{z \cdot x} \cdot \color{blue}{\frac{1}{z \cdot y}}
\] |
*-commutative [=>]94.0 | \[ \frac{1}{z \cdot x} \cdot \frac{1}{\color{blue}{y \cdot z}}
\] |
Applied egg-rr94.0%
[Start]94.0 | \[ \frac{1}{z \cdot x} \cdot \frac{1}{y \cdot z}
\] |
|---|---|
un-div-inv [=>]94.0 | \[ \color{blue}{\frac{\frac{1}{z \cdot x}}{y \cdot z}}
\] |
*-commutative [=>]94.0 | \[ \frac{\frac{1}{z \cdot x}}{\color{blue}{z \cdot y}}
\] |
Final simplification97.3%
| Alternative 1 | |
|---|---|
| Accuracy | 97.0% |
| Cost | 13504 |
| Alternative 2 | |
|---|---|
| Accuracy | 93.5% |
| Cost | 841 |
| Alternative 3 | |
|---|---|
| Accuracy | 96.3% |
| Cost | 841 |
| Alternative 4 | |
|---|---|
| Accuracy | 96.5% |
| Cost | 841 |
| Alternative 5 | |
|---|---|
| Accuracy | 93.4% |
| Cost | 836 |
| Alternative 6 | |
|---|---|
| Accuracy | 54.5% |
| Cost | 320 |
herbie shell --seed 2023135
(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)))))