
(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: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) 5e+182) (/ x (fma (- z) t y)) (/ (/ x t) (- z))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 5e+182) {
tmp = x / fma(-z, t, y);
} else {
tmp = (x / t) / -z;
}
return tmp;
}
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= 5e+182) tmp = Float64(x / fma(Float64(-z), t, y)); else tmp = Float64(Float64(x / t) / Float64(-z)); end return tmp end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], 5e+182], N[(x / N[((-z) * t + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-z, t, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\end{array}
\end{array}
if (*.f64 z t) < 4.99999999999999973e182Initial program 99.5%
sub-neg99.5%
+-commutative99.5%
distribute-lft-neg-in99.5%
fma-def99.5%
Applied egg-rr99.5%
if 4.99999999999999973e182 < (*.f64 z t) Initial program 80.6%
clear-num80.6%
associate-/r/80.6%
Applied egg-rr80.6%
Taylor expanded in y around 0 80.6%
expm1-log1p-u80.6%
expm1-udef58.0%
*-commutative58.0%
Applied egg-rr58.0%
expm1-def80.6%
expm1-log1p80.6%
*-commutative80.6%
associate-/r*80.5%
Simplified80.5%
associate-*l/96.6%
frac-2neg96.6%
associate-*l/96.7%
neg-mul-196.7%
add-sqr-sqrt41.2%
sqrt-unprod66.8%
sqr-neg66.8%
sqrt-unprod36.0%
add-sqr-sqrt57.4%
distribute-frac-neg57.4%
add-sqr-sqrt21.4%
sqrt-unprod66.6%
sqr-neg66.6%
sqrt-unprod55.3%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
Final simplification99.2%
NOTE: 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 t) -1e-61)
t_1
(if (<= (* z t) 1e-75)
(/ x y)
(if (<= (* z t) 2e+145) t_1 (/ (/ x t) (- z)))))))assert(z < t);
double code(double x, double y, double z, double t) {
double t_1 = -x / (z * t);
double tmp;
if ((z * t) <= -1e-61) {
tmp = t_1;
} else if ((z * t) <= 1e-75) {
tmp = x / y;
} else if ((z * t) <= 2e+145) {
tmp = t_1;
} else {
tmp = (x / t) / -z;
}
return tmp;
}
NOTE: 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 * t) <= (-1d-61)) then
tmp = t_1
else if ((z * t) <= 1d-75) then
tmp = x / y
else if ((z * t) <= 2d+145) then
tmp = t_1
else
tmp = (x / t) / -z
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = -x / (z * t);
double tmp;
if ((z * t) <= -1e-61) {
tmp = t_1;
} else if ((z * t) <= 1e-75) {
tmp = x / y;
} else if ((z * t) <= 2e+145) {
tmp = t_1;
} else {
tmp = (x / t) / -z;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): t_1 = -x / (z * t) tmp = 0 if (z * t) <= -1e-61: tmp = t_1 elif (z * t) <= 1e-75: tmp = x / y elif (z * t) <= 2e+145: tmp = t_1 else: tmp = (x / t) / -z return tmp
z, t = sort([z, t]) function code(x, y, z, t) t_1 = Float64(Float64(-x) / Float64(z * t)) tmp = 0.0 if (Float64(z * t) <= -1e-61) tmp = t_1; elseif (Float64(z * t) <= 1e-75) tmp = Float64(x / y); elseif (Float64(z * t) <= 2e+145) tmp = t_1; else tmp = Float64(Float64(x / t) / Float64(-z)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = -x / (z * t);
tmp = 0.0;
if ((z * t) <= -1e-61)
tmp = t_1;
elseif ((z * t) <= 1e-75)
tmp = x / y;
elseif ((z * t) <= 2e+145)
tmp = t_1;
else
tmp = (x / t) / -z;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -1e-61], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 1e-75], N[(x / y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+145], t$95$1, N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision]]]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{-x}{z \cdot t}\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{-61}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot t \leq 10^{-75}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+145}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\end{array}
\end{array}
if (*.f64 z t) < -1e-61 or 9.9999999999999996e-76 < (*.f64 z t) < 2e145Initial program 99.0%
Taylor expanded in y around 0 71.3%
associate-*r/71.3%
neg-mul-171.3%
Simplified71.3%
if -1e-61 < (*.f64 z t) < 9.9999999999999996e-76Initial program 100.0%
Taylor expanded in y around inf 81.9%
if 2e145 < (*.f64 z t) Initial program 84.3%
clear-num84.3%
associate-/r/84.3%
Applied egg-rr84.3%
Taylor expanded in y around 0 77.0%
expm1-log1p-u77.0%
expm1-udef50.1%
*-commutative50.1%
Applied egg-rr50.1%
expm1-def77.0%
expm1-log1p77.0%
*-commutative77.0%
associate-/r*76.9%
Simplified76.9%
associate-*l/89.8%
frac-2neg89.8%
associate-*l/89.9%
neg-mul-189.9%
add-sqr-sqrt33.2%
sqrt-unprod57.1%
sqr-neg57.1%
sqrt-unprod32.2%
add-sqr-sqrt49.7%
distribute-frac-neg49.7%
add-sqr-sqrt17.5%
sqrt-unprod63.1%
sqr-neg63.1%
sqrt-unprod56.5%
add-sqr-sqrt89.9%
Applied egg-rr89.9%
Final simplification78.3%
NOTE: z and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (or (<= y -3.4e-75)
(not (or (<= y -5.6e-139) (and (not (<= y -4.3e-148)) (<= y 1e+87)))))
(/ x y)
(/ (- x) (* z t))))assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.4e-75) || !((y <= -5.6e-139) || (!(y <= -4.3e-148) && (y <= 1e+87)))) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
NOTE: 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 <= (-3.4d-75)) .or. (.not. (y <= (-5.6d-139)) .or. (.not. (y <= (-4.3d-148))) .and. (y <= 1d+87))) then
tmp = x / y
else
tmp = -x / (z * t)
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -3.4e-75) || !((y <= -5.6e-139) || (!(y <= -4.3e-148) && (y <= 1e+87)))) {
tmp = x / y;
} else {
tmp = -x / (z * t);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (y <= -3.4e-75) or not ((y <= -5.6e-139) or (not (y <= -4.3e-148) and (y <= 1e+87))): tmp = x / y else: tmp = -x / (z * t) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((y <= -3.4e-75) || !((y <= -5.6e-139) || (!(y <= -4.3e-148) && (y <= 1e+87)))) tmp = Float64(x / y); else tmp = Float64(Float64(-x) / Float64(z * t)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((y <= -3.4e-75) || ~(((y <= -5.6e-139) || (~((y <= -4.3e-148)) && (y <= 1e+87)))))
tmp = x / y;
else
tmp = -x / (z * t);
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[y, -3.4e-75], N[Not[Or[LessEqual[y, -5.6e-139], And[N[Not[LessEqual[y, -4.3e-148]], $MachinePrecision], LessEqual[y, 1e+87]]]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-75} \lor \neg \left(y \leq -5.6 \cdot 10^{-139} \lor \neg \left(y \leq -4.3 \cdot 10^{-148}\right) \land y \leq 10^{+87}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\end{array}
\end{array}
if y < -3.40000000000000015e-75 or -5.5999999999999997e-139 < y < -4.2999999999999998e-148 or 9.9999999999999996e86 < y Initial program 96.1%
Taylor expanded in y around inf 81.0%
if -3.40000000000000015e-75 < y < -5.5999999999999997e-139 or -4.2999999999999998e-148 < y < 9.9999999999999996e86Initial program 98.5%
Taylor expanded in y around 0 78.7%
associate-*r/78.7%
neg-mul-178.7%
Simplified78.7%
Final simplification79.8%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -1e-61) (/ (- x) (* z t)) (if (<= (* z t) 1e-75) (/ x y) (/ (/ x z) (- t)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -1e-61) {
tmp = -x / (z * t);
} else if ((z * t) <= 1e-75) {
tmp = x / y;
} else {
tmp = (x / z) / -t;
}
return tmp;
}
NOTE: 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 * t) <= (-1d-61)) then
tmp = -x / (z * t)
else if ((z * t) <= 1d-75) then
tmp = x / y
else
tmp = (x / z) / -t
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -1e-61) {
tmp = -x / (z * t);
} else if ((z * t) <= 1e-75) {
tmp = x / y;
} else {
tmp = (x / z) / -t;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -1e-61: tmp = -x / (z * t) elif (z * t) <= 1e-75: tmp = x / y else: tmp = (x / z) / -t return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -1e-61) tmp = Float64(Float64(-x) / Float64(z * t)); elseif (Float64(z * t) <= 1e-75) tmp = Float64(x / y); else tmp = Float64(Float64(x / z) / Float64(-t)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -1e-61)
tmp = -x / (z * t);
elseif ((z * t) <= 1e-75)
tmp = x / y;
else
tmp = (x / z) / -t;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e-61], N[((-x) / N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e-75], N[(x / y), $MachinePrecision], N[(N[(x / z), $MachinePrecision] / (-t)), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{-61}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\mathbf{elif}\;z \cdot t \leq 10^{-75}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{-t}\\
\end{array}
\end{array}
if (*.f64 z t) < -1e-61Initial program 98.4%
Taylor expanded in y around 0 77.3%
associate-*r/77.3%
neg-mul-177.3%
Simplified77.3%
if -1e-61 < (*.f64 z t) < 9.9999999999999996e-76Initial program 100.0%
Taylor expanded in y around inf 81.9%
if 9.9999999999999996e-76 < (*.f64 z t) Initial program 93.2%
clear-num91.4%
associate-/r/93.0%
Applied egg-rr93.0%
Taylor expanded in y around 0 68.9%
expm1-log1p-u55.8%
expm1-udef30.8%
*-commutative30.8%
Applied egg-rr30.8%
expm1-def55.8%
expm1-log1p68.9%
*-commutative68.9%
associate-/r*68.9%
Simplified68.9%
associate-/l/68.9%
associate-*l/69.0%
neg-mul-169.0%
associate-/r*71.5%
frac-2neg71.5%
add-sqr-sqrt28.2%
sqrt-unprod39.6%
sqr-neg39.6%
sqrt-unprod17.4%
add-sqr-sqrt27.2%
distribute-frac-neg27.2%
add-sqr-sqrt9.8%
sqrt-unprod42.5%
sqr-neg42.5%
sqrt-unprod43.0%
add-sqr-sqrt71.5%
Applied egg-rr71.5%
Final simplification77.3%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= (* z t) -8.5e+68) (not (<= (* z t) 2.35e+166))) (/ x (* z t)) (/ x y)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -8.5e+68) || !((z * t) <= 2.35e+166)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
NOTE: 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 * t) <= (-8.5d+68)) .or. (.not. ((z * t) <= 2.35d+166))) then
tmp = x / (z * t)
else
tmp = x / y
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -8.5e+68) || !((z * t) <= 2.35e+166)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if ((z * t) <= -8.5e+68) or not ((z * t) <= 2.35e+166): tmp = x / (z * t) else: tmp = x / y return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((Float64(z * t) <= -8.5e+68) || !(Float64(z * t) <= 2.35e+166)) tmp = Float64(x / Float64(z * t)); else tmp = Float64(x / y); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (((z * t) <= -8.5e+68) || ~(((z * t) <= 2.35e+166)))
tmp = x / (z * t);
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -8.5e+68], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2.35e+166]], $MachinePrecision]], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -8.5 \cdot 10^{+68} \lor \neg \left(z \cdot t \leq 2.35 \cdot 10^{+166}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -8.49999999999999966e68 or 2.35e166 < (*.f64 z t) Initial program 90.3%
clear-num89.3%
associate-/r/90.2%
Applied egg-rr90.2%
Taylor expanded in y around 0 86.1%
expm1-log1p-u86.1%
expm1-udef52.1%
*-commutative52.1%
Applied egg-rr52.1%
expm1-def86.1%
expm1-log1p86.1%
*-commutative86.1%
associate-/r*86.1%
Simplified86.1%
associate-/l/86.1%
associate-*l/86.1%
neg-mul-186.1%
add-sqr-sqrt38.4%
sqrt-unprod59.5%
sqr-neg59.5%
sqrt-unprod29.8%
add-sqr-sqrt51.5%
Applied egg-rr51.5%
if -8.49999999999999966e68 < (*.f64 z t) < 2.35e166Initial program 99.9%
Taylor expanded in y around inf 63.4%
Final simplification60.2%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -5e+68) (/ (/ x t) z) (if (<= (* z t) 5e+162) (/ x y) (/ x (* z t)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+68) {
tmp = (x / t) / z;
} else if ((z * t) <= 5e+162) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
NOTE: 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 * t) <= (-5d+68)) then
tmp = (x / t) / z
else if ((z * t) <= 5d+162) then
tmp = x / y
else
tmp = x / (z * t)
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+68) {
tmp = (x / t) / z;
} else if ((z * t) <= 5e+162) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -5e+68: tmp = (x / t) / z elif (z * t) <= 5e+162: tmp = x / y else: tmp = x / (z * t) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -5e+68) tmp = Float64(Float64(x / t) / z); elseif (Float64(z * t) <= 5e+162) tmp = Float64(x / y); else tmp = Float64(x / Float64(z * t)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -5e+68)
tmp = (x / t) / z;
elseif ((z * t) <= 5e+162)
tmp = x / y;
else
tmp = x / (z * t);
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+68], N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+162], N[(x / y), $MachinePrecision], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+68}:\\
\;\;\;\;\frac{\frac{x}{t}}{z}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+162}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000004e68Initial program 97.2%
clear-num95.5%
associate-/r/97.2%
Applied egg-rr97.2%
Taylor expanded in y around 0 92.0%
expm1-log1p-u92.0%
expm1-udef48.7%
*-commutative48.7%
Applied egg-rr48.7%
expm1-def92.0%
expm1-log1p92.0%
*-commutative92.0%
associate-/r*92.1%
Simplified92.1%
associate-*l/89.4%
associate-*l/89.5%
neg-mul-189.5%
add-sqr-sqrt41.9%
sqrt-unprod53.4%
sqr-neg53.4%
sqrt-unprod24.3%
add-sqr-sqrt47.9%
Applied egg-rr47.9%
if -5.0000000000000004e68 < (*.f64 z t) < 4.9999999999999997e162Initial program 99.9%
Taylor expanded in y around inf 63.4%
if 4.9999999999999997e162 < (*.f64 z t) Initial program 82.4%
clear-num82.3%
associate-/r/82.4%
Applied egg-rr82.4%
Taylor expanded in y around 0 79.4%
expm1-log1p-u79.4%
expm1-udef55.9%
*-commutative55.9%
Applied egg-rr55.9%
expm1-def79.4%
expm1-log1p79.4%
*-commutative79.4%
associate-/r*79.3%
Simplified79.3%
associate-/l/79.4%
associate-*l/79.4%
neg-mul-179.4%
add-sqr-sqrt31.5%
sqrt-unprod63.5%
sqr-neg63.5%
sqrt-unprod35.9%
add-sqr-sqrt55.7%
Applied egg-rr55.7%
Final simplification60.2%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -5e+68) (/ (/ x z) t) (if (<= (* z t) 5e+162) (/ x y) (/ x (* z t)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+68) {
tmp = (x / z) / t;
} else if ((z * t) <= 5e+162) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
NOTE: 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 * t) <= (-5d+68)) then
tmp = (x / z) / t
else if ((z * t) <= 5d+162) then
tmp = x / y
else
tmp = x / (z * t)
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+68) {
tmp = (x / z) / t;
} else if ((z * t) <= 5e+162) {
tmp = x / y;
} else {
tmp = x / (z * t);
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -5e+68: tmp = (x / z) / t elif (z * t) <= 5e+162: tmp = x / y else: tmp = x / (z * t) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -5e+68) tmp = Float64(Float64(x / z) / t); elseif (Float64(z * t) <= 5e+162) tmp = Float64(x / y); else tmp = Float64(x / Float64(z * t)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -5e+68)
tmp = (x / z) / t;
elseif ((z * t) <= 5e+162)
tmp = x / y;
else
tmp = x / (z * t);
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+68], N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+162], N[(x / y), $MachinePrecision], N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+68}:\\
\;\;\;\;\frac{\frac{x}{z}}{t}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+162}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000004e68Initial program 97.2%
clear-num95.5%
associate-/r/97.2%
Applied egg-rr97.2%
Taylor expanded in y around 0 92.0%
expm1-log1p-u92.0%
expm1-udef48.7%
*-commutative48.7%
Applied egg-rr48.7%
expm1-def92.0%
expm1-log1p92.0%
*-commutative92.0%
associate-/r*92.1%
Simplified92.1%
associate-/l/92.0%
associate-*l/92.1%
neg-mul-192.1%
associate-/r*90.8%
add-sqr-sqrt42.2%
sqrt-unprod56.0%
sqr-neg56.0%
sqrt-unprod24.4%
add-sqr-sqrt47.9%
Applied egg-rr47.9%
if -5.0000000000000004e68 < (*.f64 z t) < 4.9999999999999997e162Initial program 99.9%
Taylor expanded in y around inf 63.4%
if 4.9999999999999997e162 < (*.f64 z t) Initial program 82.4%
clear-num82.3%
associate-/r/82.4%
Applied egg-rr82.4%
Taylor expanded in y around 0 79.4%
expm1-log1p-u79.4%
expm1-udef55.9%
*-commutative55.9%
Applied egg-rr55.9%
expm1-def79.4%
expm1-log1p79.4%
*-commutative79.4%
associate-/r*79.3%
Simplified79.3%
associate-/l/79.4%
associate-*l/79.4%
neg-mul-179.4%
add-sqr-sqrt31.5%
sqrt-unprod63.5%
sqr-neg63.5%
sqrt-unprod35.9%
add-sqr-sqrt55.7%
Applied egg-rr55.7%
Final simplification60.2%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) 5e+182) (/ x (- y (* z t))) (/ (/ x t) (- z))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 5e+182) {
tmp = x / (y - (z * t));
} else {
tmp = (x / t) / -z;
}
return tmp;
}
NOTE: 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 * t) <= 5d+182) then
tmp = x / (y - (z * t))
else
tmp = (x / t) / -z
end if
code = tmp
end function
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= 5e+182) {
tmp = x / (y - (z * t));
} else {
tmp = (x / t) / -z;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= 5e+182: tmp = x / (y - (z * t)) else: tmp = (x / t) / -z return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= 5e+182) tmp = Float64(x / Float64(y - Float64(z * t))); else tmp = Float64(Float64(x / t) / Float64(-z)); end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= 5e+182)
tmp = x / (y - (z * t));
else
tmp = (x / t) / -z;
end
tmp_2 = tmp;
end
NOTE: z and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], 5e+182], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / t), $MachinePrecision] / (-z)), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq 5 \cdot 10^{+182}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{t}}{-z}\\
\end{array}
\end{array}
if (*.f64 z t) < 4.99999999999999973e182Initial program 99.5%
if 4.99999999999999973e182 < (*.f64 z t) Initial program 80.6%
clear-num80.6%
associate-/r/80.6%
Applied egg-rr80.6%
Taylor expanded in y around 0 80.6%
expm1-log1p-u80.6%
expm1-udef58.0%
*-commutative58.0%
Applied egg-rr58.0%
expm1-def80.6%
expm1-log1p80.6%
*-commutative80.6%
associate-/r*80.5%
Simplified80.5%
associate-*l/96.6%
frac-2neg96.6%
associate-*l/96.7%
neg-mul-196.7%
add-sqr-sqrt41.2%
sqrt-unprod66.8%
sqr-neg66.8%
sqrt-unprod36.0%
add-sqr-sqrt57.4%
distribute-frac-neg57.4%
add-sqr-sqrt21.4%
sqrt-unprod66.6%
sqr-neg66.6%
sqrt-unprod55.3%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
Final simplification99.2%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (/ x y))
assert(z < t);
double code(double x, double y, double z, double t) {
return x / y;
}
NOTE: 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 z < t;
public static double code(double x, double y, double z, double t) {
return x / y;
}
[z, t] = sort([z, t]) def code(x, y, z, t): return x / y
z, t = sort([z, t]) function code(x, y, z, t) return Float64(x / y) end
z, t = num2cell(sort([z, t])){:}
function tmp = code(x, y, z, t)
tmp = x / y;
end
NOTE: 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}
[z, t] = \mathsf{sort}([z, t])\\
\\
\frac{x}{y}
\end{array}
Initial program 97.3%
Taylor expanded in y around inf 51.0%
Final simplification51.0%
(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 2023176
(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))))