
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (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 / (y - (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (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 / (y - (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) (- INFINITY)) (* (/ -1.0 t) (/ x z)) (if (<= (* z t) 1e+189) (/ x (fma z (- t) y)) (/ (/ (- x) z) t))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = (-1.0 / t) * (x / z);
} else if ((z * t) <= 1e+189) {
tmp = x / fma(z, -t, y);
} else {
tmp = (-x / z) / t;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = Float64(Float64(-1.0 / t) * Float64(x / z)); elseif (Float64(z * t) <= 1e+189) tmp = Float64(x / fma(z, Float64(-t), y)); else tmp = Float64(Float64(Float64(-x) / z) / t); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(N[(-1.0 / t), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+189], N[(x / N[(z * (-t) + y), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\
\mathbf{elif}\;z \cdot t \leq 10^{+189}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(z, -t, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{z}}{t}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 41.7%
Taylor expanded in y around 0 41.7%
associate-*r/41.7%
neg-mul-141.7%
Simplified41.7%
neg-mul-141.7%
times-frac99.8%
Applied egg-rr99.8%
if -inf.0 < (*.f64 z t) < 1e189Initial program 99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-out99.9%
fma-def99.9%
Simplified99.9%
if 1e189 < (*.f64 z t) Initial program 81.5%
Taylor expanded in y around 0 81.5%
associate-*r/81.5%
neg-mul-181.5%
Simplified81.5%
neg-mul-181.5%
times-frac97.0%
Applied egg-rr97.0%
frac-times81.5%
*-commutative81.5%
frac-times96.5%
associate-*r/96.7%
Applied egg-rr96.7%
Taylor expanded in z around 0 96.8%
neg-mul-196.8%
distribute-frac-neg96.8%
Simplified96.8%
Final simplification99.5%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (/ (- x) z) t)))
(if (<= t -1.2e-30)
t_1
(if (<= t 9.5e+26)
(/ x y)
(if (<= t 1.45e+75)
(/ (- (/ x t)) z)
(if (<= t 4.4e+118)
(/ x y)
(if (<= t 5.5e+147)
t_1
(if (<= t 1.95e+176) (/ x y) (/ -1.0 (* t (/ z x)))))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = (-x / z) / t;
double tmp;
if (t <= -1.2e-30) {
tmp = t_1;
} else if (t <= 9.5e+26) {
tmp = x / y;
} else if (t <= 1.45e+75) {
tmp = -(x / t) / z;
} else if (t <= 4.4e+118) {
tmp = x / y;
} else if (t <= 5.5e+147) {
tmp = t_1;
} else if (t <= 1.95e+176) {
tmp = x / y;
} else {
tmp = -1.0 / (t * (z / x));
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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) / t
if (t <= (-1.2d-30)) then
tmp = t_1
else if (t <= 9.5d+26) then
tmp = x / y
else if (t <= 1.45d+75) then
tmp = -(x / t) / z
else if (t <= 4.4d+118) then
tmp = x / y
else if (t <= 5.5d+147) then
tmp = t_1
else if (t <= 1.95d+176) then
tmp = x / y
else
tmp = (-1.0d0) / (t * (z / x))
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = (-x / z) / t;
double tmp;
if (t <= -1.2e-30) {
tmp = t_1;
} else if (t <= 9.5e+26) {
tmp = x / y;
} else if (t <= 1.45e+75) {
tmp = -(x / t) / z;
} else if (t <= 4.4e+118) {
tmp = x / y;
} else if (t <= 5.5e+147) {
tmp = t_1;
} else if (t <= 1.95e+176) {
tmp = x / y;
} else {
tmp = -1.0 / (t * (z / x));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = (-x / z) / t tmp = 0 if t <= -1.2e-30: tmp = t_1 elif t <= 9.5e+26: tmp = x / y elif t <= 1.45e+75: tmp = -(x / t) / z elif t <= 4.4e+118: tmp = x / y elif t <= 5.5e+147: tmp = t_1 elif t <= 1.95e+176: tmp = x / y else: tmp = -1.0 / (t * (z / x)) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(Float64(Float64(-x) / z) / t) tmp = 0.0 if (t <= -1.2e-30) tmp = t_1; elseif (t <= 9.5e+26) tmp = Float64(x / y); elseif (t <= 1.45e+75) tmp = Float64(Float64(-Float64(x / t)) / z); elseif (t <= 4.4e+118) tmp = Float64(x / y); elseif (t <= 5.5e+147) tmp = t_1; elseif (t <= 1.95e+176) tmp = Float64(x / y); else tmp = Float64(-1.0 / Float64(t * Float64(z / x))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = (-x / z) / t;
tmp = 0.0;
if (t <= -1.2e-30)
tmp = t_1;
elseif (t <= 9.5e+26)
tmp = x / y;
elseif (t <= 1.45e+75)
tmp = -(x / t) / z;
elseif (t <= 4.4e+118)
tmp = x / y;
elseif (t <= 5.5e+147)
tmp = t_1;
elseif (t <= 1.95e+176)
tmp = x / y;
else
tmp = -1.0 / (t * (z / x));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[t, -1.2e-30], t$95$1, If[LessEqual[t, 9.5e+26], N[(x / y), $MachinePrecision], If[LessEqual[t, 1.45e+75], N[((-N[(x / t), $MachinePrecision]) / z), $MachinePrecision], If[LessEqual[t, 4.4e+118], N[(x / y), $MachinePrecision], If[LessEqual[t, 5.5e+147], t$95$1, If[LessEqual[t, 1.95e+176], N[(x / y), $MachinePrecision], N[(-1.0 / N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \frac{\frac{-x}{z}}{t}\\
\mathbf{if}\;t \leq -1.2 \cdot 10^{-30}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq 9.5 \cdot 10^{+26}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t \leq 1.45 \cdot 10^{+75}:\\
\;\;\;\;\frac{-\frac{x}{t}}{z}\\
\mathbf{elif}\;t \leq 4.4 \cdot 10^{+118}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;t \leq 5.5 \cdot 10^{+147}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq 1.95 \cdot 10^{+176}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{t \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if t < -1.19999999999999992e-30 or 4.39999999999999972e118 < t < 5.4999999999999997e147Initial program 96.2%
Taylor expanded in y around 0 65.4%
associate-*r/65.4%
neg-mul-165.4%
Simplified65.4%
neg-mul-165.4%
times-frac66.5%
Applied egg-rr66.5%
frac-times65.4%
*-commutative65.4%
frac-times72.1%
associate-*r/66.4%
Applied egg-rr66.4%
Taylor expanded in z around 0 66.5%
neg-mul-166.5%
distribute-frac-neg66.5%
Simplified66.5%
if -1.19999999999999992e-30 < t < 9.50000000000000054e26 or 1.4499999999999999e75 < t < 4.39999999999999972e118 or 5.4999999999999997e147 < t < 1.9500000000000001e176Initial program 99.9%
Taylor expanded in y around inf 71.0%
if 9.50000000000000054e26 < t < 1.4499999999999999e75Initial program 99.7%
Taylor expanded in y around 0 89.8%
mul-1-neg89.8%
associate-/r*90.0%
distribute-neg-frac90.0%
Simplified90.0%
if 1.9500000000000001e176 < t Initial program 75.6%
Taylor expanded in y around 0 67.8%
associate-*r/67.8%
neg-mul-167.8%
Simplified67.8%
neg-mul-167.8%
times-frac84.2%
Applied egg-rr84.2%
*-commutative84.2%
clear-num84.1%
frac-times83.0%
metadata-eval83.0%
Applied egg-rr83.0%
Final simplification71.8%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (/ (- x) z) t)))
(if (<= z -4.8e+122)
t_1
(if (<= z -4.2e+112)
(/ x y)
(if (<= z -14500000000.0)
t_1
(if (<= z 8.2e-103) (/ x y) (* (/ -1.0 t) (/ x z))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = (-x / z) / t;
double tmp;
if (z <= -4.8e+122) {
tmp = t_1;
} else if (z <= -4.2e+112) {
tmp = x / y;
} else if (z <= -14500000000.0) {
tmp = t_1;
} else if (z <= 8.2e-103) {
tmp = x / y;
} else {
tmp = (-1.0 / t) * (x / z);
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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) / t
if (z <= (-4.8d+122)) then
tmp = t_1
else if (z <= (-4.2d+112)) then
tmp = x / y
else if (z <= (-14500000000.0d0)) then
tmp = t_1
else if (z <= 8.2d-103) then
tmp = x / y
else
tmp = ((-1.0d0) / t) * (x / z)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = (-x / z) / t;
double tmp;
if (z <= -4.8e+122) {
tmp = t_1;
} else if (z <= -4.2e+112) {
tmp = x / y;
} else if (z <= -14500000000.0) {
tmp = t_1;
} else if (z <= 8.2e-103) {
tmp = x / y;
} else {
tmp = (-1.0 / t) * (x / z);
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = (-x / z) / t tmp = 0 if z <= -4.8e+122: tmp = t_1 elif z <= -4.2e+112: tmp = x / y elif z <= -14500000000.0: tmp = t_1 elif z <= 8.2e-103: tmp = x / y else: tmp = (-1.0 / t) * (x / z) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(Float64(Float64(-x) / z) / t) tmp = 0.0 if (z <= -4.8e+122) tmp = t_1; elseif (z <= -4.2e+112) tmp = Float64(x / y); elseif (z <= -14500000000.0) tmp = t_1; elseif (z <= 8.2e-103) tmp = Float64(x / y); else tmp = Float64(Float64(-1.0 / t) * Float64(x / z)); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = (-x / z) / t;
tmp = 0.0;
if (z <= -4.8e+122)
tmp = t_1;
elseif (z <= -4.2e+112)
tmp = x / y;
elseif (z <= -14500000000.0)
tmp = t_1;
elseif (z <= 8.2e-103)
tmp = x / y;
else
tmp = (-1.0 / t) * (x / z);
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[z, -4.8e+122], t$95$1, If[LessEqual[z, -4.2e+112], N[(x / y), $MachinePrecision], If[LessEqual[z, -14500000000.0], t$95$1, If[LessEqual[z, 8.2e-103], N[(x / y), $MachinePrecision], N[(N[(-1.0 / t), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \frac{\frac{-x}{z}}{t}\\
\mathbf{if}\;z \leq -4.8 \cdot 10^{+122}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -4.2 \cdot 10^{+112}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;z \leq -14500000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{-103}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -4.8000000000000004e122 or -4.1999999999999998e112 < z < -1.45e10Initial program 93.1%
Taylor expanded in y around 0 72.6%
associate-*r/72.6%
neg-mul-172.6%
Simplified72.6%
neg-mul-172.6%
times-frac75.5%
Applied egg-rr75.5%
frac-times72.6%
*-commutative72.6%
frac-times72.3%
associate-*r/75.5%
Applied egg-rr75.5%
Taylor expanded in z around 0 75.6%
neg-mul-175.6%
distribute-frac-neg75.6%
Simplified75.6%
if -4.8000000000000004e122 < z < -4.1999999999999998e112 or -1.45e10 < z < 8.19999999999999992e-103Initial program 99.9%
Taylor expanded in y around inf 74.9%
if 8.19999999999999992e-103 < z Initial program 92.0%
Taylor expanded in y around 0 59.2%
associate-*r/59.2%
neg-mul-159.2%
Simplified59.2%
neg-mul-159.2%
times-frac61.2%
Applied egg-rr61.2%
Final simplification70.5%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (or (<= y -2.7e+18)
(and (not (<= y 1.1e-79)) (or (<= y 1.9e-20) (not (<= y 5.8e+45)))))
(/ x y)
(/ (- x) (* z t))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.7e+18) || (!(y <= 1.1e-79) && ((y <= 1.9e-20) || !(y <= 5.8e+45)))) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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+18)) .or. (.not. (y <= 1.1d-79)) .and. (y <= 1.9d-20) .or. (.not. (y <= 5.8d+45))) then
tmp = x / y
else
tmp = -x / (z * t)
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.7e+18) || (!(y <= 1.1e-79) && ((y <= 1.9e-20) || !(y <= 5.8e+45)))) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (y <= -2.7e+18) or (not (y <= 1.1e-79) and ((y <= 1.9e-20) or not (y <= 5.8e+45))): tmp = x / y else: tmp = -x / (z * t) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((y <= -2.7e+18) || (!(y <= 1.1e-79) && ((y <= 1.9e-20) || !(y <= 5.8e+45)))) tmp = Float64(x / y); else tmp = Float64(Float64(-x) / Float64(z * t)); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((y <= -2.7e+18) || (~((y <= 1.1e-79)) && ((y <= 1.9e-20) || ~((y <= 5.8e+45)))))
tmp = x / y;
else
tmp = -x / (z * t);
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.7e+18], And[N[Not[LessEqual[y, 1.1e-79]], $MachinePrecision], Or[LessEqual[y, 1.9e-20], N[Not[LessEqual[y, 5.8e+45]], $MachinePrecision]]]], N[(x / y), $MachinePrecision], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+18} \lor \neg \left(y \leq 1.1 \cdot 10^{-79}\right) \land \left(y \leq 1.9 \cdot 10^{-20} \lor \neg \left(y \leq 5.8 \cdot 10^{+45}\right)\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\end{array}
\end{array}
if y < -2.7e18 or 1.0999999999999999e-79 < y < 1.8999999999999999e-20 or 5.7999999999999994e45 < y Initial program 93.3%
Taylor expanded in y around inf 78.6%
if -2.7e18 < y < 1.0999999999999999e-79 or 1.8999999999999999e-20 < y < 5.7999999999999994e45Initial program 98.3%
Taylor expanded in y around 0 73.6%
associate-*r/73.6%
neg-mul-173.6%
Simplified73.6%
Final simplification76.1%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (or (<= z -4.8e+122)
(not
(or (<= z -4.2e+112)
(and (not (<= z -520000000000.0)) (<= z 9e-103)))))
(/ (/ (- x) z) t)
(/ x y)))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.8e+122) || !((z <= -4.2e+112) || (!(z <= -520000000000.0) && (z <= 9e-103)))) {
tmp = (-x / z) / t;
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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 <= (-4.8d+122)) .or. (.not. (z <= (-4.2d+112)) .or. (.not. (z <= (-520000000000.0d0))) .and. (z <= 9d-103))) then
tmp = (-x / z) / t
else
tmp = x / y
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.8e+122) || !((z <= -4.2e+112) || (!(z <= -520000000000.0) && (z <= 9e-103)))) {
tmp = (-x / z) / t;
} else {
tmp = x / y;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (z <= -4.8e+122) or not ((z <= -4.2e+112) or (not (z <= -520000000000.0) and (z <= 9e-103))): tmp = (-x / z) / t else: tmp = x / y return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((z <= -4.8e+122) || !((z <= -4.2e+112) || (!(z <= -520000000000.0) && (z <= 9e-103)))) tmp = Float64(Float64(Float64(-x) / z) / t); else tmp = Float64(x / y); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z <= -4.8e+122) || ~(((z <= -4.2e+112) || (~((z <= -520000000000.0)) && (z <= 9e-103)))))
tmp = (-x / z) / t;
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[z, -4.8e+122], N[Not[Or[LessEqual[z, -4.2e+112], And[N[Not[LessEqual[z, -520000000000.0]], $MachinePrecision], LessEqual[z, 9e-103]]]], $MachinePrecision]], N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+122} \lor \neg \left(z \leq -4.2 \cdot 10^{+112} \lor \neg \left(z \leq -520000000000\right) \land z \leq 9 \cdot 10^{-103}\right):\\
\;\;\;\;\frac{\frac{-x}{z}}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if z < -4.8000000000000004e122 or -4.1999999999999998e112 < z < -5.2e11 or 9e-103 < z Initial program 92.4%
Taylor expanded in y around 0 64.6%
associate-*r/64.6%
neg-mul-164.6%
Simplified64.6%
neg-mul-164.6%
times-frac67.0%
Applied egg-rr67.0%
frac-times64.6%
*-commutative64.6%
frac-times69.0%
associate-*r/66.9%
Applied egg-rr66.9%
Taylor expanded in z around 0 66.9%
neg-mul-166.9%
distribute-frac-neg66.9%
Simplified66.9%
if -4.8000000000000004e122 < z < -4.1999999999999998e112 or -5.2e11 < z < 9e-103Initial program 99.9%
Taylor expanded in y around inf 74.9%
Final simplification70.5%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) (- INFINITY)) (* (/ -1.0 t) (/ x z)) (if (<= (* z t) 1e+189) (/ x (- y (* z t))) (/ (/ (- x) z) t))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = (-1.0 / t) * (x / z);
} else if ((z * t) <= 1e+189) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / z) / t;
}
return tmp;
}
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = (-1.0 / t) * (x / z);
} else if ((z * t) <= 1e+189) {
tmp = x / (y - (z * t));
} else {
tmp = (-x / z) / t;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -math.inf: tmp = (-1.0 / t) * (x / z) elif (z * t) <= 1e+189: tmp = x / (y - (z * t)) else: tmp = (-x / z) / t return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = Float64(Float64(-1.0 / t) * Float64(x / z)); elseif (Float64(z * t) <= 1e+189) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(Float64(-x) / z) / t); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -Inf)
tmp = (-1.0 / t) * (x / z);
elseif ((z * t) <= 1e+189)
tmp = x / (y - (z * t));
else
tmp = (-x / z) / t;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[(N[(-1.0 / t), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+189], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x) / z), $MachinePrecision] / t), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\frac{-1}{t} \cdot \frac{x}{z}\\
\mathbf{elif}\;z \cdot t \leq 10^{+189}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x}{z}}{t}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 41.7%
Taylor expanded in y around 0 41.7%
associate-*r/41.7%
neg-mul-141.7%
Simplified41.7%
neg-mul-141.7%
times-frac99.8%
Applied egg-rr99.8%
if -inf.0 < (*.f64 z t) < 1e189Initial program 99.9%
if 1e189 < (*.f64 z t) Initial program 81.5%
Taylor expanded in y around 0 81.5%
associate-*r/81.5%
neg-mul-181.5%
Simplified81.5%
neg-mul-181.5%
times-frac97.0%
Applied egg-rr97.0%
frac-times81.5%
*-commutative81.5%
frac-times96.5%
associate-*r/96.7%
Applied egg-rr96.7%
Taylor expanded in z around 0 96.8%
neg-mul-196.8%
distribute-frac-neg96.8%
Simplified96.8%
Final simplification99.5%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= t -950.0) (not (<= t 1.85e+232))) (/ x (* z t)) (/ x y)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -950.0) || !(t <= 1.85e+232)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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 <= (-950.0d0)) .or. (.not. (t <= 1.85d+232))) then
tmp = x / (z * t)
else
tmp = x / y
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -950.0) || !(t <= 1.85e+232)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (t <= -950.0) or not (t <= 1.85e+232): tmp = x / (z * t) else: tmp = x / y return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((t <= -950.0) || !(t <= 1.85e+232)) tmp = Float64(x / Float64(z * t)); else tmp = Float64(x / y); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((t <= -950.0) || ~((t <= 1.85e+232)))
tmp = x / (z * t);
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[t, -950.0], N[Not[LessEqual[t, 1.85e+232]], $MachinePrecision]], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -950 \lor \neg \left(t \leq 1.85 \cdot 10^{+232}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -950 or 1.84999999999999986e232 < t Initial program 92.8%
Taylor expanded in y around 0 64.9%
associate-*r/64.9%
neg-mul-164.9%
Simplified64.9%
expm1-log1p-u54.8%
expm1-udef47.8%
add-sqr-sqrt21.0%
sqrt-unprod39.3%
sqr-neg39.3%
sqrt-unprod21.0%
add-sqr-sqrt39.7%
Applied egg-rr39.7%
expm1-def30.2%
expm1-log1p30.7%
Simplified30.7%
if -950 < t < 1.84999999999999986e232Initial program 97.2%
Taylor expanded in y around inf 64.0%
Final simplification53.6%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= t -950.0) (/ x (* z t)) (if (<= t 2.6e+231) (/ x y) (/ (/ x t) z))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -950.0) {
tmp = x / (z * t);
} else if (t <= 2.6e+231) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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 <= (-950.0d0)) then
tmp = x / (z * t)
else if (t <= 2.6d+231) then
tmp = x / y
else
tmp = (x / t) / z
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -950.0) {
tmp = x / (z * t);
} else if (t <= 2.6e+231) {
tmp = x / y;
} else {
tmp = (x / t) / z;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if t <= -950.0: tmp = x / (z * t) elif t <= 2.6e+231: tmp = x / y else: tmp = (x / t) / z return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (t <= -950.0) tmp = Float64(x / Float64(z * t)); elseif (t <= 2.6e+231) tmp = Float64(x / y); else tmp = Float64(Float64(x / t) / z); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (t <= -950.0)
tmp = x / (z * t);
elseif (t <= 2.6e+231)
tmp = x / y;
else
tmp = (x / t) / z;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[t, -950.0], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.6e+231], N[(x / y), $MachinePrecision], N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;t \leq -950:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{elif}\;t \leq 2.6 \cdot 10^{+231}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{z}\\
\end{array}
\end{array}
if t < -950Initial program 95.3%
Taylor expanded in y around 0 61.6%
associate-*r/61.6%
neg-mul-161.6%
Simplified61.6%
expm1-log1p-u51.3%
expm1-udef49.8%
add-sqr-sqrt21.9%
sqrt-unprod40.6%
sqr-neg40.6%
sqrt-unprod21.9%
add-sqr-sqrt40.8%
Applied egg-rr40.8%
expm1-def28.7%
expm1-log1p29.2%
Simplified29.2%
if -950 < t < 2.5999999999999999e231Initial program 97.2%
Taylor expanded in y around inf 64.0%
if 2.5999999999999999e231 < t Initial program 84.2%
Taylor expanded in y around 0 76.1%
associate-*r/76.1%
neg-mul-176.1%
Simplified76.1%
expm1-log1p-u67.1%
expm1-udef40.9%
add-sqr-sqrt18.1%
sqrt-unprod35.2%
sqr-neg35.2%
sqrt-unprod17.8%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
expm1-def35.6%
expm1-log1p35.9%
associate-/r*35.9%
Simplified35.9%
Final simplification53.6%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (/ x y))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return x / y;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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 / y
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return x / y;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return x / y
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(x / y) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = x / y;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\frac{x}{y}
\end{array}
Initial program 95.8%
Taylor expanded in y around inf 54.9%
Final simplification54.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ 1.0 (- (/ y x) (* (/ z x) t)))))
(if (< x -1.618195973607049e+50)
t_1
(if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = 1.0 / ((y / x) - ((z / x) * t));
double tmp;
if (x < -1.618195973607049e+50) {
tmp = t_1;
} else if (x < 2.1378306434876444e+131) {
tmp = x / (y - (z * 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) :: tmp
t_1 = 1.0d0 / ((y / x) - ((z / x) * t))
if (x < (-1.618195973607049d+50)) then
tmp = t_1
else if (x < 2.1378306434876444d+131) then
tmp = x / (y - (z * 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 = 1.0 / ((y / x) - ((z / x) * t));
double tmp;
if (x < -1.618195973607049e+50) {
tmp = t_1;
} else if (x < 2.1378306434876444e+131) {
tmp = x / (y - (z * t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = 1.0 / ((y / x) - ((z / x) * t)) tmp = 0 if x < -1.618195973607049e+50: tmp = t_1 elif x < 2.1378306434876444e+131: tmp = x / (y - (z * t)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(1.0 / Float64(Float64(y / x) - Float64(Float64(z / x) * t))) tmp = 0.0 if (x < -1.618195973607049e+50) tmp = t_1; elseif (x < 2.1378306434876444e+131) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = 1.0 / ((y / x) - ((z / x) * t)); tmp = 0.0; if (x < -1.618195973607049e+50) tmp = t_1; elseif (x < 2.1378306434876444e+131) tmp = x / (y - (z * t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(1.0 / N[(N[(y / x), $MachinePrecision] - N[(N[(z / x), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[x, -1.618195973607049e+50], t$95$1, If[Less[x, 2.1378306434876444e+131], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{1}{\frac{y}{x} - \frac{z}{x} \cdot t}\\
\mathbf{if}\;x < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x < 2.1378306434876444 \cdot 10^{+131}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2024017
(FPCore (x y z t)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:herbie-target
(if (< x -1.618195973607049e+50) (/ 1.0 (- (/ y x) (* (/ z x) t))) (if (< x 2.1378306434876444e+131) (/ x (- y (* z t))) (/ 1.0 (- (/ y x) (* (/ z x) t)))))
(/ x (- y (* z t))))