(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z) :precision binary64 (fma x (/ (- 1.0 y) z) y))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
return fma(x, ((1.0 - y) / z), y);
}
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function code(x, y, z) return fma(x, Float64(Float64(1.0 - y) / z), y) end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision] + y), $MachinePrecision]
\frac{x + y \cdot \left(z - x\right)}{z}
\mathsf{fma}\left(x, \frac{1 - y}{z}, y\right)




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.2 |
|---|---|
| Target | 0.0 |
| Herbie | 3.3 |
Initial program 10.2
Simplified10.2
Taylor expanded in y around 0 3.4
Simplified3.3
Applied egg-rr3.3
Applied egg-rr3.3
Applied egg-rr3.3
Final simplification3.3
herbie shell --seed 2022162
(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))