(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z) :precision binary64 (+ (/ y (/ z x)) (- (/ x z) x)))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
double code(double x, double y, double z) {
return (y / (z / x)) + ((x / z) - x);
}
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) + 1.0d0)) / z
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y / (z / x)) + ((x / z) - x)
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
public static double code(double x, double y, double z) {
return (y / (z / x)) + ((x / z) - x);
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
def code(x, y, z): return (y / (z / x)) + ((x / z) - x)
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function code(x, y, z) return Float64(Float64(y / Float64(z / x)) + Float64(Float64(x / z) - x)) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
function tmp = code(x, y, z) tmp = (y / (z / x)) + ((x / z) - x); end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] + N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\frac{y}{\frac{z}{x}} + \left(\frac{x}{z} - x\right)




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 9.7 |
|---|---|
| Target | 0.5 |
| Herbie | 1.6 |
Initial program 9.7
Simplified3.4
Taylor expanded in x around 0 3.5
Applied egg-rr3.5
Applied egg-rr1.7
Taylor expanded in z around 0 1.6
Final simplification1.6
herbie shell --seed 2022165
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))