(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y z) (* z t))))
(if (<= t_1 -6.014905296048345e+224)
(/ (* (/ x z) -2.0) (- t y))
(if (<= t_1 2.305918027910845e+262)
(* 2.0 (/ x (* z (- y t))))
(/ (* x (/ 2.0 (- y t))) z)))))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 = (y * z) - (z * t);
double tmp;
if (t_1 <= -6.014905296048345e+224) {
tmp = ((x / z) * -2.0) / (t - y);
} else if (t_1 <= 2.305918027910845e+262) {
tmp = 2.0 * (x / (z * (y - t)));
} else {
tmp = (x * (2.0 / (y - t))) / z;
}
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 = (y * z) - (z * t)
if (t_1 <= (-6.014905296048345d+224)) then
tmp = ((x / z) * (-2.0d0)) / (t - y)
else if (t_1 <= 2.305918027910845d+262) then
tmp = 2.0d0 * (x / (z * (y - t)))
else
tmp = (x * (2.0d0 / (y - t))) / z
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 = (y * z) - (z * t);
double tmp;
if (t_1 <= -6.014905296048345e+224) {
tmp = ((x / z) * -2.0) / (t - y);
} else if (t_1 <= 2.305918027910845e+262) {
tmp = 2.0 * (x / (z * (y - t)));
} else {
tmp = (x * (2.0 / (y - t))) / z;
}
return tmp;
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
def code(x, y, z, t): t_1 = (y * z) - (z * t) tmp = 0 if t_1 <= -6.014905296048345e+224: tmp = ((x / z) * -2.0) / (t - y) elif t_1 <= 2.305918027910845e+262: tmp = 2.0 * (x / (z * (y - t))) else: tmp = (x * (2.0 / (y - t))) / z 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(y * z) - Float64(z * t)) tmp = 0.0 if (t_1 <= -6.014905296048345e+224) tmp = Float64(Float64(Float64(x / z) * -2.0) / Float64(t - y)); elseif (t_1 <= 2.305918027910845e+262) tmp = Float64(2.0 * Float64(x / Float64(z * Float64(y - t)))); else tmp = Float64(Float64(x * Float64(2.0 / Float64(y - t))) / z); 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 = (y * z) - (z * t); tmp = 0.0; if (t_1 <= -6.014905296048345e+224) tmp = ((x / z) * -2.0) / (t - y); elseif (t_1 <= 2.305918027910845e+262) tmp = 2.0 * (x / (z * (y - t))); else tmp = (x * (2.0 / (y - t))) / z; 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[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -6.014905296048345e+224], N[(N[(N[(x / z), $MachinePrecision] * -2.0), $MachinePrecision] / N[(t - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2.305918027910845e+262], N[(2.0 * N[(x / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := y \cdot z - z \cdot t\\
\mathbf{if}\;t_1 \leq -6.014905296048345 \cdot 10^{+224}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot -2}{t - y}\\
\mathbf{elif}\;t_1 \leq 2.305918027910845 \cdot 10^{+262}:\\
\;\;\;\;2 \cdot \frac{x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 7.1 |
|---|---|
| Target | 2.1 |
| Herbie | 1.2 |
if (-.f64 (*.f64 y z) (*.f64 t z)) < -6.01490529604834e224Initial program 13.7
Simplified12.5
Applied egg-rr0.4
Applied egg-rr0.3
Applied egg-rr0.2
if -6.01490529604834e224 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2.3059180279108451e262Initial program 1.6
Simplified1.8
Taylor expanded in x around 0 1.6
if 2.3059180279108451e262 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 24.3
Simplified16.2
Applied egg-rr0.2
Applied egg-rr0.2
Applied egg-rr0.2
Final simplification1.2
herbie shell --seed 2022133
(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))))