
(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 (if (or (<= (* x 2.0) -100.0) (not (<= (* x 2.0) 1e+37))) (* (/ 2.0 z) (/ x (- y t))) (* 2.0 (/ (/ x z) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * 2.0) <= -100.0) || !((x * 2.0) <= 1e+37)) {
tmp = (2.0 / z) * (x / (y - t));
} else {
tmp = 2.0 * ((x / z) / (y - 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 (((x * 2.0d0) <= (-100.0d0)) .or. (.not. ((x * 2.0d0) <= 1d+37))) then
tmp = (2.0d0 / z) * (x / (y - t))
else
tmp = 2.0d0 * ((x / z) / (y - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * 2.0) <= -100.0) || !((x * 2.0) <= 1e+37)) {
tmp = (2.0 / z) * (x / (y - t));
} else {
tmp = 2.0 * ((x / z) / (y - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x * 2.0) <= -100.0) or not ((x * 2.0) <= 1e+37): tmp = (2.0 / z) * (x / (y - t)) else: tmp = 2.0 * ((x / z) / (y - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x * 2.0) <= -100.0) || !(Float64(x * 2.0) <= 1e+37)) tmp = Float64(Float64(2.0 / z) * Float64(x / Float64(y - t))); else tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x * 2.0) <= -100.0) || ~(((x * 2.0) <= 1e+37))) tmp = (2.0 / z) * (x / (y - t)); else tmp = 2.0 * ((x / z) / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x * 2.0), $MachinePrecision], -100.0], N[Not[LessEqual[N[(x * 2.0), $MachinePrecision], 1e+37]], $MachinePrecision]], N[(N[(2.0 / z), $MachinePrecision] * N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \leq -100 \lor \neg \left(x \cdot 2 \leq 10^{+37}\right):\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\end{array}
\end{array}
if (*.f64 x 2) < -100 or 9.99999999999999954e36 < (*.f64 x 2) Initial program 87.1%
*-commutative87.1%
distribute-rgt-out--88.0%
times-frac98.0%
Simplified98.0%
if -100 < (*.f64 x 2) < 9.99999999999999954e36Initial program 95.5%
*-commutative95.5%
associate-*r/95.5%
distribute-rgt-out--97.1%
associate-/r*99.1%
Simplified99.1%
Final simplification98.6%
(FPCore (x y z t) :precision binary64 (if (<= (- (* y z) (* z t)) 2e+110) (/ (* x 2.0) (* z (- y t))) (* (/ 2.0 z) (/ x (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((y * z) - (z * t)) <= 2e+110) {
tmp = (x * 2.0) / (z * (y - t));
} else {
tmp = (2.0 / z) * (x / (y - 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 (((y * z) - (z * t)) <= 2d+110) then
tmp = (x * 2.0d0) / (z * (y - t))
else
tmp = (2.0d0 / z) * (x / (y - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((y * z) - (z * t)) <= 2e+110) {
tmp = (x * 2.0) / (z * (y - t));
} else {
tmp = (2.0 / z) * (x / (y - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((y * z) - (z * t)) <= 2e+110: tmp = (x * 2.0) / (z * (y - t)) else: tmp = (2.0 / z) * (x / (y - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(y * z) - Float64(z * t)) <= 2e+110) tmp = Float64(Float64(x * 2.0) / Float64(z * Float64(y - t))); else tmp = Float64(Float64(2.0 / z) * Float64(x / Float64(y - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((y * z) - (z * t)) <= 2e+110) tmp = (x * 2.0) / (z * (y - t)); else tmp = (2.0 / z) * (x / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision], 2e+110], N[(N[(x * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z - z \cdot t \leq 2 \cdot 10^{+110}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < 2e110Initial program 96.1%
distribute-rgt-out--96.7%
Simplified96.7%
if 2e110 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 75.9%
*-commutative75.9%
distribute-rgt-out--79.5%
times-frac98.7%
Simplified98.7%
Final simplification97.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6e-118) (not (<= t 9e+25))) (* x (/ (/ -2.0 t) z)) (* (/ 2.0 z) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -6e-118) || !(t <= 9e+25)) {
tmp = x * ((-2.0 / t) / z);
} 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 <= (-6d-118)) .or. (.not. (t <= 9d+25))) then
tmp = x * (((-2.0d0) / t) / z)
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 <= -6e-118) || !(t <= 9e+25)) {
tmp = x * ((-2.0 / t) / z);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -6e-118) or not (t <= 9e+25): tmp = x * ((-2.0 / t) / z) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -6e-118) || !(t <= 9e+25)) tmp = Float64(x * Float64(Float64(-2.0 / t) / z)); 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 <= -6e-118) || ~((t <= 9e+25))) tmp = x * ((-2.0 / t) / z); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -6e-118], N[Not[LessEqual[t, 9e+25]], $MachinePrecision]], N[(x * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6 \cdot 10^{-118} \lor \neg \left(t \leq 9 \cdot 10^{+25}\right):\\
\;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if t < -6.00000000000000035e-118 or 9.0000000000000006e25 < t Initial program 90.8%
distribute-rgt-out--92.4%
Simplified92.4%
times-frac87.7%
Applied egg-rr87.7%
Taylor expanded in y around 0 74.1%
associate-*r/73.4%
*-commutative73.4%
associate-/r*71.6%
associate-*r/72.2%
metadata-eval72.2%
associate-*r/72.2%
associate-*r/74.6%
associate-*r/74.6%
metadata-eval74.6%
Simplified74.6%
if -6.00000000000000035e-118 < t < 9.0000000000000006e25Initial program 91.9%
*-commutative91.9%
associate-*r/91.9%
distribute-rgt-out--92.8%
associate-/r*94.0%
Simplified94.0%
Taylor expanded in y around inf 76.8%
associate-*r/76.8%
*-commutative76.8%
times-frac80.7%
Simplified80.7%
Final simplification77.4%
(FPCore (x y z t) :precision binary64 (if (or (<= t -7e-117) (not (<= t 1.65e+27))) (* x (/ (/ -2.0 t) z)) (* (/ x z) (/ 2.0 y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7e-117) || !(t <= 1.65e+27)) {
tmp = x * ((-2.0 / t) / z);
} else {
tmp = (x / z) * (2.0 / 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 <= (-7d-117)) .or. (.not. (t <= 1.65d+27))) then
tmp = x * (((-2.0d0) / t) / z)
else
tmp = (x / z) * (2.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -7e-117) || !(t <= 1.65e+27)) {
tmp = x * ((-2.0 / t) / z);
} else {
tmp = (x / z) * (2.0 / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -7e-117) or not (t <= 1.65e+27): tmp = x * ((-2.0 / t) / z) else: tmp = (x / z) * (2.0 / y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -7e-117) || !(t <= 1.65e+27)) tmp = Float64(x * Float64(Float64(-2.0 / t) / z)); else tmp = Float64(Float64(x / z) * Float64(2.0 / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -7e-117) || ~((t <= 1.65e+27))) tmp = x * ((-2.0 / t) / z); else tmp = (x / z) * (2.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -7e-117], N[Not[LessEqual[t, 1.65e+27]], $MachinePrecision]], N[(x * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -7 \cdot 10^{-117} \lor \neg \left(t \leq 1.65 \cdot 10^{+27}\right):\\
\;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\
\end{array}
\end{array}
if t < -6.9999999999999997e-117 or 1.6499999999999999e27 < t Initial program 90.8%
distribute-rgt-out--92.4%
Simplified92.4%
times-frac87.7%
Applied egg-rr87.7%
Taylor expanded in y around 0 74.1%
associate-*r/73.4%
*-commutative73.4%
associate-/r*71.6%
associate-*r/72.2%
metadata-eval72.2%
associate-*r/72.2%
associate-*r/74.6%
associate-*r/74.6%
metadata-eval74.6%
Simplified74.6%
if -6.9999999999999997e-117 < t < 1.6499999999999999e27Initial program 91.9%
distribute-rgt-out--92.8%
Simplified92.8%
Taylor expanded in y around inf 76.8%
*-commutative76.8%
times-frac82.1%
Applied egg-rr82.1%
Final simplification78.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -7e-109) (not (<= y 7.2e-65))) (* (/ 2.0 z) (/ x y)) (/ -2.0 (/ z (/ x t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7e-109) || !(y <= 7.2e-65)) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = -2.0 / (z / (x / 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 ((y <= (-7d-109)) .or. (.not. (y <= 7.2d-65))) then
tmp = (2.0d0 / z) * (x / y)
else
tmp = (-2.0d0) / (z / (x / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -7e-109) || !(y <= 7.2e-65)) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = -2.0 / (z / (x / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -7e-109) or not (y <= 7.2e-65): tmp = (2.0 / z) * (x / y) else: tmp = -2.0 / (z / (x / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -7e-109) || !(y <= 7.2e-65)) tmp = Float64(Float64(2.0 / z) * Float64(x / y)); else tmp = Float64(-2.0 / Float64(z / Float64(x / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -7e-109) || ~((y <= 7.2e-65))) tmp = (2.0 / z) * (x / y); else tmp = -2.0 / (z / (x / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -7e-109], N[Not[LessEqual[y, 7.2e-65]], $MachinePrecision]], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(z / N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{-109} \lor \neg \left(y \leq 7.2 \cdot 10^{-65}\right):\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{\frac{z}{\frac{x}{t}}}\\
\end{array}
\end{array}
if y < -7e-109 or 7.1999999999999996e-65 < y Initial program 92.4%
*-commutative92.4%
associate-*r/92.4%
distribute-rgt-out--93.9%
associate-/r*89.9%
Simplified89.9%
Taylor expanded in y around inf 73.7%
associate-*r/73.7%
*-commutative73.7%
times-frac75.3%
Simplified75.3%
if -7e-109 < y < 7.1999999999999996e-65Initial program 89.7%
*-commutative89.7%
associate-*r/90.6%
distribute-rgt-out--91.5%
associate-/r*91.5%
Simplified91.5%
Taylor expanded in y around 0 77.5%
*-commutative77.5%
Simplified77.5%
*-commutative77.5%
clear-num77.4%
un-div-inv77.4%
*-commutative77.4%
associate-/l*81.3%
Applied egg-rr81.3%
Final simplification77.7%
(FPCore (x y z t) :precision binary64 (if (<= t -6e-118) (* -2.0 (/ x (* z t))) (if (<= t 1.1e+26) (* (/ x z) (/ 2.0 y)) (* x (/ (/ -2.0 t) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6e-118) {
tmp = -2.0 * (x / (z * t));
} else if (t <= 1.1e+26) {
tmp = (x / z) * (2.0 / y);
} else {
tmp = x * ((-2.0 / 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
real(8) :: tmp
if (t <= (-6d-118)) then
tmp = (-2.0d0) * (x / (z * t))
else if (t <= 1.1d+26) then
tmp = (x / z) * (2.0d0 / y)
else
tmp = x * (((-2.0d0) / t) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -6e-118) {
tmp = -2.0 * (x / (z * t));
} else if (t <= 1.1e+26) {
tmp = (x / z) * (2.0 / y);
} else {
tmp = x * ((-2.0 / t) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -6e-118: tmp = -2.0 * (x / (z * t)) elif t <= 1.1e+26: tmp = (x / z) * (2.0 / y) else: tmp = x * ((-2.0 / t) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -6e-118) tmp = Float64(-2.0 * Float64(x / Float64(z * t))); elseif (t <= 1.1e+26) tmp = Float64(Float64(x / z) * Float64(2.0 / y)); else tmp = Float64(x * Float64(Float64(-2.0 / t) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -6e-118) tmp = -2.0 * (x / (z * t)); elseif (t <= 1.1e+26) tmp = (x / z) * (2.0 / y); else tmp = x * ((-2.0 / t) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -6e-118], N[(-2.0 * N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.1e+26], N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6 \cdot 10^{-118}:\\
\;\;\;\;-2 \cdot \frac{x}{z \cdot t}\\
\mathbf{elif}\;t \leq 1.1 \cdot 10^{+26}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\
\end{array}
\end{array}
if t < -6.00000000000000035e-118Initial program 92.6%
*-commutative92.6%
associate-*r/92.6%
distribute-rgt-out--93.9%
associate-/r*89.3%
Simplified89.3%
Taylor expanded in y around 0 71.5%
*-commutative71.5%
Simplified71.5%
if -6.00000000000000035e-118 < t < 1.10000000000000004e26Initial program 91.9%
distribute-rgt-out--92.8%
Simplified92.8%
Taylor expanded in y around inf 76.8%
*-commutative76.8%
times-frac82.1%
Applied egg-rr82.1%
if 1.10000000000000004e26 < t Initial program 88.3%
distribute-rgt-out--90.2%
Simplified90.2%
times-frac85.4%
Applied egg-rr85.4%
Taylor expanded in y around 0 77.5%
associate-*r/75.9%
*-commutative75.9%
associate-/r*75.0%
associate-*r/76.6%
metadata-eval76.6%
associate-*r/76.6%
associate-*r/78.9%
associate-*r/78.9%
metadata-eval78.9%
Simplified78.9%
Final simplification78.0%
(FPCore (x y z t) :precision binary64 (if (<= y -7.4e-106) (/ (* x 2.0) (* y z)) (if (<= y 1.86e-65) (/ -2.0 (/ z (/ x t))) (* (/ 2.0 z) (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -7.4e-106) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 1.86e-65) {
tmp = -2.0 / (z / (x / 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 (y <= (-7.4d-106)) then
tmp = (x * 2.0d0) / (y * z)
else if (y <= 1.86d-65) then
tmp = (-2.0d0) / (z / (x / 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 (y <= -7.4e-106) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 1.86e-65) {
tmp = -2.0 / (z / (x / t));
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -7.4e-106: tmp = (x * 2.0) / (y * z) elif y <= 1.86e-65: tmp = -2.0 / (z / (x / t)) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -7.4e-106) tmp = Float64(Float64(x * 2.0) / Float64(y * z)); elseif (y <= 1.86e-65) tmp = Float64(-2.0 / Float64(z / Float64(x / 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 (y <= -7.4e-106) tmp = (x * 2.0) / (y * z); elseif (y <= 1.86e-65) tmp = -2.0 / (z / (x / t)); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -7.4e-106], N[(N[(x * 2.0), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.86e-65], N[(-2.0 / N[(z / N[(x / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.4 \cdot 10^{-106}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z}\\
\mathbf{elif}\;y \leq 1.86 \cdot 10^{-65}:\\
\;\;\;\;\frac{-2}{\frac{z}{\frac{x}{t}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -7.39999999999999959e-106Initial program 92.7%
distribute-rgt-out--94.1%
Simplified94.1%
Taylor expanded in y around inf 75.9%
if -7.39999999999999959e-106 < y < 1.86000000000000006e-65Initial program 89.7%
*-commutative89.7%
associate-*r/90.6%
distribute-rgt-out--91.5%
associate-/r*91.5%
Simplified91.5%
Taylor expanded in y around 0 77.5%
*-commutative77.5%
Simplified77.5%
*-commutative77.5%
clear-num77.4%
un-div-inv77.4%
*-commutative77.4%
associate-/l*81.3%
Applied egg-rr81.3%
if 1.86000000000000006e-65 < y Initial program 92.2%
*-commutative92.2%
associate-*r/92.2%
distribute-rgt-out--93.6%
associate-/r*90.3%
Simplified90.3%
Taylor expanded in y around inf 71.6%
associate-*r/71.7%
*-commutative71.7%
times-frac75.8%
Simplified75.8%
Final simplification78.1%
(FPCore (x y z t) :precision binary64 (if (<= y -3.7e-106) (/ (* x 2.0) (* y z)) (if (<= y 7.2e-65) (/ (* x (/ -2.0 t)) z) (* (/ 2.0 z) (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.7e-106) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 7.2e-65) {
tmp = (x * (-2.0 / t)) / z;
} 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 (y <= (-3.7d-106)) then
tmp = (x * 2.0d0) / (y * z)
else if (y <= 7.2d-65) then
tmp = (x * ((-2.0d0) / t)) / z
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 (y <= -3.7e-106) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 7.2e-65) {
tmp = (x * (-2.0 / t)) / z;
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.7e-106: tmp = (x * 2.0) / (y * z) elif y <= 7.2e-65: tmp = (x * (-2.0 / t)) / z else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.7e-106) tmp = Float64(Float64(x * 2.0) / Float64(y * z)); elseif (y <= 7.2e-65) tmp = Float64(Float64(x * Float64(-2.0 / t)) / z); 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 (y <= -3.7e-106) tmp = (x * 2.0) / (y * z); elseif (y <= 7.2e-65) tmp = (x * (-2.0 / t)) / z; else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.7e-106], N[(N[(x * 2.0), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.2e-65], N[(N[(x * N[(-2.0 / t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{-106}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z}\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-65}:\\
\;\;\;\;\frac{x \cdot \frac{-2}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -3.69999999999999979e-106Initial program 92.7%
distribute-rgt-out--94.1%
Simplified94.1%
Taylor expanded in y around inf 75.9%
if -3.69999999999999979e-106 < y < 7.1999999999999996e-65Initial program 89.7%
*-commutative89.7%
associate-*r/90.6%
distribute-rgt-out--91.5%
associate-/r*91.5%
Simplified91.5%
Taylor expanded in y around 0 77.5%
associate-*r/76.6%
*-commutative76.6%
associate-/r*80.4%
Simplified80.4%
Taylor expanded in x around 0 81.3%
*-commutative81.3%
associate-*l/80.4%
associate-*r/81.3%
Simplified81.3%
if 7.1999999999999996e-65 < y Initial program 92.2%
*-commutative92.2%
associate-*r/92.2%
distribute-rgt-out--93.6%
associate-/r*90.3%
Simplified90.3%
Taylor expanded in y around inf 71.6%
associate-*r/71.7%
*-commutative71.7%
times-frac75.8%
Simplified75.8%
Final simplification78.1%
(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 91.3%
*-commutative91.3%
associate-*r/91.7%
distribute-rgt-out--92.9%
associate-/r*90.6%
Simplified90.6%
Final simplification90.6%
(FPCore (x y z t) :precision binary64 (* x (/ (/ -2.0 t) z)))
double code(double x, double y, double z, double t) {
return x * ((-2.0 / 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) / t) / z)
end function
public static double code(double x, double y, double z, double t) {
return x * ((-2.0 / t) / z);
}
def code(x, y, z, t): return x * ((-2.0 / t) / z)
function code(x, y, z, t) return Float64(x * Float64(Float64(-2.0 / t) / z)) end
function tmp = code(x, y, z, t) tmp = x * ((-2.0 / t) / z); end
code[x_, y_, z_, t_] := N[(x * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{-2}{t}}{z}
\end{array}
Initial program 91.3%
distribute-rgt-out--92.6%
Simplified92.6%
times-frac90.6%
Applied egg-rr90.6%
Taylor expanded in y around 0 52.7%
associate-*r/52.3%
*-commutative52.3%
associate-/r*51.3%
associate-*r/51.6%
metadata-eval51.6%
associate-*r/51.6%
associate-*r/52.9%
associate-*r/52.9%
metadata-eval52.9%
Simplified52.9%
Final simplification52.9%
(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 2023274
(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))))