(FPCore (x y) :precision binary64 (/ (* (* x 2.0) y) (- x y)))
(FPCore (x y) :precision binary64 (/ 1.0 (+ (/ -0.5 x) (/ 0.5 y))))
double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
double code(double x, double y) {
return 1.0 / ((-0.5 / x) + (0.5 / y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / (((-0.5d0) / x) + (0.5d0 / y))
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
public static double code(double x, double y) {
return 1.0 / ((-0.5 / x) + (0.5 / y));
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
def code(x, y): return 1.0 / ((-0.5 / x) + (0.5 / y))
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function code(x, y) return Float64(1.0 / Float64(Float64(-0.5 / x) + Float64(0.5 / y))) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
function tmp = code(x, y) tmp = 1.0 / ((-0.5 / x) + (0.5 / y)); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(1.0 / N[(N[(-0.5 / x), $MachinePrecision] + N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\frac{1}{\frac{-0.5}{x} + \frac{0.5}{y}}




Bits error versus x




Bits error versus y
Results
| Original | 15.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
Initial program 15.7
Simplified7.4
Applied clear-num_binary647.6
Taylor expanded in x around 0 0.2
Simplified0.2
Final simplification0.2
herbie shell --seed 2022130
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
:herbie-target
(if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 83645045635564430.0) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))
(/ (* (* x 2.0) y) (- x y)))