(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))
(* (/ (* 2.0 x) (- y t)) (/ 1.0 z))
(if (<= t_1 7.93994715672202e+280)
(/ (* 2.0 x) t_1)
(* (/ 1.0 z) (* x (/ 2.0 (- y t))))))))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 = ((2.0 * x) / (y - t)) * (1.0 / z);
} else if (t_1 <= 7.93994715672202e+280) {
tmp = (2.0 * x) / t_1;
} else {
tmp = (1.0 / z) * (x * (2.0 / (y - t)));
}
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 = ((2.0 * x) / (y - t)) * (1.0 / z);
} else if (t_1 <= 7.93994715672202e+280) {
tmp = (2.0 * x) / t_1;
} else {
tmp = (1.0 / z) * (x * (2.0 / (y - t)));
}
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 = ((2.0 * x) / (y - t)) * (1.0 / z) elif t_1 <= 7.93994715672202e+280: tmp = (2.0 * x) / t_1 else: tmp = (1.0 / z) * (x * (2.0 / (y - t))) 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(Float64(2.0 * x) / Float64(y - t)) * Float64(1.0 / z)); elseif (t_1 <= 7.93994715672202e+280) tmp = Float64(Float64(2.0 * x) / t_1); else tmp = Float64(Float64(1.0 / z) * Float64(x * Float64(2.0 / Float64(y - t)))); 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 = ((2.0 * x) / (y - t)) * (1.0 / z); elseif (t_1 <= 7.93994715672202e+280) tmp = (2.0 * x) / t_1; else tmp = (1.0 / z) * (x * (2.0 / (y - t))); 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[(N[(2.0 * x), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 7.93994715672202e+280], N[(N[(2.0 * x), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] * N[(x * N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision]), $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{2 \cdot x}{y - t} \cdot \frac{1}{z}\\
\mathbf{elif}\;t_1 \leq 7.93994715672202 \cdot 10^{+280}:\\
\;\;\;\;\frac{2 \cdot x}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z} \cdot \left(x \cdot \frac{2}{y - t}\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.5 |
|---|---|
| Target | 2.1 |
| Herbie | 1.2 |
if (-.f64 (*.f64 y z) (*.f64 t z)) < -inf.0Initial program 20.4
Simplified18.4
Applied *-un-lft-identity_binary6418.4
Applied *-un-lft-identity_binary6418.4
Applied add-sqr-sqrt_binary6418.4
Applied times-frac_binary6418.4
Applied times-frac_binary6418.4
Applied associate-*r*_binary6418.4
Simplified18.4
Applied div-inv_binary6418.4
Applied associate-*r*_binary640.4
Simplified0.2
if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < 7.93994715672202011e280Initial program 1.6
if 7.93994715672202011e280 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 23.2
Simplified14.9
Applied div-inv_binary6414.9
Applied associate-*r*_binary640.2
Final simplification1.2
herbie shell --seed 2022131
(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))))