(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 -5e+129)
(+ x (* (/ z (/ 1.0 x)) (/ -1.0 y)))
(if (<= t_0 2e-121)
(* x (- 1.0 (/ z y)))
(if (<= t_0 2e+277) (- x (/ (* x z) y)) (- x (/ x (/ y z))))))))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 <= -5e+129) {
tmp = x + ((z / (1.0 / x)) * (-1.0 / y));
} else if (t_0 <= 2e-121) {
tmp = x * (1.0 - (z / y));
} else if (t_0 <= 2e+277) {
tmp = x - ((x * z) / y);
} else {
tmp = x - (x / (y / z));
}
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 = (x * (y - z)) / y
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) :: t_0
real(8) :: tmp
t_0 = (x * (y - z)) / y
if (t_0 <= (-5d+129)) then
tmp = x + ((z / (1.0d0 / x)) * ((-1.0d0) / y))
else if (t_0 <= 2d-121) then
tmp = x * (1.0d0 - (z / y))
else if (t_0 <= 2d+277) then
tmp = x - ((x * z) / y)
else
tmp = x - (x / (y / z))
end if
code = tmp
end function
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 <= -5e+129) {
tmp = x + ((z / (1.0 / x)) * (-1.0 / y));
} else if (t_0 <= 2e-121) {
tmp = x * (1.0 - (z / y));
} else if (t_0 <= 2e+277) {
tmp = x - ((x * z) / y);
} else {
tmp = x - (x / (y / z));
}
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 <= -5e+129: tmp = x + ((z / (1.0 / x)) * (-1.0 / y)) elif t_0 <= 2e-121: tmp = x * (1.0 - (z / y)) elif t_0 <= 2e+277: tmp = x - ((x * z) / y) else: tmp = x - (x / (y / z)) 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 <= -5e+129) tmp = Float64(x + Float64(Float64(z / Float64(1.0 / x)) * Float64(-1.0 / y))); elseif (t_0 <= 2e-121) tmp = Float64(x * Float64(1.0 - Float64(z / y))); elseif (t_0 <= 2e+277) tmp = Float64(x - Float64(Float64(x * z) / y)); else tmp = Float64(x - Float64(x / Float64(y / z))); 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 <= -5e+129) tmp = x + ((z / (1.0 / x)) * (-1.0 / y)); elseif (t_0 <= 2e-121) tmp = x * (1.0 - (z / y)); elseif (t_0 <= 2e+277) tmp = x - ((x * z) / y); else tmp = x - (x / (y / z)); 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, -5e+129], N[(x + N[(N[(z / N[(1.0 / x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-121], N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+277], N[(x - N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / N[(y / z), $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 -5 \cdot 10^{+129}:\\
\;\;\;\;x + \frac{z}{\frac{1}{x}} \cdot \frac{-1}{y}\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-121}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+277}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{y}{z}}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.3 |
|---|---|
| Target | 3.3 |
| Herbie | 2.2 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < -5.0000000000000003e129Initial program 24.6
Simplified8.0
Applied egg-rr8.7
if -5.0000000000000003e129 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2e-121Initial program 6.5
Simplified2.9
Taylor expanded in x around 0 0.7
if 2e-121 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2.00000000000000001e277Initial program 0.3
Simplified4.7
Taylor expanded in z around 0 0.2
if 2.00000000000000001e277 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 53.7
Simplified3.7
Applied egg-rr3.6
Taylor expanded in z around 0 19.0
Simplified3.1
Final simplification2.2
herbie shell --seed 2022162
(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))