(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (- y z)) y)))
(if (<= t_0 (- INFINITY))
(- x (/ z (/ y x)))
(if (<= t_0 -1e+124) (- x (/ (* x z) y)) (- x (* x (/ z y)))))))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 * (y - z)) / y;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x - (z / (y / x));
} else if (t_0 <= -1e+124) {
tmp = x - ((x * z) / y);
} else {
tmp = x - (x * (z / y));
}
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 * (y - z)) / y;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x - (z / (y / x));
} else if (t_0 <= -1e+124) {
tmp = x - ((x * z) / y);
} else {
tmp = x - (x * (z / y));
}
return tmp;
}
def code(x, y, z): return (x * (y - z)) / y
def code(x, y, z): t_0 = (x * (y - z)) / y tmp = 0 if t_0 <= -math.inf: tmp = x - (z / (y / x)) elif t_0 <= -1e+124: tmp = x - ((x * z) / y) else: tmp = x - (x * (z / y)) return tmp
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function code(x, y, z) t_0 = Float64(Float64(x * Float64(y - z)) / y) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x - Float64(z / Float64(y / x))); elseif (t_0 <= -1e+124) tmp = Float64(x - Float64(Float64(x * z) / y)); else tmp = Float64(x - Float64(x * Float64(z / y))); 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 * (y - z)) / y; tmp = 0.0; if (t_0 <= -Inf) tmp = x - (z / (y / x)); elseif (t_0 <= -1e+124) tmp = x - ((x * z) / y); else tmp = x - (x * (z / y)); 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[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -1e+124], N[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x - \frac{z}{\frac{y}{x}}\\
\mathbf{elif}\;t_0 \leq -1 \cdot 10^{+124}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \frac{z}{y}\\
\end{array}
Results
| Original | 12.8 |
|---|---|
| Target | 3.2 |
| Herbie | 2.1 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -inf.0Initial program 64.0
Simplified0.0
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) y) < -9.99999999999999948e123Initial program 0.2
Simplified12.3
Taylor expanded in z around 0 0.2
if -9.99999999999999948e123 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 9.4
Simplified4.0
Applied egg-rr2.6
Final simplification2.1
herbie shell --seed 2022210
(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))