(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x (* y (- z x))) z)))
(if (<= t_0 (- INFINITY))
(- y (* x (/ y z)))
(if (<= t_0 -7.589173101786719e+48)
(/ (fma y (- z x) x) z)
(if (<= t_0 1.1372358904094027e+307)
(- (+ y (/ x z)) (/ (* x y) z))
(- y (* y (/ x z))))))))double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = y - (x * (y / z));
} else if (t_0 <= -7.589173101786719e+48) {
tmp = fma(y, (z - x), x) / z;
} else if (t_0 <= 1.1372358904094027e+307) {
tmp = (y + (x / z)) - ((x * y) / z);
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function code(x, y, z) t_0 = Float64(Float64(x + Float64(y * Float64(z - x))) / z) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(y - Float64(x * Float64(y / z))); elseif (t_0 <= -7.589173101786719e+48) tmp = Float64(fma(y, Float64(z - x), x) / z); elseif (t_0 <= 1.1372358904094027e+307) tmp = Float64(Float64(y + Float64(x / z)) - Float64(Float64(x * y) / z)); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(y - N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -7.589173101786719e+48], N[(N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$0, 1.1372358904094027e+307], N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\frac{x + y \cdot \left(z - x\right)}{z}
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;y - x \cdot \frac{y}{z}\\
\mathbf{elif}\;t_0 \leq -7.589173101786719 \cdot 10^{+48}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\
\mathbf{elif}\;t_0 \leq 1.1372358904094027 \cdot 10^{+307}:\\
\;\;\;\;\left(y + \frac{x}{z}\right) - \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.1 |
if (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -inf.0Initial program 64.0
Simplified64.0
Taylor expanded in y around inf 64.0
Simplified0.1
Applied div-inv_binary640.1
Applied associate-*l*_binary640.1
Simplified0.1
if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -7.58917310178671929e48Initial program 0.1
Simplified0.1
if -7.58917310178671929e48 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 1.1372358904094027e307Initial program 0.1
Simplified0.1
Taylor expanded in y around 0 0.0
if 1.1372358904094027e307 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) Initial program 63.3
Simplified63.3
Taylor expanded in y around inf 63.6
Simplified0.4
Final simplification0.1
herbie shell --seed 2022131
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:herbie-target
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))