
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
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
public static double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
function code(x, y, z, t) return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x * 2.0) / ((y * z) - (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
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
public static double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
function code(x, y, z, t) return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x * 2.0) / ((y * z) - (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y z) (* z t))))
(if (or (<= t_1 -2e+268) (not (<= t_1 5e+244)))
(* 2.0 (/ (/ x z) (- y t)))
(/ (* 2.0 x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (y * z) - (z * t);
double tmp;
if ((t_1 <= -2e+268) || !(t_1 <= 5e+244)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (2.0 * x) / t_1;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = (y * z) - (z * t)
if ((t_1 <= (-2d+268)) .or. (.not. (t_1 <= 5d+244))) then
tmp = 2.0d0 * ((x / z) / (y - t))
else
tmp = (2.0d0 * x) / t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (y * z) - (z * t);
double tmp;
if ((t_1 <= -2e+268) || !(t_1 <= 5e+244)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (2.0 * x) / t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (y * z) - (z * t) tmp = 0 if (t_1 <= -2e+268) or not (t_1 <= 5e+244): tmp = 2.0 * ((x / z) / (y - t)) else: tmp = (2.0 * x) / t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y * z) - Float64(z * t)) tmp = 0.0 if ((t_1 <= -2e+268) || !(t_1 <= 5e+244)) tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); else tmp = Float64(Float64(2.0 * x) / t_1); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (y * z) - (z * t); tmp = 0.0; if ((t_1 <= -2e+268) || ~((t_1 <= 5e+244))) tmp = 2.0 * ((x / z) / (y - t)); else tmp = (2.0 * x) / t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+268], N[Not[LessEqual[t$95$1, 5e+244]], $MachinePrecision]], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * x), $MachinePrecision] / t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot z - z \cdot t\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+268} \lor \neg \left(t_1 \leq 5 \cdot 10^{+244}\right):\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{t_1}\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < -1.9999999999999999e268 or 5.00000000000000022e244 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 71.2%
*-commutative71.2%
associate-*r/71.2%
distribute-rgt-out--81.6%
associate-/r*100.0%
Simplified100.0%
if -1.9999999999999999e268 < (-.f64 (*.f64 y z) (*.f64 t z)) < 5.00000000000000022e244Initial program 98.7%
Final simplification99.0%
(FPCore (x y z t)
:precision binary64
(if (<= (* 2.0 x) -1e-96)
(* (/ 2.0 z) (/ x (- y t)))
(if (<= (* 2.0 x) 5e-61)
(/ 2.0 (/ (* z (- y t)) x))
(/ 2.0 (* z (/ (- y t) x))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((2.0 * x) <= -1e-96) {
tmp = (2.0 / z) * (x / (y - t));
} else if ((2.0 * x) <= 5e-61) {
tmp = 2.0 / ((z * (y - t)) / x);
} else {
tmp = 2.0 / (z * ((y - t) / x));
}
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
real(8) :: tmp
if ((2.0d0 * x) <= (-1d-96)) then
tmp = (2.0d0 / z) * (x / (y - t))
else if ((2.0d0 * x) <= 5d-61) then
tmp = 2.0d0 / ((z * (y - t)) / x)
else
tmp = 2.0d0 / (z * ((y - t) / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((2.0 * x) <= -1e-96) {
tmp = (2.0 / z) * (x / (y - t));
} else if ((2.0 * x) <= 5e-61) {
tmp = 2.0 / ((z * (y - t)) / x);
} else {
tmp = 2.0 / (z * ((y - t) / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (2.0 * x) <= -1e-96: tmp = (2.0 / z) * (x / (y - t)) elif (2.0 * x) <= 5e-61: tmp = 2.0 / ((z * (y - t)) / x) else: tmp = 2.0 / (z * ((y - t) / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(2.0 * x) <= -1e-96) tmp = Float64(Float64(2.0 / z) * Float64(x / Float64(y - t))); elseif (Float64(2.0 * x) <= 5e-61) tmp = Float64(2.0 / Float64(Float64(z * Float64(y - t)) / x)); else tmp = Float64(2.0 / Float64(z * Float64(Float64(y - t) / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((2.0 * x) <= -1e-96) tmp = (2.0 / z) * (x / (y - t)); elseif ((2.0 * x) <= 5e-61) tmp = 2.0 / ((z * (y - t)) / x); else tmp = 2.0 / (z * ((y - t) / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(2.0 * x), $MachinePrecision], -1e-96], N[(N[(2.0 / z), $MachinePrecision] * N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(2.0 * x), $MachinePrecision], 5e-61], N[(2.0 / N[(N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(z * N[(N[(y - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot x \leq -1 \cdot 10^{-96}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\
\mathbf{elif}\;2 \cdot x \leq 5 \cdot 10^{-61}:\\
\;\;\;\;\frac{2}{\frac{z \cdot \left(y - t\right)}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z \cdot \frac{y - t}{x}}\\
\end{array}
\end{array}
if (*.f64 x 2) < -9.9999999999999991e-97Initial program 87.9%
*-commutative87.9%
distribute-rgt-out--91.6%
times-frac97.4%
Simplified97.4%
if -9.9999999999999991e-97 < (*.f64 x 2) < 4.9999999999999999e-61Initial program 96.9%
*-commutative96.9%
associate-*r/96.9%
distribute-rgt-out--98.8%
associate-/r*92.5%
Simplified92.5%
associate-/r*98.8%
associate-*r/98.8%
associate-/l*98.1%
Applied egg-rr98.1%
if 4.9999999999999999e-61 < (*.f64 x 2) Initial program 83.9%
*-commutative83.9%
associate-*r/83.9%
distribute-rgt-out--88.1%
associate-/r*93.3%
Simplified93.3%
associate-/r*88.1%
associate-*r/88.1%
frac-times98.3%
clear-num98.2%
frac-times98.7%
metadata-eval98.7%
Applied egg-rr98.7%
Final simplification98.1%
(FPCore (x y z t)
:precision binary64
(if (<= (* 2.0 x) -5e-37)
(* (/ 2.0 z) (/ x (- y t)))
(if (<= (* 2.0 x) 1e+33)
(/ (* 2.0 x) (* z (- y t)))
(/ 2.0 (* z (/ (- y t) x))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((2.0 * x) <= -5e-37) {
tmp = (2.0 / z) * (x / (y - t));
} else if ((2.0 * x) <= 1e+33) {
tmp = (2.0 * x) / (z * (y - t));
} else {
tmp = 2.0 / (z * ((y - t) / x));
}
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
real(8) :: tmp
if ((2.0d0 * x) <= (-5d-37)) then
tmp = (2.0d0 / z) * (x / (y - t))
else if ((2.0d0 * x) <= 1d+33) then
tmp = (2.0d0 * x) / (z * (y - t))
else
tmp = 2.0d0 / (z * ((y - t) / x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((2.0 * x) <= -5e-37) {
tmp = (2.0 / z) * (x / (y - t));
} else if ((2.0 * x) <= 1e+33) {
tmp = (2.0 * x) / (z * (y - t));
} else {
tmp = 2.0 / (z * ((y - t) / x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (2.0 * x) <= -5e-37: tmp = (2.0 / z) * (x / (y - t)) elif (2.0 * x) <= 1e+33: tmp = (2.0 * x) / (z * (y - t)) else: tmp = 2.0 / (z * ((y - t) / x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(2.0 * x) <= -5e-37) tmp = Float64(Float64(2.0 / z) * Float64(x / Float64(y - t))); elseif (Float64(2.0 * x) <= 1e+33) tmp = Float64(Float64(2.0 * x) / Float64(z * Float64(y - t))); else tmp = Float64(2.0 / Float64(z * Float64(Float64(y - t) / x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((2.0 * x) <= -5e-37) tmp = (2.0 / z) * (x / (y - t)); elseif ((2.0 * x) <= 1e+33) tmp = (2.0 * x) / (z * (y - t)); else tmp = 2.0 / (z * ((y - t) / x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(2.0 * x), $MachinePrecision], -5e-37], N[(N[(2.0 / z), $MachinePrecision] * N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(2.0 * x), $MachinePrecision], 1e+33], N[(N[(2.0 * x), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 / N[(z * N[(N[(y - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot x \leq -5 \cdot 10^{-37}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\
\mathbf{elif}\;2 \cdot x \leq 10^{+33}:\\
\;\;\;\;\frac{2 \cdot x}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z \cdot \frac{y - t}{x}}\\
\end{array}
\end{array}
if (*.f64 x 2) < -4.9999999999999997e-37Initial program 86.2%
*-commutative86.2%
distribute-rgt-out--90.4%
times-frac97.0%
Simplified97.0%
if -4.9999999999999997e-37 < (*.f64 x 2) < 9.9999999999999995e32Initial program 96.1%
distribute-rgt-out--99.1%
Simplified99.1%
if 9.9999999999999995e32 < (*.f64 x 2) Initial program 80.2%
*-commutative80.2%
associate-*r/80.2%
distribute-rgt-out--82.2%
associate-/r*90.1%
Simplified90.1%
associate-/r*82.2%
associate-*r/82.2%
frac-times97.7%
clear-num97.6%
frac-times98.9%
metadata-eval98.9%
Applied egg-rr98.9%
Final simplification98.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6.2e-67) (not (<= t 3.8e-40))) (* x (/ (/ -2.0 z) t)) (* x (/ 2.0 (* y z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.2e-67) || !(t <= 3.8e-40)) {
tmp = x * ((-2.0 / z) / t);
} else {
tmp = x * (2.0 / (y * 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
real(8) :: tmp
if ((t <= (-6.2d-67)) .or. (.not. (t <= 3.8d-40))) then
tmp = x * (((-2.0d0) / z) / t)
else
tmp = x * (2.0d0 / (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6.2e-67) || !(t <= 3.8e-40)) {
tmp = x * ((-2.0 / z) / t);
} else {
tmp = x * (2.0 / (y * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -6.2e-67) or not (t <= 3.8e-40): tmp = x * ((-2.0 / z) / t) else: tmp = x * (2.0 / (y * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -6.2e-67) || !(t <= 3.8e-40)) tmp = Float64(x * Float64(Float64(-2.0 / z) / t)); else tmp = Float64(x * Float64(2.0 / Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -6.2e-67) || ~((t <= 3.8e-40))) tmp = x * ((-2.0 / z) / t); else tmp = x * (2.0 / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -6.2e-67], N[Not[LessEqual[t, 3.8e-40]], $MachinePrecision]], N[(x * N[(N[(-2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x * N[(2.0 / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.2 \cdot 10^{-67} \lor \neg \left(t \leq 3.8 \cdot 10^{-40}\right):\\
\;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{2}{y \cdot z}\\
\end{array}
\end{array}
if t < -6.2000000000000005e-67 or 3.7999999999999999e-40 < t Initial program 87.5%
*-commutative87.5%
associate-*r/87.5%
distribute-rgt-out--92.9%
associate-/r*92.8%
Simplified92.8%
associate-/r*92.9%
associate-*r/92.9%
associate-/l*92.6%
Applied egg-rr92.6%
Taylor expanded in y around 0 78.8%
*-commutative78.8%
*-commutative78.8%
associate-*l/78.8%
associate-*r/78.6%
associate-/r*79.5%
Simplified79.5%
if -6.2000000000000005e-67 < t < 3.7999999999999999e-40Initial program 94.4%
*-commutative94.4%
associate-*r/94.4%
distribute-rgt-out--94.4%
associate-/r*91.0%
Simplified91.0%
associate-/r*94.4%
associate-*r/94.4%
associate-/l*93.7%
Applied egg-rr93.7%
Taylor expanded in y around inf 77.1%
*-commutative77.1%
*-commutative77.1%
associate-/r/77.1%
associate-/l*77.1%
Simplified77.1%
clear-num76.5%
associate-/r/77.1%
clear-num77.9%
associate-/l/77.1%
Applied egg-rr77.1%
Final simplification78.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -7.2e-66) (not (<= t 5.2e-38))) (* x (/ (/ -2.0 z) t)) (* (/ 2.0 z) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7.2e-66) || !(t <= 5.2e-38)) {
tmp = x * ((-2.0 / z) / t);
} else {
tmp = (2.0 / z) * (x / 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
real(8) :: tmp
if ((t <= (-7.2d-66)) .or. (.not. (t <= 5.2d-38))) then
tmp = x * (((-2.0d0) / z) / t)
else
tmp = (2.0d0 / z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7.2e-66) || !(t <= 5.2e-38)) {
tmp = x * ((-2.0 / z) / t);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -7.2e-66) or not (t <= 5.2e-38): tmp = x * ((-2.0 / z) / t) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -7.2e-66) || !(t <= 5.2e-38)) tmp = Float64(x * Float64(Float64(-2.0 / z) / t)); else tmp = Float64(Float64(2.0 / z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -7.2e-66) || ~((t <= 5.2e-38))) tmp = x * ((-2.0 / z) / t); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -7.2e-66], N[Not[LessEqual[t, 5.2e-38]], $MachinePrecision]], N[(x * N[(N[(-2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.2 \cdot 10^{-66} \lor \neg \left(t \leq 5.2 \cdot 10^{-38}\right):\\
\;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if t < -7.20000000000000025e-66 or 5.20000000000000022e-38 < t Initial program 87.5%
*-commutative87.5%
associate-*r/87.5%
distribute-rgt-out--92.9%
associate-/r*92.8%
Simplified92.8%
associate-/r*92.9%
associate-*r/92.9%
associate-/l*92.6%
Applied egg-rr92.6%
Taylor expanded in y around 0 78.8%
*-commutative78.8%
*-commutative78.8%
associate-*l/78.8%
associate-*r/78.6%
associate-/r*79.5%
Simplified79.5%
if -7.20000000000000025e-66 < t < 5.20000000000000022e-38Initial program 94.4%
*-commutative94.4%
associate-*r/94.4%
distribute-rgt-out--94.4%
associate-/r*91.0%
Simplified91.0%
Taylor expanded in y around inf 77.1%
associate-*r/77.1%
*-commutative77.1%
times-frac79.0%
Simplified79.0%
Final simplification79.3%
(FPCore (x y z t) :precision binary64 (if (<= t -3.9e-67) (/ (* x -2.0) (* z t)) (if (<= t 1.35e-38) (* (/ 2.0 z) (/ x y)) (* x (/ (/ -2.0 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.9e-67) {
tmp = (x * -2.0) / (z * t);
} else if (t <= 1.35e-38) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = x * ((-2.0 / z) / t);
}
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
real(8) :: tmp
if (t <= (-3.9d-67)) then
tmp = (x * (-2.0d0)) / (z * t)
else if (t <= 1.35d-38) then
tmp = (2.0d0 / z) * (x / y)
else
tmp = x * (((-2.0d0) / z) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -3.9e-67) {
tmp = (x * -2.0) / (z * t);
} else if (t <= 1.35e-38) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = x * ((-2.0 / z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -3.9e-67: tmp = (x * -2.0) / (z * t) elif t <= 1.35e-38: tmp = (2.0 / z) * (x / y) else: tmp = x * ((-2.0 / z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -3.9e-67) tmp = Float64(Float64(x * -2.0) / Float64(z * t)); elseif (t <= 1.35e-38) tmp = Float64(Float64(2.0 / z) * Float64(x / y)); else tmp = Float64(x * Float64(Float64(-2.0 / z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -3.9e-67) tmp = (x * -2.0) / (z * t); elseif (t <= 1.35e-38) tmp = (2.0 / z) * (x / y); else tmp = x * ((-2.0 / z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -3.9e-67], N[(N[(x * -2.0), $MachinePrecision] / N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.35e-38], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.9 \cdot 10^{-67}:\\
\;\;\;\;\frac{x \cdot -2}{z \cdot t}\\
\mathbf{elif}\;t \leq 1.35 \cdot 10^{-38}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\
\end{array}
\end{array}
if t < -3.8999999999999998e-67Initial program 90.3%
*-commutative90.3%
associate-*r/90.3%
distribute-rgt-out--94.5%
associate-/r*92.9%
Simplified92.9%
Taylor expanded in y around 0 77.1%
associate-*r/77.1%
*-commutative77.1%
*-commutative77.1%
Simplified77.1%
if -3.8999999999999998e-67 < t < 1.35000000000000003e-38Initial program 94.4%
*-commutative94.4%
associate-*r/94.4%
distribute-rgt-out--94.4%
associate-/r*91.0%
Simplified91.0%
Taylor expanded in y around inf 77.1%
associate-*r/77.1%
*-commutative77.1%
times-frac79.0%
Simplified79.0%
if 1.35000000000000003e-38 < t Initial program 85.0%
*-commutative85.0%
associate-*r/85.0%
distribute-rgt-out--91.4%
associate-/r*92.7%
Simplified92.7%
associate-/r*91.4%
associate-*r/91.4%
associate-/l*91.4%
Applied egg-rr91.4%
Taylor expanded in y around 0 80.2%
*-commutative80.2%
*-commutative80.2%
associate-*l/80.2%
associate-*r/80.1%
associate-/r*81.9%
Simplified81.9%
Final simplification79.4%
(FPCore (x y z t) :precision binary64 (if (<= t -5.5e-65) (/ (* x -2.0) (* z t)) (if (<= t 2.05e-38) (/ (/ x y) (* z 0.5)) (* x (/ (/ -2.0 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -5.5e-65) {
tmp = (x * -2.0) / (z * t);
} else if (t <= 2.05e-38) {
tmp = (x / y) / (z * 0.5);
} else {
tmp = x * ((-2.0 / z) / t);
}
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
real(8) :: tmp
if (t <= (-5.5d-65)) then
tmp = (x * (-2.0d0)) / (z * t)
else if (t <= 2.05d-38) then
tmp = (x / y) / (z * 0.5d0)
else
tmp = x * (((-2.0d0) / z) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -5.5e-65) {
tmp = (x * -2.0) / (z * t);
} else if (t <= 2.05e-38) {
tmp = (x / y) / (z * 0.5);
} else {
tmp = x * ((-2.0 / z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -5.5e-65: tmp = (x * -2.0) / (z * t) elif t <= 2.05e-38: tmp = (x / y) / (z * 0.5) else: tmp = x * ((-2.0 / z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -5.5e-65) tmp = Float64(Float64(x * -2.0) / Float64(z * t)); elseif (t <= 2.05e-38) tmp = Float64(Float64(x / y) / Float64(z * 0.5)); else tmp = Float64(x * Float64(Float64(-2.0 / z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -5.5e-65) tmp = (x * -2.0) / (z * t); elseif (t <= 2.05e-38) tmp = (x / y) / (z * 0.5); else tmp = x * ((-2.0 / z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -5.5e-65], N[(N[(x * -2.0), $MachinePrecision] / N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.05e-38], N[(N[(x / y), $MachinePrecision] / N[(z * 0.5), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -5.5 \cdot 10^{-65}:\\
\;\;\;\;\frac{x \cdot -2}{z \cdot t}\\
\mathbf{elif}\;t \leq 2.05 \cdot 10^{-38}:\\
\;\;\;\;\frac{\frac{x}{y}}{z \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\
\end{array}
\end{array}
if t < -5.4999999999999999e-65Initial program 90.3%
*-commutative90.3%
associate-*r/90.3%
distribute-rgt-out--94.5%
associate-/r*92.9%
Simplified92.9%
Taylor expanded in y around 0 77.1%
associate-*r/77.1%
*-commutative77.1%
*-commutative77.1%
Simplified77.1%
if -5.4999999999999999e-65 < t < 2.0499999999999999e-38Initial program 94.4%
*-commutative94.4%
associate-*r/94.4%
distribute-rgt-out--94.4%
associate-/r*91.0%
Simplified91.0%
Taylor expanded in y around inf 77.1%
associate-*r/77.1%
*-commutative77.1%
times-frac79.0%
Simplified79.0%
clear-num79.0%
un-div-inv79.2%
div-inv79.2%
metadata-eval79.2%
Applied egg-rr79.2%
if 2.0499999999999999e-38 < t Initial program 85.0%
*-commutative85.0%
associate-*r/85.0%
distribute-rgt-out--91.4%
associate-/r*92.7%
Simplified92.7%
associate-/r*91.4%
associate-*r/91.4%
associate-/l*91.4%
Applied egg-rr91.4%
Taylor expanded in y around 0 80.2%
*-commutative80.2%
*-commutative80.2%
associate-*l/80.2%
associate-*r/80.1%
associate-/r*81.9%
Simplified81.9%
Final simplification79.5%
(FPCore (x y z t) :precision binary64 (* 2.0 (/ (/ x z) (- y t))))
double code(double x, double y, double z, double t) {
return 2.0 * ((x / z) / (y - t));
}
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 = 2.0d0 * ((x / z) / (y - t))
end function
public static double code(double x, double y, double z, double t) {
return 2.0 * ((x / z) / (y - t));
}
def code(x, y, z, t): return 2.0 * ((x / z) / (y - t))
function code(x, y, z, t) return Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))) end
function tmp = code(x, y, z, t) tmp = 2.0 * ((x / z) / (y - t)); end
code[x_, y_, z_, t_] := N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \frac{\frac{x}{z}}{y - t}
\end{array}
Initial program 90.4%
*-commutative90.4%
associate-*r/90.4%
distribute-rgt-out--93.5%
associate-/r*92.1%
Simplified92.1%
Final simplification92.1%
(FPCore (x y z t) :precision binary64 (* (/ 2.0 z) (/ x (- y t))))
double code(double x, double y, double z, double t) {
return (2.0 / z) * (x / (y - t));
}
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 = (2.0d0 / z) * (x / (y - t))
end function
public static double code(double x, double y, double z, double t) {
return (2.0 / z) * (x / (y - t));
}
def code(x, y, z, t): return (2.0 / z) * (x / (y - t))
function code(x, y, z, t) return Float64(Float64(2.0 / z) * Float64(x / Float64(y - t))) end
function tmp = code(x, y, z, t) tmp = (2.0 / z) * (x / (y - t)); end
code[x_, y_, z_, t_] := N[(N[(2.0 / z), $MachinePrecision] * N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{z} \cdot \frac{x}{y - t}
\end{array}
Initial program 90.4%
*-commutative90.4%
distribute-rgt-out--93.5%
times-frac93.5%
Simplified93.5%
Final simplification93.5%
(FPCore (x y z t) :precision binary64 (* x (/ (/ -2.0 z) t)))
double code(double x, double y, double z, double t) {
return x * ((-2.0 / z) / t);
}
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) / z) / t)
end function
public static double code(double x, double y, double z, double t) {
return x * ((-2.0 / z) / t);
}
def code(x, y, z, t): return x * ((-2.0 / z) / t)
function code(x, y, z, t) return Float64(x * Float64(Float64(-2.0 / z) / t)) end
function tmp = code(x, y, z, t) tmp = x * ((-2.0 / z) / t); end
code[x_, y_, z_, t_] := N[(x * N[(N[(-2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{-2}{z}}{t}
\end{array}
Initial program 90.4%
*-commutative90.4%
associate-*r/90.4%
distribute-rgt-out--93.5%
associate-/r*92.1%
Simplified92.1%
associate-/r*93.5%
associate-*r/93.5%
associate-/l*93.1%
Applied egg-rr93.1%
Taylor expanded in y around 0 58.9%
*-commutative58.9%
*-commutative58.9%
associate-*l/58.9%
associate-*r/58.8%
associate-/r*59.3%
Simplified59.3%
Final simplification59.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (/ x (* (- y t) z)) 2.0))
(t_2 (/ (* x 2.0) (- (* y z) (* t z)))))
(if (< t_2 -2.559141628295061e-13)
t_1
(if (< t_2 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x / ((y - t) * z)) * 2.0;
double t_2 = (x * 2.0) / ((y * z) - (t * z));
double tmp;
if (t_2 < -2.559141628295061e-13) {
tmp = t_1;
} else if (t_2 < 1.045027827330126e-269) {
tmp = ((x / z) * 2.0) / (y - t);
} else {
tmp = t_1;
}
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
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (x / ((y - t) * z)) * 2.0d0
t_2 = (x * 2.0d0) / ((y * z) - (t * z))
if (t_2 < (-2.559141628295061d-13)) then
tmp = t_1
else if (t_2 < 1.045027827330126d-269) then
tmp = ((x / z) * 2.0d0) / (y - t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x / ((y - t) * z)) * 2.0;
double t_2 = (x * 2.0) / ((y * z) - (t * z));
double tmp;
if (t_2 < -2.559141628295061e-13) {
tmp = t_1;
} else if (t_2 < 1.045027827330126e-269) {
tmp = ((x / z) * 2.0) / (y - t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x / ((y - t) * z)) * 2.0 t_2 = (x * 2.0) / ((y * z) - (t * z)) tmp = 0 if t_2 < -2.559141628295061e-13: tmp = t_1 elif t_2 < 1.045027827330126e-269: tmp = ((x / z) * 2.0) / (y - t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x / Float64(Float64(y - t) * z)) * 2.0) t_2 = Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) tmp = 0.0 if (t_2 < -2.559141628295061e-13) tmp = t_1; elseif (t_2 < 1.045027827330126e-269) tmp = Float64(Float64(Float64(x / z) * 2.0) / Float64(y - t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x / ((y - t) * z)) * 2.0; t_2 = (x * 2.0) / ((y * z) - (t * z)); tmp = 0.0; if (t_2 < -2.559141628295061e-13) tmp = t_1; elseif (t_2 < 1.045027827330126e-269) tmp = ((x / z) * 2.0) / (y - t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / N[(N[(y - t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$2, -2.559141628295061e-13], t$95$1, If[Less[t$95$2, 1.045027827330126e-269], N[(N[(N[(x / z), $MachinePrecision] * 2.0), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{\left(y - t\right) \cdot z} \cdot 2\\
t_2 := \frac{x \cdot 2}{y \cdot z - t \cdot z}\\
\mathbf{if}\;t_2 < -2.559141628295061 \cdot 10^{-13}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 < 1.045027827330126 \cdot 10^{-269}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2023336
(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))))