(FPCore (x y z) :precision binary64 (/ (* x y) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x y) z)) (t_1 (/ y (/ z x))))
(if (<= (* x y) (- INFINITY))
t_1
(if (<= (* x y) -1.6601695723168201e-80)
t_0
(if (<= (* x y) 3.6864798105561816e-255)
(* y (/ x z))
(if (<= (* x y) 8.68692735132234e+172) t_0 t_1))))))double code(double x, double y, double z) {
return (x * y) / z;
}
double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double t_1 = y / (z / x);
double tmp;
if ((x * y) <= -((double) INFINITY)) {
tmp = t_1;
} else if ((x * y) <= -1.6601695723168201e-80) {
tmp = t_0;
} else if ((x * y) <= 3.6864798105561816e-255) {
tmp = y * (x / z);
} else if ((x * y) <= 8.68692735132234e+172) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z) {
return (x * y) / z;
}
public static double code(double x, double y, double z) {
double t_0 = (x * y) / z;
double t_1 = y / (z / x);
double tmp;
if ((x * y) <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if ((x * y) <= -1.6601695723168201e-80) {
tmp = t_0;
} else if ((x * y) <= 3.6864798105561816e-255) {
tmp = y * (x / z);
} else if ((x * y) <= 8.68692735132234e+172) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): return (x * y) / z
def code(x, y, z): t_0 = (x * y) / z t_1 = y / (z / x) tmp = 0 if (x * y) <= -math.inf: tmp = t_1 elif (x * y) <= -1.6601695723168201e-80: tmp = t_0 elif (x * y) <= 3.6864798105561816e-255: tmp = y * (x / z) elif (x * y) <= 8.68692735132234e+172: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) return Float64(Float64(x * y) / z) end
function code(x, y, z) t_0 = Float64(Float64(x * y) / z) t_1 = Float64(y / Float64(z / x)) tmp = 0.0 if (Float64(x * y) <= Float64(-Inf)) tmp = t_1; elseif (Float64(x * y) <= -1.6601695723168201e-80) tmp = t_0; elseif (Float64(x * y) <= 3.6864798105561816e-255) tmp = Float64(y * Float64(x / z)); elseif (Float64(x * y) <= 8.68692735132234e+172) tmp = t_0; else tmp = t_1; end return tmp end
function tmp = code(x, y, z) tmp = (x * y) / z; end
function tmp_2 = code(x, y, z) t_0 = (x * y) / z; t_1 = y / (z / x); tmp = 0.0; if ((x * y) <= -Inf) tmp = t_1; elseif ((x * y) <= -1.6601695723168201e-80) tmp = t_0; elseif ((x * y) <= 3.6864798105561816e-255) tmp = y * (x / z); elseif ((x * y) <= 8.68692735132234e+172) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -1.6601695723168201e-80], t$95$0, If[LessEqual[N[(x * y), $MachinePrecision], 3.6864798105561816e-255], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 8.68692735132234e+172], t$95$0, t$95$1]]]]]]
\frac{x \cdot y}{z}
\begin{array}{l}
t_0 := \frac{x \cdot y}{z}\\
t_1 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;x \cdot y \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot y \leq -1.6601695723168201 \cdot 10^{-80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \cdot y \leq 3.6864798105561816 \cdot 10^{-255}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;x \cdot y \leq 8.68692735132234 \cdot 10^{+172}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 6.1 |
|---|---|
| Target | 6.4 |
| Herbie | 0.9 |
if (*.f64 x y) < -inf.0 or 8.68692735132233945e172 < (*.f64 x y) Initial program 32.5
Applied add-cube-cbrt_binary6433.1
Applied associate-/r*_binary6433.1
Simplified9.2
Applied associate-/l*_binary642.6
Simplified1.6
if -inf.0 < (*.f64 x y) < -1.6601695723168201e-80 or 3.6864798105561816e-255 < (*.f64 x y) < 8.68692735132233945e172Initial program 0.2
Applied add-cube-cbrt_binary641.3
Applied associate-/r*_binary641.3
Simplified6.6
Applied *-un-lft-identity_binary646.6
Applied cbrt-prod_binary646.6
Applied times-frac_binary6410.4
Simplified10.4
Simplified9.6
Taylor expanded in y around 0 0.2
if -1.6601695723168201e-80 < (*.f64 x y) < 3.6864798105561816e-255Initial program 8.3
Applied add-cube-cbrt_binary648.7
Applied associate-/r*_binary648.7
Simplified3.0
Applied *-un-lft-identity_binary643.0
Applied cbrt-prod_binary643.0
Applied times-frac_binary642.5
Simplified2.5
Simplified1.8
Final simplification0.9
herbie shell --seed 2022129
(FPCore (x y z)
:name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, A"
:precision binary64
:herbie-target
(if (< z -4.262230790519429e-138) (/ (* x y) z) (if (< z 1.7042130660650472e-164) (/ x (/ z y)) (* (/ x z) y)))
(/ (* x y) z))