(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
:precision binary64
(if (<= (/ y z) (- INFINITY))
(pow (/ z (* y x)) -1.0)
(if (<= (/ y z) -1e-153)
(* (/ y z) x)
(if (<= (/ y z) 2e-258)
(/ y (/ z x))
(if (<= (/ y z) 2e+261) (/ x (/ z y)) (* y (/ x z)))))))double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
double tmp;
if ((y / z) <= -((double) INFINITY)) {
tmp = pow((z / (y * x)), -1.0);
} else if ((y / z) <= -1e-153) {
tmp = (y / z) * x;
} else if ((y / z) <= 2e-258) {
tmp = y / (z / x);
} else if ((y / z) <= 2e+261) {
tmp = x / (z / y);
} else {
tmp = y * (x / z);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y / z) <= -Double.POSITIVE_INFINITY) {
tmp = Math.pow((z / (y * x)), -1.0);
} else if ((y / z) <= -1e-153) {
tmp = (y / z) * x;
} else if ((y / z) <= 2e-258) {
tmp = y / (z / x);
} else if ((y / z) <= 2e+261) {
tmp = x / (z / y);
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
def code(x, y, z, t): tmp = 0 if (y / z) <= -math.inf: tmp = math.pow((z / (y * x)), -1.0) elif (y / z) <= -1e-153: tmp = (y / z) * x elif (y / z) <= 2e-258: tmp = y / (z / x) elif (y / z) <= 2e+261: tmp = x / (z / y) else: tmp = y * (x / z) return tmp
function code(x, y, z, t) return Float64(x * Float64(Float64(Float64(y / z) * t) / t)) end
function code(x, y, z, t) tmp = 0.0 if (Float64(y / z) <= Float64(-Inf)) tmp = Float64(z / Float64(y * x)) ^ -1.0; elseif (Float64(y / z) <= -1e-153) tmp = Float64(Float64(y / z) * x); elseif (Float64(y / z) <= 2e-258) tmp = Float64(y / Float64(z / x)); elseif (Float64(y / z) <= 2e+261) tmp = Float64(x / Float64(z / y)); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp = code(x, y, z, t) tmp = x * (((y / z) * t) / t); end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y / z) <= -Inf) tmp = (z / (y * x)) ^ -1.0; elseif ((y / z) <= -1e-153) tmp = (y / z) * x; elseif ((y / z) <= 2e-258) tmp = y / (z / x); elseif ((y / z) <= 2e+261) tmp = x / (z / y); else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := If[LessEqual[N[(y / z), $MachinePrecision], (-Infinity)], N[Power[N[(z / N[(y * x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], -1e-153], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 2e-258], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 2e+261], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -\infty:\\
\;\;\;\;{\left(\frac{z}{y \cdot x}\right)}^{-1}\\
\mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-153}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{-258}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{+261}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
Results
| Original | 14.5 |
|---|---|
| Target | 1.6 |
| Herbie | 0.4 |
if (/.f64 y z) < -inf.0Initial program 64.0
Simplified59.2
Applied egg-rr0.3
if -inf.0 < (/.f64 y z) < -1.00000000000000004e-153Initial program 9.9
Simplified0.3
Taylor expanded in x around 0 9.3
Simplified9.4
Applied egg-rr9.6
Applied egg-rr0.3
if -1.00000000000000004e-153 < (/.f64 y z) < 1.99999999999999991e-258Initial program 16.0
Simplified10.9
Taylor expanded in x around 0 0.9
Simplified0.8
Applied egg-rr0.9
if 1.99999999999999991e-258 < (/.f64 y z) < 1.9999999999999999e261Initial program 9.7
Simplified0.2
if 1.9999999999999999e261 < (/.f64 y z) Initial program 54.9
Simplified42.0
Taylor expanded in x around 0 0.5
Simplified0.3
Final simplification0.4
herbie shell --seed 2022192
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
:precision binary64
:herbie-target
(if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))
(* x (/ (* (/ y z) t) t)))