
(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 9 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 (<= t_1 -2e+220)
(* (/ x z) (/ 2.0 (- y t)))
(if (<= t_1 2e+197)
(/ (* x 2.0) (* z (- y t)))
(* 2.0 (/ (/ x z) (- y t)))))))
double code(double x, double y, double z, double t) {
double t_1 = (y * z) - (z * t);
double tmp;
if (t_1 <= -2e+220) {
tmp = (x / z) * (2.0 / (y - t));
} else if (t_1 <= 2e+197) {
tmp = (x * 2.0) / (z * (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) :: t_1
real(8) :: tmp
t_1 = (y * z) - (z * t)
if (t_1 <= (-2d+220)) then
tmp = (x / z) * (2.0d0 / (y - t))
else if (t_1 <= 2d+197) then
tmp = (x * 2.0d0) / (z * (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 t_1 = (y * z) - (z * t);
double tmp;
if (t_1 <= -2e+220) {
tmp = (x / z) * (2.0 / (y - t));
} else if (t_1 <= 2e+197) {
tmp = (x * 2.0) / (z * (y - t));
} else {
tmp = 2.0 * ((x / z) / (y - t));
}
return tmp;
}
def code(x, y, z, t): t_1 = (y * z) - (z * t) tmp = 0 if t_1 <= -2e+220: tmp = (x / z) * (2.0 / (y - t)) elif t_1 <= 2e+197: tmp = (x * 2.0) / (z * (y - t)) else: tmp = 2.0 * ((x / z) / (y - t)) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y * z) - Float64(z * t)) tmp = 0.0 if (t_1 <= -2e+220) tmp = Float64(Float64(x / z) * Float64(2.0 / Float64(y - t))); elseif (t_1 <= 2e+197) tmp = Float64(Float64(x * 2.0) / Float64(z * 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) t_1 = (y * z) - (z * t); tmp = 0.0; if (t_1 <= -2e+220) tmp = (x / z) * (2.0 / (y - t)); elseif (t_1 <= 2e+197) tmp = (x * 2.0) / (z * (y - t)); else tmp = 2.0 * ((x / z) / (y - t)); 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[LessEqual[t$95$1, -2e+220], N[(N[(x / z), $MachinePrecision] * N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+197], N[(N[(x * 2.0), $MachinePrecision] / N[(z * 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}
t_1 := y \cdot z - z \cdot t\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+220}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+197}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < -2e220Initial program 77.4%
distribute-rgt-out--77.4%
Simplified77.4%
times-frac99.9%
Applied egg-rr99.9%
if -2e220 < (-.f64 (*.f64 y z) (*.f64 t z)) < 1.9999999999999999e197Initial program 98.0%
distribute-rgt-out--98.0%
Simplified98.0%
if 1.9999999999999999e197 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 65.9%
*-commutative65.9%
associate-*r/65.9%
distribute-rgt-out--74.0%
associate-/r*99.9%
Simplified99.9%
Final simplification98.6%
(FPCore (x y z t) :precision binary64 (if (or (<= (* x 2.0) -5e-154) (not (<= (* x 2.0) 2e-141))) (* (/ 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) <= -5e-154) || !((x * 2.0) <= 2e-141)) {
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) <= (-5d-154)) .or. (.not. ((x * 2.0d0) <= 2d-141))) 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) <= -5e-154) || !((x * 2.0) <= 2e-141)) {
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) <= -5e-154) or not ((x * 2.0) <= 2e-141): 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) <= -5e-154) || !(Float64(x * 2.0) <= 2e-141)) 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) <= -5e-154) || ~(((x * 2.0) <= 2e-141))) 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], -5e-154], N[Not[LessEqual[N[(x * 2.0), $MachinePrecision], 2e-141]], $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 -5 \cdot 10^{-154} \lor \neg \left(x \cdot 2 \leq 2 \cdot 10^{-141}\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) < -5.0000000000000002e-154 or 2.0000000000000001e-141 < (*.f64 x 2) Initial program 86.2%
*-commutative86.2%
distribute-rgt-out--88.4%
times-frac97.6%
Simplified97.6%
if -5.0000000000000002e-154 < (*.f64 x 2) < 2.0000000000000001e-141Initial program 97.3%
*-commutative97.3%
associate-*r/97.3%
distribute-rgt-out--97.3%
associate-/r*97.1%
Simplified97.1%
Final simplification97.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (/ x z) (/ 2.0 y))))
(if (<= y -4.8e-38)
t_1
(if (<= y 3.8e-63)
(/ -2.0 (* t (/ z x)))
(if (<= y 5.9e-5)
t_1
(if (<= y 1.02e+30) (* -2.0 (/ (/ x t) z)) (* (/ 2.0 z) (/ x y))))))))
double code(double x, double y, double z, double t) {
double t_1 = (x / z) * (2.0 / y);
double tmp;
if (y <= -4.8e-38) {
tmp = t_1;
} else if (y <= 3.8e-63) {
tmp = -2.0 / (t * (z / x));
} else if (y <= 5.9e-5) {
tmp = t_1;
} else if (y <= 1.02e+30) {
tmp = -2.0 * ((x / 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) :: t_1
real(8) :: tmp
t_1 = (x / z) * (2.0d0 / y)
if (y <= (-4.8d-38)) then
tmp = t_1
else if (y <= 3.8d-63) then
tmp = (-2.0d0) / (t * (z / x))
else if (y <= 5.9d-5) then
tmp = t_1
else if (y <= 1.02d+30) then
tmp = (-2.0d0) * ((x / 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 t_1 = (x / z) * (2.0 / y);
double tmp;
if (y <= -4.8e-38) {
tmp = t_1;
} else if (y <= 3.8e-63) {
tmp = -2.0 / (t * (z / x));
} else if (y <= 5.9e-5) {
tmp = t_1;
} else if (y <= 1.02e+30) {
tmp = -2.0 * ((x / t) / z);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): t_1 = (x / z) * (2.0 / y) tmp = 0 if y <= -4.8e-38: tmp = t_1 elif y <= 3.8e-63: tmp = -2.0 / (t * (z / x)) elif y <= 5.9e-5: tmp = t_1 elif y <= 1.02e+30: tmp = -2.0 * ((x / t) / z) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x / z) * Float64(2.0 / y)) tmp = 0.0 if (y <= -4.8e-38) tmp = t_1; elseif (y <= 3.8e-63) tmp = Float64(-2.0 / Float64(t * Float64(z / x))); elseif (y <= 5.9e-5) tmp = t_1; elseif (y <= 1.02e+30) tmp = Float64(-2.0 * Float64(Float64(x / t) / z)); else tmp = Float64(Float64(2.0 / z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x / z) * (2.0 / y); tmp = 0.0; if (y <= -4.8e-38) tmp = t_1; elseif (y <= 3.8e-63) tmp = -2.0 / (t * (z / x)); elseif (y <= 5.9e-5) tmp = t_1; elseif (y <= 1.02e+30) tmp = -2.0 * ((x / t) / z); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.8e-38], t$95$1, If[LessEqual[y, 3.8e-63], N[(-2.0 / N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.9e-5], t$95$1, If[LessEqual[y, 1.02e+30], N[(-2.0 * N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{z} \cdot \frac{2}{y}\\
\mathbf{if}\;y \leq -4.8 \cdot 10^{-38}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-63}:\\
\;\;\;\;\frac{-2}{t \cdot \frac{z}{x}}\\
\mathbf{elif}\;y \leq 5.9 \cdot 10^{-5}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+30}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -4.80000000000000044e-38 or 3.80000000000000017e-63 < y < 5.8999999999999998e-5Initial program 93.4%
distribute-rgt-out--94.8%
Simplified94.8%
times-frac94.8%
Applied egg-rr94.8%
Taylor expanded in y around inf 76.8%
if -4.80000000000000044e-38 < y < 3.80000000000000017e-63Initial program 92.7%
*-commutative92.7%
associate-*r/92.7%
distribute-rgt-out--92.7%
associate-/r*93.6%
Simplified93.6%
Taylor expanded in y around 0 75.6%
*-commutative75.6%
associate-/r*74.9%
Simplified74.9%
*-commutative74.9%
associate-/l/75.6%
associate-*r/75.6%
*-commutative75.6%
times-frac77.1%
clear-num77.0%
frac-times77.2%
metadata-eval77.2%
Applied egg-rr77.2%
if 5.8999999999999998e-5 < y < 1.02e30Initial program 90.3%
*-commutative90.3%
associate-*r/90.3%
distribute-rgt-out--90.3%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in y around 0 71.2%
*-commutative71.2%
associate-/r*80.8%
Simplified80.8%
if 1.02e30 < y Initial program 77.0%
distribute-rgt-out--82.0%
Simplified82.0%
Taylor expanded in y around inf 77.0%
*-commutative77.0%
Simplified77.0%
*-commutative77.0%
times-frac85.4%
Applied egg-rr85.4%
Final simplification79.2%
(FPCore (x y z t)
:precision binary64
(if (<= y -2.25e-39)
(/ (* x 2.0) (* y z))
(if (<= y 7e-64)
(/ -2.0 (* t (/ z x)))
(if (<= y 0.00016)
(* (/ x z) (/ 2.0 y))
(if (<= y 1.1e+30) (* -2.0 (/ (/ x t) z)) (* (/ 2.0 z) (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.25e-39) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 7e-64) {
tmp = -2.0 / (t * (z / x));
} else if (y <= 0.00016) {
tmp = (x / z) * (2.0 / y);
} else if (y <= 1.1e+30) {
tmp = -2.0 * ((x / 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 <= (-2.25d-39)) then
tmp = (x * 2.0d0) / (y * z)
else if (y <= 7d-64) then
tmp = (-2.0d0) / (t * (z / x))
else if (y <= 0.00016d0) then
tmp = (x / z) * (2.0d0 / y)
else if (y <= 1.1d+30) then
tmp = (-2.0d0) * ((x / 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 <= -2.25e-39) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 7e-64) {
tmp = -2.0 / (t * (z / x));
} else if (y <= 0.00016) {
tmp = (x / z) * (2.0 / y);
} else if (y <= 1.1e+30) {
tmp = -2.0 * ((x / t) / z);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.25e-39: tmp = (x * 2.0) / (y * z) elif y <= 7e-64: tmp = -2.0 / (t * (z / x)) elif y <= 0.00016: tmp = (x / z) * (2.0 / y) elif y <= 1.1e+30: tmp = -2.0 * ((x / t) / z) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.25e-39) tmp = Float64(Float64(x * 2.0) / Float64(y * z)); elseif (y <= 7e-64) tmp = Float64(-2.0 / Float64(t * Float64(z / x))); elseif (y <= 0.00016) tmp = Float64(Float64(x / z) * Float64(2.0 / y)); elseif (y <= 1.1e+30) tmp = Float64(-2.0 * Float64(Float64(x / 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 <= -2.25e-39) tmp = (x * 2.0) / (y * z); elseif (y <= 7e-64) tmp = -2.0 / (t * (z / x)); elseif (y <= 0.00016) tmp = (x / z) * (2.0 / y); elseif (y <= 1.1e+30) tmp = -2.0 * ((x / t) / z); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.25e-39], N[(N[(x * 2.0), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-64], N[(-2.0 / N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.00016], N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+30], N[(-2.0 * N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.25 \cdot 10^{-39}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-64}:\\
\;\;\;\;\frac{-2}{t \cdot \frac{z}{x}}\\
\mathbf{elif}\;y \leq 0.00016:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+30}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -2.25e-39Initial program 92.6%
distribute-rgt-out--94.2%
Simplified94.2%
Taylor expanded in y around inf 76.1%
*-commutative76.1%
Simplified76.1%
if -2.25e-39 < y < 7.0000000000000006e-64Initial program 92.7%
*-commutative92.7%
associate-*r/92.7%
distribute-rgt-out--92.7%
associate-/r*94.4%
Simplified94.4%
Taylor expanded in y around 0 76.2%
*-commutative76.2%
associate-/r*75.6%
Simplified75.6%
*-commutative75.6%
associate-/l/76.2%
associate-*r/76.2%
*-commutative76.2%
times-frac77.7%
clear-num77.6%
frac-times77.8%
metadata-eval77.8%
Applied egg-rr77.8%
if 7.0000000000000006e-64 < y < 1.60000000000000013e-4Initial program 99.7%
distribute-rgt-out--99.7%
Simplified99.7%
times-frac100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 91.9%
if 1.60000000000000013e-4 < y < 1.1e30Initial program 90.3%
*-commutative90.3%
associate-*r/90.3%
distribute-rgt-out--90.3%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in y around 0 71.2%
*-commutative71.2%
associate-/r*80.8%
Simplified80.8%
if 1.1e30 < y Initial program 77.0%
distribute-rgt-out--82.0%
Simplified82.0%
Taylor expanded in y around inf 77.0%
*-commutative77.0%
Simplified77.0%
*-commutative77.0%
times-frac85.4%
Applied egg-rr85.4%
Final simplification79.9%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.3e-39)
(/ (* x 2.0) (* y z))
(if (<= y 6.8e-63)
(/ (* (/ x z) -2.0) t)
(if (<= y 1.22e-5)
(* (/ x z) (/ 2.0 y))
(if (<= y 5.5e+29) (* -2.0 (/ (/ x t) z)) (* (/ 2.0 z) (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.3e-39) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 6.8e-63) {
tmp = ((x / z) * -2.0) / t;
} else if (y <= 1.22e-5) {
tmp = (x / z) * (2.0 / y);
} else if (y <= 5.5e+29) {
tmp = -2.0 * ((x / 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 <= (-1.3d-39)) then
tmp = (x * 2.0d0) / (y * z)
else if (y <= 6.8d-63) then
tmp = ((x / z) * (-2.0d0)) / t
else if (y <= 1.22d-5) then
tmp = (x / z) * (2.0d0 / y)
else if (y <= 5.5d+29) then
tmp = (-2.0d0) * ((x / 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 <= -1.3e-39) {
tmp = (x * 2.0) / (y * z);
} else if (y <= 6.8e-63) {
tmp = ((x / z) * -2.0) / t;
} else if (y <= 1.22e-5) {
tmp = (x / z) * (2.0 / y);
} else if (y <= 5.5e+29) {
tmp = -2.0 * ((x / t) / z);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.3e-39: tmp = (x * 2.0) / (y * z) elif y <= 6.8e-63: tmp = ((x / z) * -2.0) / t elif y <= 1.22e-5: tmp = (x / z) * (2.0 / y) elif y <= 5.5e+29: tmp = -2.0 * ((x / t) / z) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.3e-39) tmp = Float64(Float64(x * 2.0) / Float64(y * z)); elseif (y <= 6.8e-63) tmp = Float64(Float64(Float64(x / z) * -2.0) / t); elseif (y <= 1.22e-5) tmp = Float64(Float64(x / z) * Float64(2.0 / y)); elseif (y <= 5.5e+29) tmp = Float64(-2.0 * Float64(Float64(x / 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 <= -1.3e-39) tmp = (x * 2.0) / (y * z); elseif (y <= 6.8e-63) tmp = ((x / z) * -2.0) / t; elseif (y <= 1.22e-5) tmp = (x / z) * (2.0 / y); elseif (y <= 5.5e+29) tmp = -2.0 * ((x / t) / z); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.3e-39], N[(N[(x * 2.0), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.8e-63], N[(N[(N[(x / z), $MachinePrecision] * -2.0), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[y, 1.22e-5], N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.5e+29], N[(-2.0 * N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{-39}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z}\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-63}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot -2}{t}\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+29}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -1.3e-39Initial program 92.6%
distribute-rgt-out--94.2%
Simplified94.2%
Taylor expanded in y around inf 76.1%
*-commutative76.1%
Simplified76.1%
if -1.3e-39 < y < 6.79999999999999997e-63Initial program 92.7%
*-commutative92.7%
associate-*r/92.7%
distribute-rgt-out--92.7%
associate-/r*94.4%
Simplified94.4%
Taylor expanded in y around 0 76.2%
*-commutative76.2%
associate-/r*75.6%
Simplified75.6%
*-commutative75.6%
associate-/l/76.2%
associate-*r/76.2%
*-commutative76.2%
times-frac77.7%
associate-*r/78.6%
Applied egg-rr78.6%
if 6.79999999999999997e-63 < y < 1.22000000000000001e-5Initial program 99.7%
distribute-rgt-out--99.7%
Simplified99.7%
times-frac100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 91.9%
if 1.22000000000000001e-5 < y < 5.5e29Initial program 90.3%
*-commutative90.3%
associate-*r/90.3%
distribute-rgt-out--90.3%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in y around 0 71.2%
*-commutative71.2%
associate-/r*80.8%
Simplified80.8%
if 5.5e29 < y Initial program 77.0%
distribute-rgt-out--82.0%
Simplified82.0%
Taylor expanded in y around inf 77.0%
*-commutative77.0%
Simplified77.0%
*-commutative77.0%
times-frac85.4%
Applied egg-rr85.4%
Final simplification80.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* -2.0 (/ (/ x t) z))))
(if (<= t -245000.0)
t_1
(if (<= t -1.7e-260)
(* (/ x z) (/ 2.0 y))
(if (<= t 0.0098) (* (/ 2.0 z) (/ x y)) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = -2.0 * ((x / t) / z);
double tmp;
if (t <= -245000.0) {
tmp = t_1;
} else if (t <= -1.7e-260) {
tmp = (x / z) * (2.0 / y);
} else if (t <= 0.0098) {
tmp = (2.0 / z) * (x / y);
} 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) :: tmp
t_1 = (-2.0d0) * ((x / t) / z)
if (t <= (-245000.0d0)) then
tmp = t_1
else if (t <= (-1.7d-260)) then
tmp = (x / z) * (2.0d0 / y)
else if (t <= 0.0098d0) then
tmp = (2.0d0 / z) * (x / y)
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 = -2.0 * ((x / t) / z);
double tmp;
if (t <= -245000.0) {
tmp = t_1;
} else if (t <= -1.7e-260) {
tmp = (x / z) * (2.0 / y);
} else if (t <= 0.0098) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -2.0 * ((x / t) / z) tmp = 0 if t <= -245000.0: tmp = t_1 elif t <= -1.7e-260: tmp = (x / z) * (2.0 / y) elif t <= 0.0098: tmp = (2.0 / z) * (x / y) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(-2.0 * Float64(Float64(x / t) / z)) tmp = 0.0 if (t <= -245000.0) tmp = t_1; elseif (t <= -1.7e-260) tmp = Float64(Float64(x / z) * Float64(2.0 / y)); elseif (t <= 0.0098) tmp = Float64(Float64(2.0 / z) * Float64(x / y)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -2.0 * ((x / t) / z); tmp = 0.0; if (t <= -245000.0) tmp = t_1; elseif (t <= -1.7e-260) tmp = (x / z) * (2.0 / y); elseif (t <= 0.0098) tmp = (2.0 / z) * (x / y); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-2.0 * N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -245000.0], t$95$1, If[LessEqual[t, -1.7e-260], N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 0.0098], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -2 \cdot \frac{\frac{x}{t}}{z}\\
\mathbf{if}\;t \leq -245000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq -1.7 \cdot 10^{-260}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\
\mathbf{elif}\;t \leq 0.0098:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if t < -245000 or 0.0097999999999999997 < t Initial program 86.7%
*-commutative86.7%
associate-*r/86.6%
distribute-rgt-out--89.8%
associate-/r*93.1%
Simplified93.1%
Taylor expanded in y around 0 72.8%
*-commutative72.8%
associate-/r*72.8%
Simplified72.8%
if -245000 < t < -1.6999999999999999e-260Initial program 92.4%
distribute-rgt-out--92.4%
Simplified92.4%
times-frac94.1%
Applied egg-rr94.1%
Taylor expanded in y around inf 82.2%
if -1.6999999999999999e-260 < t < 0.0097999999999999997Initial program 90.7%
distribute-rgt-out--90.7%
Simplified90.7%
Taylor expanded in y around inf 74.3%
*-commutative74.3%
Simplified74.3%
*-commutative74.3%
times-frac82.0%
Applied egg-rr82.0%
Final simplification77.4%
(FPCore (x y z t) :precision binary64 (if (or (<= x -1e+38) (not (<= x 2e+26))) (* (/ 2.0 z) (/ x y)) (* (/ x z) (/ 2.0 y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -1e+38) || !(x <= 2e+26)) {
tmp = (2.0 / z) * (x / y);
} 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 ((x <= (-1d+38)) .or. (.not. (x <= 2d+26))) then
tmp = (2.0d0 / z) * (x / y)
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 ((x <= -1e+38) || !(x <= 2e+26)) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = (x / z) * (2.0 / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -1e+38) or not (x <= 2e+26): tmp = (2.0 / z) * (x / y) else: tmp = (x / z) * (2.0 / y) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -1e+38) || !(x <= 2e+26)) tmp = Float64(Float64(2.0 / z) * Float64(x / y)); 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 ((x <= -1e+38) || ~((x <= 2e+26))) tmp = (2.0 / z) * (x / y); else tmp = (x / z) * (2.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -1e+38], N[Not[LessEqual[x, 2e+26]], $MachinePrecision]], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+38} \lor \neg \left(x \leq 2 \cdot 10^{+26}\right):\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\
\end{array}
\end{array}
if x < -9.99999999999999977e37 or 2.0000000000000001e26 < x Initial program 81.6%
distribute-rgt-out--83.4%
Simplified83.4%
Taylor expanded in y around inf 49.4%
*-commutative49.4%
Simplified49.4%
*-commutative49.4%
times-frac58.7%
Applied egg-rr58.7%
if -9.99999999999999977e37 < x < 2.0000000000000001e26Initial program 95.7%
distribute-rgt-out--97.1%
Simplified97.1%
times-frac97.1%
Applied egg-rr97.1%
Taylor expanded in y around inf 66.7%
Final simplification62.9%
(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 89.0%
*-commutative89.0%
associate-*r/89.0%
distribute-rgt-out--90.7%
associate-/r*92.1%
Simplified92.1%
Final simplification92.1%
(FPCore (x y z t) :precision binary64 (* (/ 2.0 z) (/ x y)))
double code(double x, double y, double z, double t) {
return (2.0 / z) * (x / y);
}
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)
end function
public static double code(double x, double y, double z, double t) {
return (2.0 / z) * (x / y);
}
def code(x, y, z, t): return (2.0 / z) * (x / y)
function code(x, y, z, t) return Float64(Float64(2.0 / z) * Float64(x / y)) end
function tmp = code(x, y, z, t) tmp = (2.0 / z) * (x / y); end
code[x_, y_, z_, t_] := N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{z} \cdot \frac{x}{y}
\end{array}
Initial program 89.0%
distribute-rgt-out--90.7%
Simplified90.7%
Taylor expanded in y around inf 55.5%
*-commutative55.5%
Simplified55.5%
*-commutative55.5%
times-frac56.5%
Applied egg-rr56.5%
Final simplification56.5%
(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 2023293
(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))))