
(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 10 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}
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= (* z t) (- INFINITY))
(fabs (/ (/ x_m z) t))
(if (<= (* z t) 2e+196)
(/ x_m (- y (* z t)))
(* (/ x_m z) (/ (cbrt -1.0) t))))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = fabs(((x_m / z) / t));
} else if ((z * t) <= 2e+196) {
tmp = x_m / (y - (z * t));
} else {
tmp = (x_m / z) * (cbrt(-1.0) / t);
}
return x_s * tmp;
}
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = Math.abs(((x_m / z) / t));
} else if ((z * t) <= 2e+196) {
tmp = x_m / (y - (z * t));
} else {
tmp = (x_m / z) * (Math.cbrt(-1.0) / t);
}
return x_s * tmp;
}
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = abs(Float64(Float64(x_m / z) / t)); elseif (Float64(z * t) <= 2e+196) tmp = Float64(x_m / Float64(y - Float64(z * t))); else tmp = Float64(Float64(x_m / z) * Float64(cbrt(-1.0) / t)); end return Float64(x_s * tmp) end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[Abs[N[(N[(x$95$m / z), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+196], N[(x$95$m / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / z), $MachinePrecision] * N[(N[Power[-1.0, 1/3], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\left|\frac{\frac{x_m}{z}}{t}\right|\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+196}:\\
\;\;\;\;\frac{x_m}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{z} \cdot \frac{\sqrt[3]{-1}}{t}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 56.1%
Taylor expanded in y around 0 56.1%
associate-*r/56.1%
neg-mul-156.1%
Simplified56.1%
associate-/r*100.0%
add-sqr-sqrt73.2%
sqrt-unprod68.8%
clear-num68.7%
clear-num68.6%
unpow-168.6%
unpow-168.6%
pow-prod-up68.7%
div-inv68.7%
clear-num68.7%
add-sqr-sqrt15.0%
sqrt-unprod48.8%
sqr-neg48.8%
sqrt-unprod53.5%
add-sqr-sqrt68.7%
metadata-eval68.7%
Applied egg-rr68.7%
metadata-eval68.7%
pow-sqr68.6%
rem-sqrt-square74.4%
unpow-174.4%
*-commutative74.4%
associate-*l/56.1%
associate-/l*74.4%
associate-/l*74.7%
*-lft-identity74.7%
Simplified74.7%
if -inf.0 < (*.f64 z t) < 1.9999999999999999e196Initial program 99.9%
if 1.9999999999999999e196 < (*.f64 z t) Initial program 78.9%
Taylor expanded in y around 0 78.9%
mul-1-neg78.9%
associate-/r*99.8%
distribute-neg-frac99.8%
Simplified99.8%
add-cbrt-cube73.4%
pow373.4%
distribute-neg-frac73.4%
Applied egg-rr73.4%
Taylor expanded in x around 0 78.9%
*-commutative78.9%
times-frac99.8%
Simplified99.8%
Final simplification98.4%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= (* z t) (- INFINITY))
(fabs (/ (/ x_m z) t))
(if (<= (* z t) 2e+196) (/ x_m (- y (* z t))) (/ (/ (- x_m) t) z)))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((z * t) <= -((double) INFINITY)) {
tmp = fabs(((x_m / z) / t));
} else if ((z * t) <= 2e+196) {
tmp = x_m / (y - (z * t));
} else {
tmp = (-x_m / t) / z;
}
return x_s * tmp;
}
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((z * t) <= -Double.POSITIVE_INFINITY) {
tmp = Math.abs(((x_m / z) / t));
} else if ((z * t) <= 2e+196) {
tmp = x_m / (y - (z * t));
} else {
tmp = (-x_m / t) / z;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): tmp = 0 if (z * t) <= -math.inf: tmp = math.fabs(((x_m / z) / t)) elif (z * t) <= 2e+196: tmp = x_m / (y - (z * t)) else: tmp = (-x_m / t) / z return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) tmp = 0.0 if (Float64(z * t) <= Float64(-Inf)) tmp = abs(Float64(Float64(x_m / z) / t)); elseif (Float64(z * t) <= 2e+196) tmp = Float64(x_m / Float64(y - Float64(z * t))); else tmp = Float64(Float64(Float64(-x_m) / t) / z); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp_2 = code(x_s, x_m, y, z, t)
tmp = 0.0;
if ((z * t) <= -Inf)
tmp = abs(((x_m / z) / t));
elseif ((z * t) <= 2e+196)
tmp = x_m / (y - (z * t));
else
tmp = (-x_m / t) / z;
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[Abs[N[(N[(x$95$m / z), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+196], N[(x$95$m / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-x$95$m) / t), $MachinePrecision] / z), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty:\\
\;\;\;\;\left|\frac{\frac{x_m}{z}}{t}\right|\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+196}:\\
\;\;\;\;\frac{x_m}{y - z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-x_m}{t}}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0Initial program 56.1%
Taylor expanded in y around 0 56.1%
associate-*r/56.1%
neg-mul-156.1%
Simplified56.1%
associate-/r*100.0%
add-sqr-sqrt73.2%
sqrt-unprod68.8%
clear-num68.7%
clear-num68.6%
unpow-168.6%
unpow-168.6%
pow-prod-up68.7%
div-inv68.7%
clear-num68.7%
add-sqr-sqrt15.0%
sqrt-unprod48.8%
sqr-neg48.8%
sqrt-unprod53.5%
add-sqr-sqrt68.7%
metadata-eval68.7%
Applied egg-rr68.7%
metadata-eval68.7%
pow-sqr68.6%
rem-sqrt-square74.4%
unpow-174.4%
*-commutative74.4%
associate-*l/56.1%
associate-/l*74.4%
associate-/l*74.7%
*-lft-identity74.7%
Simplified74.7%
if -inf.0 < (*.f64 z t) < 1.9999999999999999e196Initial program 99.9%
if 1.9999999999999999e196 < (*.f64 z t) Initial program 78.9%
Taylor expanded in y around 0 78.9%
mul-1-neg78.9%
associate-/r*99.8%
distribute-neg-frac99.8%
Simplified99.8%
Final simplification98.4%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (or (<= (* z t) (- INFINITY)) (not (<= (* z t) 2e+196)))
(/ (/ (- x_m) t) z)
(/ x_m (- y (* z t))))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -((double) INFINITY)) || !((z * t) <= 2e+196)) {
tmp = (-x_m / t) / z;
} else {
tmp = x_m / (y - (z * t));
}
return x_s * tmp;
}
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -Double.POSITIVE_INFINITY) || !((z * t) <= 2e+196)) {
tmp = (-x_m / t) / z;
} else {
tmp = x_m / (y - (z * t));
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): tmp = 0 if ((z * t) <= -math.inf) or not ((z * t) <= 2e+196): tmp = (-x_m / t) / z else: tmp = x_m / (y - (z * t)) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) tmp = 0.0 if ((Float64(z * t) <= Float64(-Inf)) || !(Float64(z * t) <= 2e+196)) tmp = Float64(Float64(Float64(-x_m) / t) / z); else tmp = Float64(x_m / Float64(y - Float64(z * t))); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp_2 = code(x_s, x_m, y, z, t)
tmp = 0.0;
if (((z * t) <= -Inf) || ~(((z * t) <= 2e+196)))
tmp = (-x_m / t) / z;
else
tmp = x_m / (y - (z * t));
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[Or[LessEqual[N[(z * t), $MachinePrecision], (-Infinity)], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e+196]], $MachinePrecision]], N[(N[((-x$95$m) / t), $MachinePrecision] / z), $MachinePrecision], N[(x$95$m / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -\infty \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+196}\right):\\
\;\;\;\;\frac{\frac{-x_m}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{y - z \cdot t}\\
\end{array}
\end{array}
if (*.f64 z t) < -inf.0 or 1.9999999999999999e196 < (*.f64 z t) Initial program 70.8%
Taylor expanded in y around 0 70.8%
mul-1-neg70.8%
associate-/r*99.9%
distribute-neg-frac99.9%
Simplified99.9%
if -inf.0 < (*.f64 z t) < 1.9999999999999999e196Initial program 99.9%
Final simplification99.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (or (<= (* z t) -5e+23) (not (<= (* z t) 1e+36)))
(/ (- x_m) (* z t))
(/ x_m y))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -5e+23) || !((z * t) <= 1e+36)) {
tmp = -x_m / (z * t);
} else {
tmp = x_m / y;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((z * t) <= (-5d+23)) .or. (.not. ((z * t) <= 1d+36))) then
tmp = -x_m / (z * t)
else
tmp = x_m / y
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -5e+23) || !((z * t) <= 1e+36)) {
tmp = -x_m / (z * t);
} else {
tmp = x_m / y;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): tmp = 0 if ((z * t) <= -5e+23) or not ((z * t) <= 1e+36): tmp = -x_m / (z * t) else: tmp = x_m / y return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) tmp = 0.0 if ((Float64(z * t) <= -5e+23) || !(Float64(z * t) <= 1e+36)) tmp = Float64(Float64(-x_m) / Float64(z * t)); else tmp = Float64(x_m / y); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp_2 = code(x_s, x_m, y, z, t)
tmp = 0.0;
if (((z * t) <= -5e+23) || ~(((z * t) <= 1e+36)))
tmp = -x_m / (z * t);
else
tmp = x_m / y;
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[Or[LessEqual[N[(z * t), $MachinePrecision], -5e+23], N[Not[LessEqual[N[(z * t), $MachinePrecision], 1e+36]], $MachinePrecision]], N[((-x$95$m) / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x$95$m / y), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+23} \lor \neg \left(z \cdot t \leq 10^{+36}\right):\\
\;\;\;\;\frac{-x_m}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999999e23 or 1.00000000000000004e36 < (*.f64 z t) Initial program 89.8%
Taylor expanded in y around 0 76.8%
associate-*r/76.8%
neg-mul-176.8%
Simplified76.8%
if -4.9999999999999999e23 < (*.f64 z t) < 1.00000000000000004e36Initial program 99.9%
Taylor expanded in y around inf 78.2%
Final simplification77.5%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (or (<= (* z t) -5e+23) (not (<= (* z t) 1e+36)))
(/ (/ (- x_m) t) z)
(/ x_m y))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -5e+23) || !((z * t) <= 1e+36)) {
tmp = (-x_m / t) / z;
} else {
tmp = x_m / y;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((z * t) <= (-5d+23)) .or. (.not. ((z * t) <= 1d+36))) then
tmp = (-x_m / t) / z
else
tmp = x_m / y
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -5e+23) || !((z * t) <= 1e+36)) {
tmp = (-x_m / t) / z;
} else {
tmp = x_m / y;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): tmp = 0 if ((z * t) <= -5e+23) or not ((z * t) <= 1e+36): tmp = (-x_m / t) / z else: tmp = x_m / y return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) tmp = 0.0 if ((Float64(z * t) <= -5e+23) || !(Float64(z * t) <= 1e+36)) tmp = Float64(Float64(Float64(-x_m) / t) / z); else tmp = Float64(x_m / y); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp_2 = code(x_s, x_m, y, z, t)
tmp = 0.0;
if (((z * t) <= -5e+23) || ~(((z * t) <= 1e+36)))
tmp = (-x_m / t) / z;
else
tmp = x_m / y;
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[Or[LessEqual[N[(z * t), $MachinePrecision], -5e+23], N[Not[LessEqual[N[(z * t), $MachinePrecision], 1e+36]], $MachinePrecision]], N[(N[((-x$95$m) / t), $MachinePrecision] / z), $MachinePrecision], N[(x$95$m / y), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+23} \lor \neg \left(z \cdot t \leq 10^{+36}\right):\\
\;\;\;\;\frac{\frac{-x_m}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -4.9999999999999999e23 or 1.00000000000000004e36 < (*.f64 z t) Initial program 89.8%
Taylor expanded in y around 0 76.8%
mul-1-neg76.8%
associate-/r*84.2%
distribute-neg-frac84.2%
Simplified84.2%
if -4.9999999999999999e23 < (*.f64 z t) < 1.00000000000000004e36Initial program 99.9%
Taylor expanded in y around inf 78.2%
Final simplification81.1%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (or (<= (* z t) -2e+164) (not (<= (* z t) 2e+160)))
(/ x_m (* z t))
(/ x_m y))))x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -2e+164) || !((z * t) <= 2e+160)) {
tmp = x_m / (z * t);
} else {
tmp = x_m / y;
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((z * t) <= (-2d+164)) .or. (.not. ((z * t) <= 2d+160))) then
tmp = x_m / (z * t)
else
tmp = x_m / y
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (((z * t) <= -2e+164) || !((z * t) <= 2e+160)) {
tmp = x_m / (z * t);
} else {
tmp = x_m / y;
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): tmp = 0 if ((z * t) <= -2e+164) or not ((z * t) <= 2e+160): tmp = x_m / (z * t) else: tmp = x_m / y return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) tmp = 0.0 if ((Float64(z * t) <= -2e+164) || !(Float64(z * t) <= 2e+160)) tmp = Float64(x_m / Float64(z * t)); else tmp = Float64(x_m / y); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp_2 = code(x_s, x_m, y, z, t)
tmp = 0.0;
if (((z * t) <= -2e+164) || ~(((z * t) <= 2e+160)))
tmp = x_m / (z * t);
else
tmp = x_m / y;
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+164], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e+160]], $MachinePrecision]], N[(x$95$m / N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x$95$m / y), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+164} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+160}\right):\\
\;\;\;\;\frac{x_m}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -2e164 or 2.00000000000000001e160 < (*.f64 z t) Initial program 82.9%
Taylor expanded in y around 0 79.2%
associate-*r/79.2%
neg-mul-179.2%
Simplified79.2%
associate-/r*94.1%
expm1-log1p-u91.3%
expm1-udef50.8%
associate-/r*50.8%
add-sqr-sqrt17.6%
sqrt-unprod44.7%
sqr-neg44.7%
sqrt-unprod31.9%
add-sqr-sqrt48.0%
Applied egg-rr48.0%
expm1-def47.5%
expm1-log1p47.6%
*-commutative47.6%
Simplified47.6%
if -2e164 < (*.f64 z t) < 2.00000000000000001e160Initial program 99.9%
Taylor expanded in y around inf 65.2%
Final simplification60.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z t) :precision binary64 (* x_s (if (<= t 1.2e+263) (/ x_m y) (* z (/ x_m t)))))
x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= 1.2e+263) {
tmp = x_m / y;
} else {
tmp = z * (x_m / t);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= 1.2d+263) then
tmp = x_m / y
else
tmp = z * (x_m / t)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= 1.2e+263) {
tmp = x_m / y;
} else {
tmp = z * (x_m / t);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): tmp = 0 if t <= 1.2e+263: tmp = x_m / y else: tmp = z * (x_m / t) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) tmp = 0.0 if (t <= 1.2e+263) tmp = Float64(x_m / y); else tmp = Float64(z * Float64(x_m / t)); end return Float64(x_s * tmp) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp_2 = code(x_s, x_m, y, z, t)
tmp = 0.0;
if (t <= 1.2e+263)
tmp = x_m / y;
else
tmp = z * (x_m / t);
end
tmp_2 = x_s * tmp;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[t, 1.2e+263], N[(x$95$m / y), $MachinePrecision], N[(z * N[(x$95$m / t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq 1.2 \cdot 10^{+263}:\\
\;\;\;\;\frac{x_m}{y}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{x_m}{t}\\
\end{array}
\end{array}
if t < 1.2e263Initial program 95.2%
Taylor expanded in y around inf 52.6%
if 1.2e263 < t Initial program 94.0%
Taylor expanded in y around 0 76.4%
mul-1-neg76.4%
associate-/r*78.9%
distribute-neg-frac78.9%
Simplified78.9%
add-cbrt-cube66.8%
pow366.8%
distribute-neg-frac66.8%
Applied egg-rr66.8%
Taylor expanded in x around 0 76.4%
*-commutative76.4%
times-frac81.9%
Simplified81.9%
Applied egg-rr33.1%
associate-*l/48.2%
Simplified48.2%
Final simplification52.4%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z t) :precision binary64 (* x_s (/ x_m y)))
x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (x_m / y);
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_s * (x_m / y)
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (x_m / y);
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): return x_s * (x_m / y)
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) return Float64(x_s * Float64(x_m / y)) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp = code(x_s, x_m, y, z, t)
tmp = x_s * (x_m / y);
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot \frac{x_m}{y}
\end{array}
Initial program 95.1%
Taylor expanded in y around inf 51.5%
Final simplification51.5%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z t) :precision binary64 (* x_s 1.0))
x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
return x_s * 1.0;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_s * 1.0d0
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
return x_s * 1.0;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): return x_s * 1.0
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) return Float64(x_s * 1.0) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp = code(x_s, x_m, y, z, t)
tmp = x_s * 1.0;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * 1.0), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot 1
\end{array}
Initial program 95.1%
Taylor expanded in y around 0 51.6%
mul-1-neg51.6%
associate-/r*55.7%
distribute-neg-frac55.7%
Simplified55.7%
add-cbrt-cube40.7%
pow340.7%
distribute-neg-frac40.7%
Applied egg-rr40.7%
Taylor expanded in x around 0 51.6%
*-commutative51.6%
times-frac52.8%
Simplified52.8%
Applied egg-rr0.8%
*-inverses3.7%
Simplified3.7%
Final simplification3.7%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z t) :precision binary64 (* x_s x_m))
x_m = fabs(x);
x_s = copysign(1.0, x);
assert(x_m < y && y < z && z < t);
double code(double x_s, double x_m, double y, double z, double t) {
return x_s * x_m;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_s * x_m
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
assert x_m < y && y < z && z < t;
public static double code(double x_s, double x_m, double y, double z, double t) {
return x_s * x_m;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) [x_m, y, z, t] = sort([x_m, y, z, t]) def code(x_s, x_m, y, z, t): return x_s * x_m
x_m = abs(x) x_s = copysign(1.0, x) x_m, y, z, t = sort([x_m, y, z, t]) function code(x_s, x_m, y, z, t) return Float64(x_s * x_m) end
x_m = abs(x);
x_s = sign(x) * abs(1.0);
x_m, y, z, t = num2cell(sort([x_m, y, z, t])){:}
function tmp = code(x_s, x_m, y, z, t)
tmp = x_s * x_m;
end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, z, and t should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z, t] = \mathsf{sort}([x_m, y, z, t])\\
\\
x_s \cdot x_m
\end{array}
Initial program 95.1%
Taylor expanded in y around 0 51.6%
associate-*r/51.6%
neg-mul-151.6%
Simplified51.6%
associate-/r*55.7%
expm1-log1p-u47.0%
expm1-udef32.4%
associate-/r*33.1%
add-sqr-sqrt13.7%
sqrt-unprod26.5%
sqr-neg26.5%
sqrt-unprod14.9%
add-sqr-sqrt24.8%
Applied egg-rr24.8%
expm1-def18.0%
expm1-log1p20.1%
*-commutative20.1%
Simplified20.1%
Applied egg-rr3.1%
*-commutative3.1%
associate-*l/1.7%
associate-/l*1.3%
*-inverses4.2%
Simplified4.2%
Final simplification4.2%
(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 2024018
(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))))