
(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 8 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 (or (<= (* z t) (- INFINITY)) (not (<= (* z t) 5e+243))) (* (/ -1.0 z) (/ x t)) (/ x (fma z (- t) y))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -((double) INFINITY)) || !((z * t) <= 5e+243)) {
tmp = (-1.0 / z) * (x / t);
} else {
tmp = x / fma(z, -t, y);
}
return tmp;
}
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((Float64(z * t) <= Float64(-Inf)) || !(Float64(z * t) <= 5e+243)) tmp = Float64(Float64(-1.0 / z) * Float64(x / t)); else tmp = Float64(x / fma(z, Float64(-t), y)); end return 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], (-Infinity)], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5e+243]], $MachinePrecision]], N[(N[(-1.0 / z), $MachinePrecision] * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(x / N[(z * (-t) + y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+243}\right):\\
\;\;\;\;\frac{-1}{z} \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(z, -t, y\right)}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0 or 5.00000000000000037e243 < (*.f64 z t) Initial program 72.0%
sub-neg72.0%
+-commutative72.0%
distribute-rgt-neg-in72.0%
fma-udef72.0%
clear-num72.0%
inv-pow72.0%
add-sqr-sqrt41.6%
sqrt-unprod72.0%
sqr-neg72.0%
sqrt-unprod30.4%
add-sqr-sqrt67.0%
Applied egg-rr67.0%
Taylor expanded in z around inf 67.0%
add-sqr-sqrt33.2%
sqrt-unprod68.2%
sqr-neg68.2%
sqrt-unprod36.3%
add-sqr-sqrt72.0%
neg-mul-172.0%
*-commutative72.0%
times-frac99.9%
Applied egg-rr99.9%
if -inf.0 < (*.f64 z t) < 5.00000000000000037e243Initial program 99.8%
cancel-sign-sub-inv99.8%
+-commutative99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-out99.8%
fma-def99.8%
Simplified99.8%
Final simplification99.8%
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))) (t_2 (* (/ -1.0 z) (/ x t))))
(if (<= (* z t) -5e+89)
t_2
(if (<= (* z t) -5e+15)
(/ x y)
(if (<= (* z t) -5e-133)
t_1
(if (<= (* z t) 4e-17) (/ x y) (if (<= (* z t) 5e+243) t_1 t_2)))))))assert(z < t);
double code(double x, double y, double z, double t) {
double t_1 = -x / (z * t);
double t_2 = (-1.0 / z) * (x / t);
double tmp;
if ((z * t) <= -5e+89) {
tmp = t_2;
} else if ((z * t) <= -5e+15) {
tmp = x / y;
} else if ((z * t) <= -5e-133) {
tmp = t_1;
} else if ((z * t) <= 4e-17) {
tmp = x / y;
} else if ((z * t) <= 5e+243) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = -x / (z * t)
t_2 = ((-1.0d0) / z) * (x / t)
if ((z * t) <= (-5d+89)) then
tmp = t_2
else if ((z * t) <= (-5d+15)) then
tmp = x / y
else if ((z * t) <= (-5d-133)) then
tmp = t_1
else if ((z * t) <= 4d-17) then
tmp = x / y
else if ((z * t) <= 5d+243) then
tmp = t_1
else
tmp = t_2
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 t_2 = (-1.0 / z) * (x / t);
double tmp;
if ((z * t) <= -5e+89) {
tmp = t_2;
} else if ((z * t) <= -5e+15) {
tmp = x / y;
} else if ((z * t) <= -5e-133) {
tmp = t_1;
} else if ((z * t) <= 4e-17) {
tmp = x / y;
} else if ((z * t) <= 5e+243) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): t_1 = -x / (z * t) t_2 = (-1.0 / z) * (x / t) tmp = 0 if (z * t) <= -5e+89: tmp = t_2 elif (z * t) <= -5e+15: tmp = x / y elif (z * t) <= -5e-133: tmp = t_1 elif (z * t) <= 4e-17: tmp = x / y elif (z * t) <= 5e+243: tmp = t_1 else: tmp = t_2 return tmp
z, t = sort([z, t]) function code(x, y, z, t) t_1 = Float64(Float64(-x) / Float64(z * t)) t_2 = Float64(Float64(-1.0 / z) * Float64(x / t)) tmp = 0.0 if (Float64(z * t) <= -5e+89) tmp = t_2; elseif (Float64(z * t) <= -5e+15) tmp = Float64(x / y); elseif (Float64(z * t) <= -5e-133) tmp = t_1; elseif (Float64(z * t) <= 4e-17) tmp = Float64(x / y); elseif (Float64(z * t) <= 5e+243) tmp = t_1; else tmp = t_2; end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = -x / (z * t);
t_2 = (-1.0 / z) * (x / t);
tmp = 0.0;
if ((z * t) <= -5e+89)
tmp = t_2;
elseif ((z * t) <= -5e+15)
tmp = x / y;
elseif ((z * t) <= -5e-133)
tmp = t_1;
elseif ((z * t) <= 4e-17)
tmp = x / y;
elseif ((z * t) <= 5e+243)
tmp = t_1;
else
tmp = t_2;
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]}, Block[{t$95$2 = N[(N[(-1.0 / z), $MachinePrecision] * N[(x / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+89], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -5e+15], N[(x / y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5e-133], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 4e-17], N[(x / y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+243], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{-x}{z \cdot t}\\
t_2 := \frac{-1}{z} \cdot \frac{x}{t}\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+89}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{-133}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+243}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999983e89 or 5.00000000000000037e243 < (*.f64 z t) Initial program 86.6%
sub-neg86.6%
+-commutative86.6%
distribute-rgt-neg-in86.6%
fma-udef86.6%
clear-num84.9%
inv-pow84.9%
add-sqr-sqrt51.5%
sqrt-unprod64.0%
sqr-neg64.0%
sqrt-unprod23.3%
add-sqr-sqrt50.8%
Applied egg-rr50.8%
Taylor expanded in z around inf 44.1%
add-sqr-sqrt21.4%
sqrt-unprod54.8%
sqr-neg54.8%
sqrt-unprod40.6%
add-sqr-sqrt79.5%
neg-mul-179.5%
*-commutative79.5%
times-frac90.4%
Applied egg-rr90.4%
if -4.99999999999999983e89 < (*.f64 z t) < -5e15 or -4.9999999999999999e-133 < (*.f64 z t) < 4.00000000000000029e-17Initial program 100.0%
Taylor expanded in y around inf 86.6%
if -5e15 < (*.f64 z t) < -4.9999999999999999e-133 or 4.00000000000000029e-17 < (*.f64 z t) < 5.00000000000000037e243Initial program 99.6%
Taylor expanded in y around 0 75.8%
associate-*r/75.8%
neg-mul-175.8%
Simplified75.8%
Final simplification84.6%
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))) (t_2 (/ (- (/ x t)) z)))
(if (<= (* z t) -5e+89)
t_2
(if (<= (* z t) -5e+15)
(/ x y)
(if (<= (* z t) -5e-133)
t_1
(if (<= (* z t) 4e-17) (/ x y) (if (<= (* z t) 5e+243) t_1 t_2)))))))assert(z < t);
double code(double x, double y, double z, double t) {
double t_1 = -x / (z * t);
double t_2 = -(x / t) / z;
double tmp;
if ((z * t) <= -5e+89) {
tmp = t_2;
} else if ((z * t) <= -5e+15) {
tmp = x / y;
} else if ((z * t) <= -5e-133) {
tmp = t_1;
} else if ((z * t) <= 4e-17) {
tmp = x / y;
} else if ((z * t) <= 5e+243) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_1 = -x / (z * t)
t_2 = -(x / t) / z
if ((z * t) <= (-5d+89)) then
tmp = t_2
else if ((z * t) <= (-5d+15)) then
tmp = x / y
else if ((z * t) <= (-5d-133)) then
tmp = t_1
else if ((z * t) <= 4d-17) then
tmp = x / y
else if ((z * t) <= 5d+243) then
tmp = t_1
else
tmp = t_2
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 t_2 = -(x / t) / z;
double tmp;
if ((z * t) <= -5e+89) {
tmp = t_2;
} else if ((z * t) <= -5e+15) {
tmp = x / y;
} else if ((z * t) <= -5e-133) {
tmp = t_1;
} else if ((z * t) <= 4e-17) {
tmp = x / y;
} else if ((z * t) <= 5e+243) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): t_1 = -x / (z * t) t_2 = -(x / t) / z tmp = 0 if (z * t) <= -5e+89: tmp = t_2 elif (z * t) <= -5e+15: tmp = x / y elif (z * t) <= -5e-133: tmp = t_1 elif (z * t) <= 4e-17: tmp = x / y elif (z * t) <= 5e+243: tmp = t_1 else: tmp = t_2 return tmp
z, t = sort([z, t]) function code(x, y, z, t) t_1 = Float64(Float64(-x) / Float64(z * t)) t_2 = Float64(Float64(-Float64(x / t)) / z) tmp = 0.0 if (Float64(z * t) <= -5e+89) tmp = t_2; elseif (Float64(z * t) <= -5e+15) tmp = Float64(x / y); elseif (Float64(z * t) <= -5e-133) tmp = t_1; elseif (Float64(z * t) <= 4e-17) tmp = Float64(x / y); elseif (Float64(z * t) <= 5e+243) tmp = t_1; else tmp = t_2; end return tmp end
z, t = num2cell(sort([z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = -x / (z * t);
t_2 = -(x / t) / z;
tmp = 0.0;
if ((z * t) <= -5e+89)
tmp = t_2;
elseif ((z * t) <= -5e+15)
tmp = x / y;
elseif ((z * t) <= -5e-133)
tmp = t_1;
elseif ((z * t) <= 4e-17)
tmp = x / y;
elseif ((z * t) <= 5e+243)
tmp = t_1;
else
tmp = t_2;
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]}, Block[{t$95$2 = N[((-N[(x / t), $MachinePrecision]) / z), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e+89], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -5e+15], N[(x / y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5e-133], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 4e-17], N[(x / y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+243], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
t_1 := \frac{-x}{z \cdot t}\\
t_2 := \frac{-\frac{x}{t}}{z}\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+89}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{+15}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{-133}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+243}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (*.f64 z t) < -4.99999999999999983e89 or 5.00000000000000037e243 < (*.f64 z t) Initial program 86.6%
sub-neg86.6%
+-commutative86.6%
distribute-rgt-neg-in86.6%
fma-udef86.6%
frac-2neg86.6%
div-inv86.6%
fma-udef86.6%
distribute-rgt-neg-in86.6%
distribute-neg-in86.6%
Applied egg-rr86.6%
/-rgt-identity86.6%
add-cube-cbrt86.1%
associate-/l*86.0%
pow286.0%
Applied egg-rr86.0%
Taylor expanded in z around inf 79.5%
mul-1-neg79.5%
associate-/r*90.4%
distribute-neg-frac90.4%
Simplified90.4%
if -4.99999999999999983e89 < (*.f64 z t) < -5e15 or -4.9999999999999999e-133 < (*.f64 z t) < 4.00000000000000029e-17Initial program 100.0%
Taylor expanded in y around inf 86.6%
if -5e15 < (*.f64 z t) < -4.9999999999999999e-133 or 4.00000000000000029e-17 < (*.f64 z t) < 5.00000000000000037e243Initial program 99.6%
Taylor expanded in y around 0 75.8%
associate-*r/75.8%
neg-mul-175.8%
Simplified75.8%
Final simplification84.6%
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) (- INFINITY)) (not (<= (* z t) 5e+243))) (* (/ -1.0 z) (/ x t)) (/ x (- y (* z t)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -((double) INFINITY)) || !((z * t) <= 5e+243)) {
tmp = (-1.0 / z) * (x / t);
} else {
tmp = x / (y - (z * t));
}
return tmp;
}
assert z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -Double.POSITIVE_INFINITY) || !((z * t) <= 5e+243)) {
tmp = (-1.0 / z) * (x / t);
} else {
tmp = x / (y - (z * t));
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if ((z * t) <= -math.inf) or not ((z * t) <= 5e+243): tmp = (-1.0 / z) * (x / t) else: tmp = x / (y - (z * t)) return tmp
z, t = sort([z, t]) function code(x, y, z, t) tmp = 0.0 if ((Float64(z * t) <= Float64(-Inf)) || !(Float64(z * t) <= 5e+243)) tmp = Float64(Float64(-1.0 / z) * Float64(x / t)); else tmp = Float64(x / Float64(y - 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) <= -Inf) || ~(((z * t) <= 5e+243)))
tmp = (-1.0 / z) * (x / t);
else
tmp = x / (y - (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[N[(z * t), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5e+243]], $MachinePrecision]], N[(N[(-1.0 / z), $MachinePrecision] * N[(x / t), $MachinePrecision]), $MachinePrecision], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[z, t] = \mathsf{sort}([z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+243}\right):\\
\;\;\;\;\frac{-1}{z} \cdot \frac{x}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0 or 5.00000000000000037e243 < (*.f64 z t) Initial program 72.0%
sub-neg72.0%
+-commutative72.0%
distribute-rgt-neg-in72.0%
fma-udef72.0%
clear-num72.0%
inv-pow72.0%
add-sqr-sqrt41.6%
sqrt-unprod72.0%
sqr-neg72.0%
sqrt-unprod30.4%
add-sqr-sqrt67.0%
Applied egg-rr67.0%
Taylor expanded in z around inf 67.0%
add-sqr-sqrt33.2%
sqrt-unprod68.2%
sqr-neg68.2%
sqrt-unprod36.3%
add-sqr-sqrt72.0%
neg-mul-172.0%
*-commutative72.0%
times-frac99.9%
Applied egg-rr99.9%
if -inf.0 < (*.f64 z t) < 5.00000000000000037e243Initial program 99.8%
Final simplification99.8%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= y -1.5e+32) (/ x y) (if (<= y 4.8e-72) (/ (- x) (* z t)) (/ x y))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e+32) {
tmp = x / y;
} else if (y <= 4.8e-72) {
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 (y <= (-1.5d+32)) then
tmp = x / y
else if (y <= 4.8d-72) 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 (y <= -1.5e+32) {
tmp = x / y;
} else if (y <= 4.8e-72) {
tmp = -x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if y <= -1.5e+32: tmp = x / y elif y <= 4.8e-72: 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 (y <= -1.5e+32) tmp = Float64(x / y); elseif (y <= 4.8e-72) tmp = Float64(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 (y <= -1.5e+32)
tmp = x / y;
elseif (y <= 4.8e-72)
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[LessEqual[y, -1.5e+32], N[(x / y), $MachinePrecision], If[LessEqual[y, 4.8e-72], 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}\;y \leq -1.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-72}:\\
\;\;\;\;\frac{-x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if y < -1.5e32 or 4.8e-72 < y Initial program 95.9%
Taylor expanded in y around inf 76.7%
if -1.5e32 < y < 4.8e-72Initial program 95.7%
Taylor expanded in y around 0 83.0%
associate-*r/83.0%
neg-mul-183.0%
Simplified83.0%
Final simplification79.6%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (or (<= t -2100000000.0) (not (<= t 6.8e+181))) (/ x (* z t)) (/ x y)))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2100000000.0) || !(t <= 6.8e+181)) {
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 ((t <= (-2100000000.0d0)) .or. (.not. (t <= 6.8d+181))) 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 ((t <= -2100000000.0) || !(t <= 6.8e+181)) {
tmp = x / (z * t);
} else {
tmp = x / y;
}
return tmp;
}
[z, t] = sort([z, t]) def code(x, y, z, t): tmp = 0 if (t <= -2100000000.0) or not (t <= 6.8e+181): 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 ((t <= -2100000000.0) || !(t <= 6.8e+181)) 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 ((t <= -2100000000.0) || ~((t <= 6.8e+181)))
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[t, -2100000000.0], N[Not[LessEqual[t, 6.8e+181]], $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}\;t \leq -2100000000 \lor \neg \left(t \leq 6.8 \cdot 10^{+181}\right):\\
\;\;\;\;\frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if t < -2.1e9 or 6.80000000000000062e181 < t Initial program 91.3%
sub-neg91.3%
+-commutative91.3%
distribute-rgt-neg-in91.3%
fma-udef91.3%
clear-num88.6%
inv-pow88.6%
add-sqr-sqrt65.4%
sqrt-unprod57.2%
sqr-neg57.2%
sqrt-unprod14.3%
add-sqr-sqrt50.9%
Applied egg-rr50.9%
Taylor expanded in z around inf 32.3%
if -2.1e9 < t < 6.80000000000000062e181Initial program 98.7%
Taylor expanded in y around inf 61.4%
Final simplification50.0%
NOTE: z and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= z -2.8e+140) (/ (/ x z) t) (if (<= z 5.2e+80) (/ x y) (/ x (* z t)))))
assert(z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.8e+140) {
tmp = (x / z) / t;
} else if (z <= 5.2e+80) {
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 <= (-2.8d+140)) then
tmp = (x / z) / t
else if (z <= 5.2d+80) 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 <= -2.8e+140) {
tmp = (x / z) / t;
} else if (z <= 5.2e+80) {
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 <= -2.8e+140: tmp = (x / z) / t elif z <= 5.2e+80: 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 (z <= -2.8e+140) tmp = Float64(Float64(x / z) / t); elseif (z <= 5.2e+80) 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 <= -2.8e+140)
tmp = (x / z) / t;
elseif (z <= 5.2e+80)
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[z, -2.8e+140], N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[z, 5.2e+80], 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 \leq -2.8 \cdot 10^{+140}:\\
\;\;\;\;\frac{\frac{x}{z}}{t}\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{+80}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z \cdot t}\\
\end{array}
\end{array}
if z < -2.79999999999999983e140Initial program 94.5%
sub-neg94.5%
+-commutative94.5%
distribute-rgt-neg-in94.5%
fma-udef94.5%
frac-2neg94.5%
div-inv94.3%
fma-udef94.3%
distribute-rgt-neg-in94.3%
distribute-neg-in94.3%
Applied egg-rr94.3%
un-div-inv94.5%
sub-neg94.5%
add-sqr-sqrt0.0%
add-sqr-sqrt0.0%
sqrt-unprod25.8%
sqr-neg25.8%
sqrt-unprod31.1%
add-sqr-sqrt31.1%
associate-*l*31.1%
distribute-lft-neg-out31.1%
distribute-lft-neg-out31.1%
associate-*r*31.1%
add-sqr-sqrt69.1%
distribute-neg-in69.1%
fma-udef69.1%
frac-2neg69.1%
clear-num69.2%
frac-2neg69.2%
metadata-eval69.2%
add-sqr-sqrt31.8%
sqrt-unprod74.2%
Applied egg-rr82.6%
Taylor expanded in z around inf 80.1%
associate-/l*88.2%
associate-/r/80.6%
Simplified80.6%
expm1-log1p-u76.7%
expm1-udef58.2%
associate-/r*58.2%
frac-2neg58.2%
metadata-eval58.2%
add-sqr-sqrt23.6%
sqrt-unprod57.9%
sqr-neg57.9%
sqrt-unprod34.6%
add-sqr-sqrt58.2%
distribute-frac-neg58.2%
frac-2neg58.2%
clear-num58.2%
Applied egg-rr58.2%
expm1-def55.1%
expm1-log1p55.3%
associate-/l/55.4%
associate-/r*58.0%
Simplified58.0%
if -2.79999999999999983e140 < z < 5.19999999999999963e80Initial program 98.7%
Taylor expanded in y around inf 60.7%
if 5.19999999999999963e80 < z Initial program 88.3%
sub-neg88.3%
+-commutative88.3%
distribute-rgt-neg-in88.3%
fma-udef88.3%
clear-num87.7%
inv-pow87.7%
add-sqr-sqrt48.8%
sqrt-unprod67.3%
sqr-neg67.3%
sqrt-unprod21.7%
add-sqr-sqrt50.9%
Applied egg-rr50.9%
Taylor expanded in z around inf 31.8%
Final simplification53.9%
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 95.8%
Taylor expanded in y around inf 50.1%
Final simplification50.1%
(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 2023293
(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))))