
(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 (- INFINITY)) (not (<= t_1 5e+301)))
(* 2.0 (/ (/ x 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 <= -((double) INFINITY)) || !(t_1 <= 5e+301)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (2.0 * x) / (z * (y - t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (y * z) - (z * t);
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+301)) {
tmp = 2.0 * ((x / 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 <= -math.inf) or not (t_1 <= 5e+301): tmp = 2.0 * ((x / 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 <= Float64(-Inf)) || !(t_1 <= 5e+301)) tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); else tmp = Float64(Float64(2.0 * x) / Float64(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 <= -Inf) || ~((t_1 <= 5e+301))) tmp = 2.0 * ((x / 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[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+301]], $MachinePrecision]], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * x), $MachinePrecision] / N[(z * 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 -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+301}\right):\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{z \cdot \left(y - t\right)}\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < -inf.0 or 5.0000000000000004e301 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 57.1%
associate-*l/57.1%
*-commutative57.1%
distribute-rgt-out--63.6%
associate-/r*99.9%
Simplified99.9%
if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < 5.0000000000000004e301Initial program 97.3%
distribute-rgt-out--98.3%
Simplified98.3%
Final simplification98.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -2.8e-18) (not (<= z 50000.0))) (* 2.0 (/ (/ x z) (- y t))) (* x (/ 2.0 (* z (- y t))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.8e-18) || !(z <= 50000.0)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = x * (2.0 / (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 ((z <= (-2.8d-18)) .or. (.not. (z <= 50000.0d0))) then
tmp = 2.0d0 * ((x / z) / (y - t))
else
tmp = x * (2.0d0 / (z * (y - t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -2.8e-18) || !(z <= 50000.0)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = x * (2.0 / (z * (y - t)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -2.8e-18) or not (z <= 50000.0): tmp = 2.0 * ((x / z) / (y - t)) else: tmp = x * (2.0 / (z * (y - t))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -2.8e-18) || !(z <= 50000.0)) tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); else tmp = Float64(x * Float64(2.0 / Float64(z * Float64(y - t)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -2.8e-18) || ~((z <= 50000.0))) tmp = 2.0 * ((x / z) / (y - t)); else tmp = x * (2.0 / (z * (y - t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -2.8e-18], N[Not[LessEqual[z, 50000.0]], $MachinePrecision]], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(2.0 / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-18} \lor \neg \left(z \leq 50000\right):\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{2}{z \cdot \left(y - t\right)}\\
\end{array}
\end{array}
if z < -2.80000000000000012e-18 or 5e4 < z Initial program 82.4%
associate-*l/82.3%
*-commutative82.3%
distribute-rgt-out--85.0%
associate-/r*96.0%
Simplified96.0%
if -2.80000000000000012e-18 < z < 5e4Initial program 96.0%
associate-*r/95.8%
distribute-rgt-out--97.3%
Simplified97.3%
Final simplification96.7%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.8e+98) (not (<= z 1.05e-33))) (* 2.0 (/ (/ x z) (- y t))) (* x (/ (/ -2.0 (- t y)) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.8e+98) || !(z <= 1.05e-33)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = x * ((-2.0 / (t - 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 ((z <= (-3.8d+98)) .or. (.not. (z <= 1.05d-33))) then
tmp = 2.0d0 * ((x / z) / (y - t))
else
tmp = x * (((-2.0d0) / (t - y)) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.8e+98) || !(z <= 1.05e-33)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = x * ((-2.0 / (t - y)) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.8e+98) or not (z <= 1.05e-33): tmp = 2.0 * ((x / z) / (y - t)) else: tmp = x * ((-2.0 / (t - y)) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.8e+98) || !(z <= 1.05e-33)) tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); else tmp = Float64(x * Float64(Float64(-2.0 / Float64(t - y)) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.8e+98) || ~((z <= 1.05e-33))) tmp = 2.0 * ((x / z) / (y - t)); else tmp = x * ((-2.0 / (t - y)) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.8e+98], N[Not[LessEqual[z, 1.05e-33]], $MachinePrecision]], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-2.0 / N[(t - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+98} \lor \neg \left(z \leq 1.05 \cdot 10^{-33}\right):\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{t - y}}{z}\\
\end{array}
\end{array}
if z < -3.7999999999999999e98 or 1.05e-33 < z Initial program 79.6%
associate-*l/79.6%
*-commutative79.6%
distribute-rgt-out--82.6%
associate-/r*95.5%
Simplified95.5%
if -3.7999999999999999e98 < z < 1.05e-33Initial program 96.4%
associate-*r/96.2%
distribute-rgt-out--97.6%
associate-/l/97.7%
sub-neg97.7%
+-commutative97.7%
neg-sub097.7%
associate-+l-97.7%
sub0-neg97.7%
neg-mul-197.7%
associate-/r*97.7%
metadata-eval97.7%
Simplified97.7%
Final simplification96.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.3e+96) (not (<= z 0.00047))) (* (/ x (- y t)) (/ 2.0 z)) (* x (/ (/ -2.0 (- t y)) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.3e+96) || !(z <= 0.00047)) {
tmp = (x / (y - t)) * (2.0 / z);
} else {
tmp = x * ((-2.0 / (t - 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 ((z <= (-1.3d+96)) .or. (.not. (z <= 0.00047d0))) then
tmp = (x / (y - t)) * (2.0d0 / z)
else
tmp = x * (((-2.0d0) / (t - y)) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.3e+96) || !(z <= 0.00047)) {
tmp = (x / (y - t)) * (2.0 / z);
} else {
tmp = x * ((-2.0 / (t - y)) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.3e+96) or not (z <= 0.00047): tmp = (x / (y - t)) * (2.0 / z) else: tmp = x * ((-2.0 / (t - y)) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.3e+96) || !(z <= 0.00047)) tmp = Float64(Float64(x / Float64(y - t)) * Float64(2.0 / z)); else tmp = Float64(x * Float64(Float64(-2.0 / Float64(t - y)) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.3e+96) || ~((z <= 0.00047))) tmp = (x / (y - t)) * (2.0 / z); else tmp = x * ((-2.0 / (t - y)) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.3e+96], N[Not[LessEqual[z, 0.00047]], $MachinePrecision]], N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-2.0 / N[(t - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+96} \lor \neg \left(z \leq 0.00047\right):\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{t - y}}{z}\\
\end{array}
\end{array}
if z < -1.3e96 or 4.69999999999999986e-4 < z Initial program 78.2%
distribute-rgt-out--81.4%
Simplified81.4%
*-commutative81.4%
times-frac95.8%
Applied egg-rr95.8%
if -1.3e96 < z < 4.69999999999999986e-4Initial program 96.5%
associate-*r/96.4%
distribute-rgt-out--97.7%
associate-/l/97.8%
sub-neg97.8%
+-commutative97.8%
neg-sub097.8%
associate-+l-97.8%
sub0-neg97.8%
neg-mul-197.8%
associate-/r*97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification97.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.1e-14) (not (<= y 7.1e-81))) (* x (/ (/ 2.0 y) z)) (* x (/ (/ -2.0 z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.1e-14) || !(y <= 7.1e-81)) {
tmp = x * ((2.0 / y) / z);
} 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 ((y <= (-1.1d-14)) .or. (.not. (y <= 7.1d-81))) then
tmp = x * ((2.0d0 / y) / z)
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 ((y <= -1.1e-14) || !(y <= 7.1e-81)) {
tmp = x * ((2.0 / y) / z);
} else {
tmp = x * ((-2.0 / z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.1e-14) or not (y <= 7.1e-81): tmp = x * ((2.0 / y) / z) else: tmp = x * ((-2.0 / z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.1e-14) || !(y <= 7.1e-81)) tmp = Float64(x * Float64(Float64(2.0 / y) / z)); 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 ((y <= -1.1e-14) || ~((y <= 7.1e-81))) tmp = x * ((2.0 / y) / z); else tmp = x * ((-2.0 / z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.1e-14], N[Not[LessEqual[y, 7.1e-81]], $MachinePrecision]], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{-14} \lor \neg \left(y \leq 7.1 \cdot 10^{-81}\right):\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\
\end{array}
\end{array}
if y < -1.1e-14 or 7.10000000000000019e-81 < y Initial program 88.2%
associate-*r/88.1%
distribute-rgt-out--90.3%
associate-/l/91.3%
sub-neg91.3%
+-commutative91.3%
neg-sub091.3%
associate-+l-91.3%
sub0-neg91.3%
neg-mul-191.3%
associate-/r*91.3%
metadata-eval91.3%
Simplified91.3%
Taylor expanded in t around 0 79.6%
if -1.1e-14 < y < 7.10000000000000019e-81Initial program 91.1%
associate-*l/91.0%
*-commutative91.0%
distribute-rgt-out--93.0%
associate-/r*88.6%
Simplified88.6%
Taylor expanded in x around 0 93.0%
associate-*r/93.0%
*-commutative93.0%
times-frac90.5%
associate-*l/88.6%
associate-*r/93.0%
Simplified93.0%
Taylor expanded in y around 0 81.6%
*-commutative81.6%
associate-/r*81.8%
Simplified81.8%
Final simplification80.5%
(FPCore (x y z t) :precision binary64 (if (<= y -2.7e-17) (* x (/ (/ 2.0 y) z)) (if (<= y 7e-86) (* x (/ (/ -2.0 z) t)) (* (/ 2.0 z) (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.7e-17) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 7e-86) {
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 (y <= (-2.7d-17)) then
tmp = x * ((2.0d0 / y) / z)
else if (y <= 7d-86) 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 (y <= -2.7e-17) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 7e-86) {
tmp = x * ((-2.0 / z) / t);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.7e-17: tmp = x * ((2.0 / y) / z) elif y <= 7e-86: 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 (y <= -2.7e-17) tmp = Float64(x * Float64(Float64(2.0 / y) / z)); elseif (y <= 7e-86) 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 (y <= -2.7e-17) tmp = x * ((2.0 / y) / z); elseif (y <= 7e-86) tmp = x * ((-2.0 / z) / t); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.7e-17], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-86], 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}\;y \leq -2.7 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-86}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{z}}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -2.7000000000000001e-17Initial program 90.7%
associate-*r/90.6%
distribute-rgt-out--92.2%
associate-/l/93.3%
sub-neg93.3%
+-commutative93.3%
neg-sub093.3%
associate-+l-93.3%
sub0-neg93.3%
neg-mul-193.3%
associate-/r*93.3%
metadata-eval93.3%
Simplified93.3%
Taylor expanded in t around 0 78.4%
if -2.7000000000000001e-17 < y < 7.00000000000000041e-86Initial program 91.1%
associate-*l/91.0%
*-commutative91.0%
distribute-rgt-out--93.0%
associate-/r*88.6%
Simplified88.6%
Taylor expanded in x around 0 93.0%
associate-*r/93.0%
*-commutative93.0%
times-frac90.5%
associate-*l/88.6%
associate-*r/93.0%
Simplified93.0%
Taylor expanded in y around 0 81.6%
*-commutative81.6%
associate-/r*81.8%
Simplified81.8%
if 7.00000000000000041e-86 < y Initial program 86.3%
distribute-rgt-out--88.9%
Simplified88.9%
Taylor expanded in y around inf 79.6%
times-frac81.9%
Applied egg-rr81.9%
Final simplification81.0%
(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.4%
associate-*l/89.4%
*-commutative89.4%
distribute-rgt-out--91.5%
associate-/r*90.3%
Simplified90.3%
Final simplification90.3%
(FPCore (x y z t) :precision binary64 (* -2.0 (/ x (* z t))))
double code(double x, double y, double z, double t) {
return -2.0 * (x / (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 = (-2.0d0) * (x / (z * t))
end function
public static double code(double x, double y, double z, double t) {
return -2.0 * (x / (z * t));
}
def code(x, y, z, t): return -2.0 * (x / (z * t))
function code(x, y, z, t) return Float64(-2.0 * Float64(x / Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = -2.0 * (x / (z * t)); end
code[x_, y_, z_, t_] := N[(-2.0 * N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \frac{x}{z \cdot t}
\end{array}
Initial program 89.4%
associate-*r/89.3%
distribute-rgt-out--91.4%
associate-/l/92.0%
sub-neg92.0%
+-commutative92.0%
neg-sub092.0%
associate-+l-92.0%
sub0-neg92.0%
neg-mul-192.0%
associate-/r*92.0%
metadata-eval92.0%
Simplified92.0%
Taylor expanded in t around inf 51.0%
Final simplification51.0%
(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 89.4%
associate-*r/89.3%
distribute-rgt-out--91.4%
associate-/l/92.0%
sub-neg92.0%
+-commutative92.0%
neg-sub092.0%
associate-+l-92.0%
sub0-neg92.0%
neg-mul-192.0%
associate-/r*92.0%
metadata-eval92.0%
Simplified92.0%
Taylor expanded in t around inf 51.0%
Final simplification51.0%
(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 89.4%
associate-*l/89.4%
*-commutative89.4%
distribute-rgt-out--91.5%
associate-/r*90.3%
Simplified90.3%
Taylor expanded in x around 0 91.5%
associate-*r/91.5%
*-commutative91.5%
times-frac91.5%
associate-*l/90.2%
associate-*r/92.0%
Simplified92.0%
Taylor expanded in y around 0 51.0%
*-commutative51.0%
associate-/r*51.1%
Simplified51.1%
Final simplification51.1%
(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 2023224
(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))))