(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* x 2.0) (- (* y z) (* z t)))))
(if (<= t_1 -5e+95)
(* (/ -2.0 z) (/ x (- t y)))
(if (<= t_1 0.0)
(* 2.0 (/ (/ x z) (- y t)))
(/ (* x -2.0) (* z (- t y)))))))double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
double code(double x, double y, double z, double t) {
double t_1 = (x * 2.0) / ((y * z) - (z * t));
double tmp;
if (t_1 <= -5e+95) {
tmp = (-2.0 / z) * (x / (t - y));
} else if (t_1 <= 0.0) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (x * -2.0) / (z * (t - y));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * 2.0d0) / ((y * z) - (t * z))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x * 2.0d0) / ((y * z) - (z * t))
if (t_1 <= (-5d+95)) then
tmp = ((-2.0d0) / z) * (x / (t - y))
else if (t_1 <= 0.0d0) then
tmp = 2.0d0 * ((x / z) / (y - t))
else
tmp = (x * (-2.0d0)) / (z * (t - y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x * 2.0) / ((y * z) - (z * t));
double tmp;
if (t_1 <= -5e+95) {
tmp = (-2.0 / z) * (x / (t - y));
} else if (t_1 <= 0.0) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (x * -2.0) / (z * (t - y));
}
return tmp;
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
def code(x, y, z, t): t_1 = (x * 2.0) / ((y * z) - (z * t)) tmp = 0 if t_1 <= -5e+95: tmp = (-2.0 / z) * (x / (t - y)) elif t_1 <= 0.0: tmp = 2.0 * ((x / z) / (y - t)) else: tmp = (x * -2.0) / (z * (t - y)) return tmp
function code(x, y, z, t) return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) end
function code(x, y, z, t) t_1 = Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(z * t))) tmp = 0.0 if (t_1 <= -5e+95) tmp = Float64(Float64(-2.0 / z) * Float64(x / Float64(t - y))); elseif (t_1 <= 0.0) tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); else tmp = Float64(Float64(x * -2.0) / Float64(z * Float64(t - y))); end return tmp end
function tmp = code(x, y, z, t) tmp = (x * 2.0) / ((y * z) - (t * z)); end
function tmp_2 = code(x, y, z, t) t_1 = (x * 2.0) / ((y * z) - (z * t)); tmp = 0.0; if (t_1 <= -5e+95) tmp = (-2.0 / z) * (x / (t - y)); elseif (t_1 <= 0.0) tmp = 2.0 * ((x / z) / (y - t)); else tmp = (x * -2.0) / (z * (t - y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+95], N[(N[(-2.0 / z), $MachinePrecision] * N[(x / N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * -2.0), $MachinePrecision] / N[(z * N[(t - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := \frac{x \cdot 2}{y \cdot z - z \cdot t}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+95}:\\
\;\;\;\;\frac{-2}{z} \cdot \frac{x}{t - y}\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot -2}{z \cdot \left(t - y\right)}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 7.0 |
|---|---|
| Target | 2.1 |
| Herbie | 2.3 |
if (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -5.00000000000000025e95Initial program 5.0
Taylor expanded in z around -inf 4.9
Simplified5.9
if -5.00000000000000025e95 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -0.0Initial program 8.2
Simplified1.5
if -0.0 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) Initial program 5.7
Applied egg-rr8.7
Taylor expanded in x around -inf 5.7
Simplified2.5
Final simplification2.3
herbie shell --seed 2022166
(FPCore (x y z t)
:name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
:precision binary64
:herbie-target
(if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))
(/ (* x 2.0) (- (* y z) (* t z))))