(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (/ (* x z) y))) (t_1 (/ (* x (- y z)) y)))
(if (<= t_1 (- INFINITY))
(- x (* z (/ x y)))
(if (<= t_1 -4e-76)
t_0
(if (<= t_1 0.0)
(- x (/ z (/ y x)))
(if (<= t_1 5e+298) t_0 (+ x (* z (/ 1.0 (/ (- y) x))))))))))double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
double t_0 = x - ((x * z) / y);
double t_1 = (x * (y - z)) / y;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x - (z * (x / y));
} else if (t_1 <= -4e-76) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = x - (z / (y / x));
} else if (t_1 <= 5e+298) {
tmp = t_0;
} else {
tmp = x + (z * (1.0 / (-y / x)));
}
return tmp;
}
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
double t_0 = x - ((x * z) / y);
double t_1 = (x * (y - z)) / y;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x - (z * (x / y));
} else if (t_1 <= -4e-76) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = x - (z / (y / x));
} else if (t_1 <= 5e+298) {
tmp = t_0;
} else {
tmp = x + (z * (1.0 / (-y / x)));
}
return tmp;
}
def code(x, y, z): return (x * (y - z)) / y
def code(x, y, z): t_0 = x - ((x * z) / y) t_1 = (x * (y - z)) / y tmp = 0 if t_1 <= -math.inf: tmp = x - (z * (x / y)) elif t_1 <= -4e-76: tmp = t_0 elif t_1 <= 0.0: tmp = x - (z / (y / x)) elif t_1 <= 5e+298: tmp = t_0 else: tmp = x + (z * (1.0 / (-y / x))) return tmp
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function code(x, y, z) t_0 = Float64(x - Float64(Float64(x * z) / y)) t_1 = Float64(Float64(x * Float64(y - z)) / y) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x - Float64(z * Float64(x / y))); elseif (t_1 <= -4e-76) tmp = t_0; elseif (t_1 <= 0.0) tmp = Float64(x - Float64(z / Float64(y / x))); elseif (t_1 <= 5e+298) tmp = t_0; else tmp = Float64(x + Float64(z * Float64(1.0 / Float64(Float64(-y) / x)))); end return tmp end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
function tmp_2 = code(x, y, z) t_0 = x - ((x * z) / y); t_1 = (x * (y - z)) / y; tmp = 0.0; if (t_1 <= -Inf) tmp = x - (z * (x / y)); elseif (t_1 <= -4e-76) tmp = t_0; elseif (t_1 <= 0.0) tmp = x - (z / (y / x)); elseif (t_1 <= 5e+298) tmp = t_0; else tmp = x + (z * (1.0 / (-y / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -4e-76], t$95$0, If[LessEqual[t$95$1, 0.0], N[(x - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+298], t$95$0, N[(x + N[(z * N[(1.0 / N[((-y) / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := x - \frac{x \cdot z}{y}\\
t_1 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x - z \cdot \frac{x}{y}\\
\mathbf{elif}\;t_1 \leq -4 \cdot 10^{-76}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;x - \frac{z}{\frac{y}{x}}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+298}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{1}{\frac{-y}{x}}\\
\end{array}
Results
| Original | 12.6 |
|---|---|
| Target | 3.3 |
| Herbie | 1.1 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0Initial program 64.0
Simplified0.0
Applied egg-rr0.0
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -3.99999999999999971e-76 or 0.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < 5.0000000000000003e298Initial program 0.3
Simplified5.5
Taylor expanded in z around 0 0.2
if -3.99999999999999971e-76 < (/.f64 (*.f64 x (-.f64 y z)) y) < 0.0Initial program 15.5
Simplified4.5
if 5.0000000000000003e298 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 60.8
Simplified1.7
Applied egg-rr2.0
Final simplification1.1
herbie shell --seed 2022185
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))