(FPCore (x y z t) :precision binary64 (* (- (* x y) (* z y)) t))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (* y (- x z))))
(t_2 (- (* x y) (* y z)))
(t_3 (* (- x z) (* y t))))
(if (<= t_2 -3.675024877736191e+161)
t_3
(if (<= t_2 -2.532347618419866e-187)
t_1
(if (<= t_2 3.350296082224214e-201)
(* y (* (- x z) t))
(if (<= t_2 3.647665142799277e+268) t_1 t_3))))))double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
double code(double x, double y, double z, double t) {
double t_1 = t * (y * (x - z));
double t_2 = (x * y) - (y * z);
double t_3 = (x - z) * (y * t);
double tmp;
if (t_2 <= -3.675024877736191e+161) {
tmp = t_3;
} else if (t_2 <= -2.532347618419866e-187) {
tmp = t_1;
} else if (t_2 <= 3.350296082224214e-201) {
tmp = y * ((x - z) * t);
} else if (t_2 <= 3.647665142799277e+268) {
tmp = t_1;
} else {
tmp = t_3;
}
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 * y) - (z * y)) * t
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = t * (y * (x - z))
t_2 = (x * y) - (y * z)
t_3 = (x - z) * (y * t)
if (t_2 <= (-3.675024877736191d+161)) then
tmp = t_3
else if (t_2 <= (-2.532347618419866d-187)) then
tmp = t_1
else if (t_2 <= 3.350296082224214d-201) then
tmp = y * ((x - z) * t)
else if (t_2 <= 3.647665142799277d+268) then
tmp = t_1
else
tmp = t_3
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return ((x * y) - (z * y)) * t;
}
public static double code(double x, double y, double z, double t) {
double t_1 = t * (y * (x - z));
double t_2 = (x * y) - (y * z);
double t_3 = (x - z) * (y * t);
double tmp;
if (t_2 <= -3.675024877736191e+161) {
tmp = t_3;
} else if (t_2 <= -2.532347618419866e-187) {
tmp = t_1;
} else if (t_2 <= 3.350296082224214e-201) {
tmp = y * ((x - z) * t);
} else if (t_2 <= 3.647665142799277e+268) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
def code(x, y, z, t): return ((x * y) - (z * y)) * t
def code(x, y, z, t): t_1 = t * (y * (x - z)) t_2 = (x * y) - (y * z) t_3 = (x - z) * (y * t) tmp = 0 if t_2 <= -3.675024877736191e+161: tmp = t_3 elif t_2 <= -2.532347618419866e-187: tmp = t_1 elif t_2 <= 3.350296082224214e-201: tmp = y * ((x - z) * t) elif t_2 <= 3.647665142799277e+268: tmp = t_1 else: tmp = t_3 return tmp
function code(x, y, z, t) return Float64(Float64(Float64(x * y) - Float64(z * y)) * t) end
function code(x, y, z, t) t_1 = Float64(t * Float64(y * Float64(x - z))) t_2 = Float64(Float64(x * y) - Float64(y * z)) t_3 = Float64(Float64(x - z) * Float64(y * t)) tmp = 0.0 if (t_2 <= -3.675024877736191e+161) tmp = t_3; elseif (t_2 <= -2.532347618419866e-187) tmp = t_1; elseif (t_2 <= 3.350296082224214e-201) tmp = Float64(y * Float64(Float64(x - z) * t)); elseif (t_2 <= 3.647665142799277e+268) tmp = t_1; else tmp = t_3; end return tmp end
function tmp = code(x, y, z, t) tmp = ((x * y) - (z * y)) * t; end
function tmp_2 = code(x, y, z, t) t_1 = t * (y * (x - z)); t_2 = (x * y) - (y * z); t_3 = (x - z) * (y * t); tmp = 0.0; if (t_2 <= -3.675024877736191e+161) tmp = t_3; elseif (t_2 <= -2.532347618419866e-187) tmp = t_1; elseif (t_2 <= 3.350296082224214e-201) tmp = y * ((x - z) * t); elseif (t_2 <= 3.647665142799277e+268) tmp = t_1; else tmp = t_3; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(N[(x * y), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x - z), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -3.675024877736191e+161], t$95$3, If[LessEqual[t$95$2, -2.532347618419866e-187], t$95$1, If[LessEqual[t$95$2, 3.350296082224214e-201], N[(y * N[(N[(x - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 3.647665142799277e+268], t$95$1, t$95$3]]]]]]]
\left(x \cdot y - z \cdot y\right) \cdot t
\begin{array}{l}
t_1 := t \cdot \left(y \cdot \left(x - z\right)\right)\\
t_2 := x \cdot y - y \cdot z\\
t_3 := \left(x - z\right) \cdot \left(y \cdot t\right)\\
\mathbf{if}\;t_2 \leq -3.675024877736191 \cdot 10^{+161}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_2 \leq -2.532347618419866 \cdot 10^{-187}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 3.350296082224214 \cdot 10^{-201}:\\
\;\;\;\;y \cdot \left(\left(x - z\right) \cdot t\right)\\
\mathbf{elif}\;t_2 \leq 3.647665142799277 \cdot 10^{+268}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 6.9 |
|---|---|
| Target | 3.2 |
| Herbie | 0.6 |
if (-.f64 (*.f64 x y) (*.f64 z y)) < -3.6750248777361908e161 or 3.647665142799277e268 < (-.f64 (*.f64 x y) (*.f64 z y)) Initial program 29.6
Simplified1.9
Taylor expanded in y around 0 1.9
Simplified1.5
if -3.6750248777361908e161 < (-.f64 (*.f64 x y) (*.f64 z y)) < -2.5323476184198661e-187 or 3.35029608222421406e-201 < (-.f64 (*.f64 x y) (*.f64 z y)) < 3.647665142799277e268Initial program 0.3
Simplified9.7
Applied egg-rr31.0
Applied egg-rr0.3
if -2.5323476184198661e-187 < (-.f64 (*.f64 x y) (*.f64 z y)) < 3.35029608222421406e-201Initial program 7.7
Simplified0.9
Final simplification0.6
herbie shell --seed 2022153
(FPCore (x y z t)
:name "Linear.Projection:inverseInfinitePerspective from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< t -9.231879582886777e-80) (* (* y t) (- x z)) (if (< t 2.543067051564877e+83) (* y (* t (- x z))) (* (* y (- x z)) t)))
(* (- (* x y) (* z y)) t))