
(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 7 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 (/ (* x 2.0) (- (* y z) (* z t)))))
(if (<= t_1 -5e-324)
(/ (* x 2.0) (* z (- y t)))
(if (<= t_1 4e-97)
(* 2.0 (/ (/ x z) (- y t)))
(* (/ 2.0 z) (/ x (- y t)))))))
double code(double x, double y, double z, double t) {
double t_1 = (x * 2.0) / ((y * z) - (z * t));
double tmp;
if (t_1 <= -5e-324) {
tmp = (x * 2.0) / (z * (y - t));
} else if (t_1 <= 4e-97) {
tmp = 2.0 * ((x / 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) :: t_1
real(8) :: tmp
t_1 = (x * 2.0d0) / ((y * z) - (z * t))
if (t_1 <= (-5d-324)) then
tmp = (x * 2.0d0) / (z * (y - t))
else if (t_1 <= 4d-97) then
tmp = 2.0d0 * ((x / 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 t_1 = (x * 2.0) / ((y * z) - (z * t));
double tmp;
if (t_1 <= -5e-324) {
tmp = (x * 2.0) / (z * (y - t));
} else if (t_1 <= 4e-97) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (2.0 / z) * (x / (y - t));
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * 2.0) / ((y * z) - (z * t)) tmp = 0 if t_1 <= -5e-324: tmp = (x * 2.0) / (z * (y - t)) elif t_1 <= 4e-97: tmp = 2.0 * ((x / z) / (y - t)) else: tmp = (2.0 / z) * (x / (y - t)) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(z * t))) tmp = 0.0 if (t_1 <= -5e-324) tmp = Float64(Float64(x * 2.0) / Float64(z * Float64(y - t))); elseif (t_1 <= 4e-97) tmp = Float64(2.0 * Float64(Float64(x / 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) t_1 = (x * 2.0) / ((y * z) - (z * t)); tmp = 0.0; if (t_1 <= -5e-324) tmp = (x * 2.0) / (z * (y - t)); elseif (t_1 <= 4e-97) tmp = 2.0 * ((x / z) / (y - t)); else tmp = (2.0 / z) * (x / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-324], N[(N[(x * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 4e-97], N[(2.0 * N[(N[(x / z), $MachinePrecision] / 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}
t_1 := \frac{x \cdot 2}{y \cdot z - z \cdot t}\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-324}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{elif}\;t_1 \leq 4 \cdot 10^{-97}:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -4.94066e-324Initial program 95.8%
distribute-rgt-out--97.9%
Simplified97.9%
if -4.94066e-324 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < 4.00000000000000014e-97Initial program 87.0%
*-commutative87.0%
associate-*r/86.9%
distribute-rgt-out--86.9%
associate-/r*98.9%
Simplified98.9%
if 4.00000000000000014e-97 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) Initial program 78.7%
*-commutative78.7%
distribute-rgt-out--87.0%
times-frac99.7%
Simplified99.7%
Final simplification98.7%
(FPCore (x y z t) :precision binary64 (if (or (<= (* x 2.0) -5e-178) (not (<= (* x 2.0) 1e-125))) (* (/ 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-178) || !((x * 2.0) <= 1e-125)) {
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-178)) .or. (.not. ((x * 2.0d0) <= 1d-125))) 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-178) || !((x * 2.0) <= 1e-125)) {
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-178) or not ((x * 2.0) <= 1e-125): 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-178) || !(Float64(x * 2.0) <= 1e-125)) 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-178) || ~(((x * 2.0) <= 1e-125))) 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-178], N[Not[LessEqual[N[(x * 2.0), $MachinePrecision], 1e-125]], $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^{-178} \lor \neg \left(x \cdot 2 \leq 10^{-125}\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) < -4.99999999999999976e-178 or 1.00000000000000001e-125 < (*.f64 x 2) Initial program 88.4%
*-commutative88.4%
distribute-rgt-out--90.6%
times-frac97.6%
Simplified97.6%
if -4.99999999999999976e-178 < (*.f64 x 2) < 1.00000000000000001e-125Initial program 88.0%
*-commutative88.0%
associate-*r/88.0%
distribute-rgt-out--92.2%
associate-/r*99.9%
Simplified99.9%
Final simplification98.3%
(FPCore (x y z t)
:precision binary64
(if (<= (* x 2.0) -5e+73)
(/ 2.0 (* z (/ (- y t) x)))
(if (<= (* x 2.0) 1e-125)
(* 2.0 (/ (/ x z) (- y t)))
(* (/ 2.0 z) (/ x (- y t))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * 2.0) <= -5e+73) {
tmp = 2.0 / (z * ((y - t) / x));
} else if ((x * 2.0) <= 1e-125) {
tmp = 2.0 * ((x / 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 ((x * 2.0d0) <= (-5d+73)) then
tmp = 2.0d0 / (z * ((y - t) / x))
else if ((x * 2.0d0) <= 1d-125) then
tmp = 2.0d0 * ((x / 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 ((x * 2.0) <= -5e+73) {
tmp = 2.0 / (z * ((y - t) / x));
} else if ((x * 2.0) <= 1e-125) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (2.0 / z) * (x / (y - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * 2.0) <= -5e+73: tmp = 2.0 / (z * ((y - t) / x)) elif (x * 2.0) <= 1e-125: tmp = 2.0 * ((x / z) / (y - t)) else: tmp = (2.0 / z) * (x / (y - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * 2.0) <= -5e+73) tmp = Float64(2.0 / Float64(z * Float64(Float64(y - t) / x))); elseif (Float64(x * 2.0) <= 1e-125) tmp = Float64(2.0 * Float64(Float64(x / 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 ((x * 2.0) <= -5e+73) tmp = 2.0 / (z * ((y - t) / x)); elseif ((x * 2.0) <= 1e-125) tmp = 2.0 * ((x / z) / (y - t)); else tmp = (2.0 / z) * (x / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * 2.0), $MachinePrecision], -5e+73], N[(2.0 / N[(z * N[(N[(y - t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 2.0), $MachinePrecision], 1e-125], N[(2.0 * N[(N[(x / z), $MachinePrecision] / 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}\;x \cdot 2 \leq -5 \cdot 10^{+73}:\\
\;\;\;\;\frac{2}{z \cdot \frac{y - t}{x}}\\
\mathbf{elif}\;x \cdot 2 \leq 10^{-125}:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\
\end{array}
\end{array}
if (*.f64 x 2) < -4.99999999999999976e73Initial program 75.0%
*-commutative75.0%
associate-*r/75.0%
distribute-rgt-out--77.5%
associate-/r*84.2%
Simplified84.2%
associate-/r*77.5%
associate-*r/77.5%
frac-times97.1%
clear-num97.1%
frac-times97.3%
metadata-eval97.3%
Applied egg-rr97.3%
if -4.99999999999999976e73 < (*.f64 x 2) < 1.00000000000000001e-125Initial program 89.9%
*-commutative89.9%
associate-*r/89.9%
distribute-rgt-out--93.7%
associate-/r*97.7%
Simplified97.7%
if 1.00000000000000001e-125 < (*.f64 x 2) Initial program 92.7%
*-commutative92.7%
distribute-rgt-out--93.8%
times-frac99.7%
Simplified99.7%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.05e-66) (not (<= y 4.8e+26))) (* (/ 2.0 z) (/ x y)) (* (/ x z) (/ -2.0 t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.05e-66) || !(y <= 4.8e+26)) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = (x / z) * (-2.0 / 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 <= (-1.05d-66)) .or. (.not. (y <= 4.8d+26))) then
tmp = (2.0d0 / z) * (x / y)
else
tmp = (x / z) * ((-2.0d0) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.05e-66) || !(y <= 4.8e+26)) {
tmp = (2.0 / z) * (x / y);
} else {
tmp = (x / z) * (-2.0 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.05e-66) or not (y <= 4.8e+26): tmp = (2.0 / z) * (x / y) else: tmp = (x / z) * (-2.0 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.05e-66) || !(y <= 4.8e+26)) tmp = Float64(Float64(2.0 / z) * Float64(x / y)); else tmp = Float64(Float64(x / z) * Float64(-2.0 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.05e-66) || ~((y <= 4.8e+26))) tmp = (2.0 / z) * (x / y); else tmp = (x / z) * (-2.0 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.05e-66], N[Not[LessEqual[y, 4.8e+26]], $MachinePrecision]], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(-2.0 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{-66} \lor \neg \left(y \leq 4.8 \cdot 10^{+26}\right):\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{-2}{t}\\
\end{array}
\end{array}
if y < -1.05e-66 or 4.80000000000000009e26 < y Initial program 87.0%
distribute-rgt-out--90.0%
Simplified90.0%
Taylor expanded in y around inf 73.1%
*-commutative73.1%
Simplified73.1%
*-commutative73.1%
times-frac74.9%
Applied egg-rr74.9%
if -1.05e-66 < y < 4.80000000000000009e26Initial program 89.6%
*-commutative89.6%
associate-*r/89.6%
distribute-rgt-out--92.1%
associate-/r*94.9%
Simplified94.9%
associate-*r/94.2%
*-commutative94.2%
associate-*r/94.9%
clear-num94.4%
frac-times93.1%
metadata-eval93.1%
Applied egg-rr93.1%
Taylor expanded in y around 0 79.4%
associate-*r/79.4%
times-frac81.3%
*-commutative81.3%
Simplified81.3%
Final simplification78.0%
(FPCore (x y z t) :precision binary64 (if (<= y -2.45e-64) (* (/ x z) (/ 2.0 y)) (if (<= y 4.4e+32) (* (/ x z) (/ -2.0 t)) (* (/ 2.0 z) (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.45e-64) {
tmp = (x / z) * (2.0 / y);
} else if (y <= 4.4e+32) {
tmp = (x / z) * (-2.0 / 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 <= (-2.45d-64)) then
tmp = (x / z) * (2.0d0 / y)
else if (y <= 4.4d+32) then
tmp = (x / z) * ((-2.0d0) / 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 <= -2.45e-64) {
tmp = (x / z) * (2.0 / y);
} else if (y <= 4.4e+32) {
tmp = (x / z) * (-2.0 / t);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.45e-64: tmp = (x / z) * (2.0 / y) elif y <= 4.4e+32: tmp = (x / z) * (-2.0 / t) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.45e-64) tmp = Float64(Float64(x / z) * Float64(2.0 / y)); elseif (y <= 4.4e+32) tmp = Float64(Float64(x / z) * Float64(-2.0 / 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 <= -2.45e-64) tmp = (x / z) * (2.0 / y); elseif (y <= 4.4e+32) tmp = (x / z) * (-2.0 / t); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.45e-64], N[(N[(x / z), $MachinePrecision] * N[(2.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.4e+32], N[(N[(x / z), $MachinePrecision] * N[(-2.0 / t), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \cdot 10^{-64}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y}\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+32}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{-2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -2.4500000000000001e-64Initial program 86.6%
distribute-rgt-out--90.4%
Simplified90.4%
Taylor expanded in y around inf 71.1%
*-commutative71.1%
Simplified71.1%
times-frac71.9%
Applied egg-rr71.9%
if -2.4500000000000001e-64 < y < 4.40000000000000002e32Initial program 89.6%
*-commutative89.6%
associate-*r/89.6%
distribute-rgt-out--92.1%
associate-/r*94.9%
Simplified94.9%
associate-*r/94.2%
*-commutative94.2%
associate-*r/94.9%
clear-num94.4%
frac-times93.1%
metadata-eval93.1%
Applied egg-rr93.1%
Taylor expanded in y around 0 79.4%
associate-*r/79.4%
times-frac81.3%
*-commutative81.3%
Simplified81.3%
if 4.40000000000000002e32 < y Initial program 87.6%
distribute-rgt-out--89.6%
Simplified89.6%
Taylor expanded in y around inf 75.8%
*-commutative75.8%
Simplified75.8%
*-commutative75.8%
times-frac80.8%
Applied egg-rr80.8%
Final simplification78.4%
(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 88.3%
*-commutative88.3%
associate-*r/88.3%
distribute-rgt-out--91.0%
associate-/r*92.6%
Simplified92.6%
Final simplification92.6%
(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 88.3%
distribute-rgt-out--91.1%
Simplified91.1%
Taylor expanded in y around inf 49.5%
*-commutative49.5%
Simplified49.5%
*-commutative49.5%
times-frac51.0%
Applied egg-rr51.0%
Final simplification51.0%
(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 2023297
(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))))