(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 (- INFINITY))
(* (/ x (- y t)) (/ 2.0 z))
(if (<= t_1 1.8358957548390894e+154)
(/ (* x 2.0) (* z (- y t)))
(/ (/ 2.0 (- y t)) (/ z x))))))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 <= -((double) INFINITY)) {
tmp = (x / (y - t)) * (2.0 / z);
} else if (t_1 <= 1.8358957548390894e+154) {
tmp = (x * 2.0) / (z * (y - t));
} else {
tmp = (2.0 / (y - t)) / (z / x);
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) {
tmp = (x / (y - t)) * (2.0 / z);
} else if (t_1 <= 1.8358957548390894e+154) {
tmp = (x * 2.0) / (z * (y - t));
} else {
tmp = (2.0 / (y - t)) / (z / x);
}
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 <= -math.inf: tmp = (x / (y - t)) * (2.0 / z) elif t_1 <= 1.8358957548390894e+154: tmp = (x * 2.0) / (z * (y - t)) else: tmp = (2.0 / (y - t)) / (z / x) 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 <= Float64(-Inf)) tmp = Float64(Float64(x / Float64(y - t)) * Float64(2.0 / z)); elseif (t_1 <= 1.8358957548390894e+154) tmp = Float64(Float64(x * 2.0) / Float64(z * Float64(y - t))); else tmp = Float64(Float64(2.0 / Float64(y - t)) / Float64(z / x)); 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 <= -Inf) tmp = (x / (y - t)) * (2.0 / z); elseif (t_1 <= 1.8358957548390894e+154) tmp = (x * 2.0) / (z * (y - t)); else tmp = (2.0 / (y - t)) / (z / x); 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, (-Infinity)], N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.8358957548390894e+154], N[(N[(x * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[(z / x), $MachinePrecision]), $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 -\infty:\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\
\mathbf{elif}\;t_1 \leq 1.8358957548390894 \cdot 10^{+154}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{y - t}}{\frac{z}{x}}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 7.1 |
|---|---|
| Target | 2.2 |
| Herbie | 1.4 |
if (-.f64 (*.f64 y z) (*.f64 t z)) < -inf.0Initial program 23.2
Simplified0.1
Applied egg-rr0.6
Applied egg-rr0.1
Taylor expanded in x around 0 23.2
Simplified0.1
if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < 1.8358957548390894e154Initial program 1.7
Simplified8.5
Applied egg-rr1.7
if 1.8358957548390894e154 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 14.9
Simplified1.2
Applied egg-rr1.6
Applied egg-rr1.2
Applied egg-rr1.2
Final simplification1.4
herbie shell --seed 2022153
(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))))