
(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
double code(double x, double y) {
return fabs((x - y)) / fabs(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((x - y)) / abs(y)
end function
public static double code(double x, double y) {
return Math.abs((x - y)) / Math.abs(y);
}
def code(x, y): return math.fabs((x - y)) / math.fabs(y)
function code(x, y) return Float64(abs(Float64(x - y)) / abs(y)) end
function tmp = code(x, y) tmp = abs((x - y)) / abs(y); end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x - y\right|}{\left|y\right|}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (fabs (- x y)) (fabs y)))
double code(double x, double y) {
return fabs((x - y)) / fabs(y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((x - y)) / abs(y)
end function
public static double code(double x, double y) {
return Math.abs((x - y)) / Math.abs(y);
}
def code(x, y): return math.fabs((x - y)) / math.fabs(y)
function code(x, y) return Float64(abs(Float64(x - y)) / abs(y)) end
function tmp = code(x, y) tmp = abs((x - y)) / abs(y); end
code[x_, y_] := N[(N[Abs[N[(x - y), $MachinePrecision]], $MachinePrecision] / N[Abs[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left|x - y\right|}{\left|y\right|}
\end{array}
(FPCore (x y) :precision binary64 (fabs (- 1.0 (/ x y))))
double code(double x, double y) {
return fabs((1.0 - (x / y)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = abs((1.0d0 - (x / y)))
end function
public static double code(double x, double y) {
return Math.abs((1.0 - (x / y)));
}
def code(x, y): return math.fabs((1.0 - (x / y)))
function code(x, y) return abs(Float64(1.0 - Float64(x / y))) end
function tmp = code(x, y) tmp = abs((1.0 - (x / y))); end
code[x_, y_] := N[Abs[N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|1 - \frac{x}{y}\right|
\end{array}
Initial program 100.0%
fabs-sub100.0%
div-fabs100.0%
Applied egg-rr100.0%
div-sub100.0%
*-inverses100.0%
Applied egg-rr100.0%
(FPCore (x y) :precision binary64 (if (or (<= x -7.8e+89) (not (<= x 6.5e+93))) (fabs (/ x y)) (- 1.0 (/ x y))))
double code(double x, double y) {
double tmp;
if ((x <= -7.8e+89) || !(x <= 6.5e+93)) {
tmp = fabs((x / y));
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-7.8d+89)) .or. (.not. (x <= 6.5d+93))) then
tmp = abs((x / y))
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -7.8e+89) || !(x <= 6.5e+93)) {
tmp = Math.abs((x / y));
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -7.8e+89) or not (x <= 6.5e+93): tmp = math.fabs((x / y)) else: tmp = 1.0 - (x / y) return tmp
function code(x, y) tmp = 0.0 if ((x <= -7.8e+89) || !(x <= 6.5e+93)) tmp = abs(Float64(x / y)); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -7.8e+89) || ~((x <= 6.5e+93))) tmp = abs((x / y)); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -7.8e+89], N[Not[LessEqual[x, 6.5e+93]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.8 \cdot 10^{+89} \lor \neg \left(x \leq 6.5 \cdot 10^{+93}\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if x < -7.80000000000000021e89 or 6.4999999999999998e93 < x Initial program 100.0%
fabs-sub100.0%
div-fabs100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 85.5%
neg-mul-185.5%
distribute-neg-frac285.5%
Simplified85.5%
if -7.80000000000000021e89 < x < 6.4999999999999998e93Initial program 100.0%
add-sqr-sqrt47.3%
fabs-sqr47.3%
add-sqr-sqrt6.9%
fabs-sqr6.9%
add-sqr-sqrt7.5%
add-sqr-sqrt16.3%
clear-num16.3%
Applied egg-rr16.3%
div-inv16.3%
Applied egg-rr16.3%
*-commutative16.3%
associate-/r/16.3%
metadata-eval16.3%
div-sub16.3%
*-inverses16.3%
sub-neg16.3%
metadata-eval16.3%
associate-/r*16.3%
+-commutative16.3%
distribute-lft-in16.3%
metadata-eval16.3%
neg-mul-116.3%
sub-neg16.3%
rem-square-sqrt1.2%
fabs-sqr1.2%
rem-square-sqrt1.3%
fabs-sub1.3%
sub-neg1.3%
metadata-eval1.3%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt84.9%
Simplified84.9%
Taylor expanded in y around 0 85.0%
neg-mul-185.0%
sub-neg85.0%
div-sub85.0%
*-inverses85.0%
Simplified85.0%
Final simplification85.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- y))) (t_1 (+ (/ x y) -1.0)))
(if (<= x -7e+113)
t_1
(if (<= x 1.6e+16)
1.0
(if (<= x 1.4e+43)
t_0
(if (<= x 2.7e+111) 1.0 (if (<= x 3.5e+182) t_1 t_0)))))))
double code(double x, double y) {
double t_0 = x / -y;
double t_1 = (x / y) + -1.0;
double tmp;
if (x <= -7e+113) {
tmp = t_1;
} else if (x <= 1.6e+16) {
tmp = 1.0;
} else if (x <= 1.4e+43) {
tmp = t_0;
} else if (x <= 2.7e+111) {
tmp = 1.0;
} else if (x <= 3.5e+182) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x / -y
t_1 = (x / y) + (-1.0d0)
if (x <= (-7d+113)) then
tmp = t_1
else if (x <= 1.6d+16) then
tmp = 1.0d0
else if (x <= 1.4d+43) then
tmp = t_0
else if (x <= 2.7d+111) then
tmp = 1.0d0
else if (x <= 3.5d+182) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / -y;
double t_1 = (x / y) + -1.0;
double tmp;
if (x <= -7e+113) {
tmp = t_1;
} else if (x <= 1.6e+16) {
tmp = 1.0;
} else if (x <= 1.4e+43) {
tmp = t_0;
} else if (x <= 2.7e+111) {
tmp = 1.0;
} else if (x <= 3.5e+182) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / -y t_1 = (x / y) + -1.0 tmp = 0 if x <= -7e+113: tmp = t_1 elif x <= 1.6e+16: tmp = 1.0 elif x <= 1.4e+43: tmp = t_0 elif x <= 2.7e+111: tmp = 1.0 elif x <= 3.5e+182: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(-y)) t_1 = Float64(Float64(x / y) + -1.0) tmp = 0.0 if (x <= -7e+113) tmp = t_1; elseif (x <= 1.6e+16) tmp = 1.0; elseif (x <= 1.4e+43) tmp = t_0; elseif (x <= 2.7e+111) tmp = 1.0; elseif (x <= 3.5e+182) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / -y; t_1 = (x / y) + -1.0; tmp = 0.0; if (x <= -7e+113) tmp = t_1; elseif (x <= 1.6e+16) tmp = 1.0; elseif (x <= 1.4e+43) tmp = t_0; elseif (x <= 2.7e+111) tmp = 1.0; elseif (x <= 3.5e+182) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / (-y)), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]}, If[LessEqual[x, -7e+113], t$95$1, If[LessEqual[x, 1.6e+16], 1.0, If[LessEqual[x, 1.4e+43], t$95$0, If[LessEqual[x, 2.7e+111], 1.0, If[LessEqual[x, 3.5e+182], t$95$1, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-y}\\
t_1 := \frac{x}{y} + -1\\
\mathbf{if}\;x \leq -7 \cdot 10^{+113}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{+111}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+182}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -7.0000000000000001e113 or 2.6999999999999999e111 < x < 3.50000000000000023e182Initial program 99.9%
Taylor expanded in x around -inf 99.9%
fabs-neg99.9%
mul-1-neg99.9%
sub-neg99.9%
fabs-sub99.9%
fabs-div99.9%
rem-square-sqrt54.3%
fabs-sqr54.3%
rem-square-sqrt55.0%
div-sub55.1%
sub-neg55.1%
*-inverses55.1%
metadata-eval55.1%
+-commutative55.1%
Simplified55.1%
if -7.0000000000000001e113 < x < 1.6e16 or 1.40000000000000009e43 < x < 2.6999999999999999e111Initial program 100.0%
add-sqr-sqrt46.1%
fabs-sqr46.1%
add-sqr-sqrt5.8%
fabs-sqr5.8%
add-sqr-sqrt6.4%
add-sqr-sqrt15.9%
clear-num15.9%
Applied egg-rr15.9%
div-inv15.9%
Applied egg-rr15.9%
*-commutative15.9%
associate-/r/15.9%
metadata-eval15.9%
div-sub15.9%
*-inverses15.9%
sub-neg15.9%
metadata-eval15.9%
associate-/r*15.9%
+-commutative15.9%
distribute-lft-in15.9%
metadata-eval15.9%
neg-mul-115.9%
sub-neg15.9%
rem-square-sqrt1.2%
fabs-sqr1.2%
rem-square-sqrt1.3%
fabs-sub1.3%
sub-neg1.3%
metadata-eval1.3%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt85.3%
Simplified85.3%
Taylor expanded in y around inf 71.6%
if 1.6e16 < x < 1.40000000000000009e43 or 3.50000000000000023e182 < x Initial program 100.0%
add-sqr-sqrt93.6%
fabs-sqr93.6%
add-sqr-sqrt27.0%
fabs-sqr27.0%
add-sqr-sqrt27.3%
add-sqr-sqrt27.6%
clear-num27.6%
Applied egg-rr27.6%
div-inv27.6%
Applied egg-rr27.6%
*-commutative27.6%
associate-/r/27.6%
metadata-eval27.6%
div-sub27.6%
*-inverses27.6%
sub-neg27.6%
metadata-eval27.6%
associate-/r*27.6%
+-commutative27.6%
distribute-lft-in27.6%
metadata-eval27.6%
neg-mul-127.6%
sub-neg27.6%
rem-square-sqrt0.3%
fabs-sqr0.3%
rem-square-sqrt0.4%
fabs-sub0.4%
sub-neg0.4%
metadata-eval0.4%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt72.7%
Simplified72.7%
Taylor expanded in y around 0 66.8%
associate-*r/66.8%
neg-mul-166.8%
Simplified66.8%
Final simplification67.6%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (- y))))
(if (<= x -8.8e+111)
(/ x y)
(if (<= x 1.6e+16)
1.0
(if (<= x 4.8e+43)
t_0
(if (<= x 1.35e+111) 1.0 (if (<= x 4e+182) (/ x y) t_0)))))))
double code(double x, double y) {
double t_0 = x / -y;
double tmp;
if (x <= -8.8e+111) {
tmp = x / y;
} else if (x <= 1.6e+16) {
tmp = 1.0;
} else if (x <= 4.8e+43) {
tmp = t_0;
} else if (x <= 1.35e+111) {
tmp = 1.0;
} else if (x <= 4e+182) {
tmp = x / y;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / -y
if (x <= (-8.8d+111)) then
tmp = x / y
else if (x <= 1.6d+16) then
tmp = 1.0d0
else if (x <= 4.8d+43) then
tmp = t_0
else if (x <= 1.35d+111) then
tmp = 1.0d0
else if (x <= 4d+182) then
tmp = x / y
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x / -y;
double tmp;
if (x <= -8.8e+111) {
tmp = x / y;
} else if (x <= 1.6e+16) {
tmp = 1.0;
} else if (x <= 4.8e+43) {
tmp = t_0;
} else if (x <= 1.35e+111) {
tmp = 1.0;
} else if (x <= 4e+182) {
tmp = x / y;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / -y tmp = 0 if x <= -8.8e+111: tmp = x / y elif x <= 1.6e+16: tmp = 1.0 elif x <= 4.8e+43: tmp = t_0 elif x <= 1.35e+111: tmp = 1.0 elif x <= 4e+182: tmp = x / y else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(-y)) tmp = 0.0 if (x <= -8.8e+111) tmp = Float64(x / y); elseif (x <= 1.6e+16) tmp = 1.0; elseif (x <= 4.8e+43) tmp = t_0; elseif (x <= 1.35e+111) tmp = 1.0; elseif (x <= 4e+182) tmp = Float64(x / y); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / -y; tmp = 0.0; if (x <= -8.8e+111) tmp = x / y; elseif (x <= 1.6e+16) tmp = 1.0; elseif (x <= 4.8e+43) tmp = t_0; elseif (x <= 1.35e+111) tmp = 1.0; elseif (x <= 4e+182) tmp = x / y; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / (-y)), $MachinePrecision]}, If[LessEqual[x, -8.8e+111], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.6e+16], 1.0, If[LessEqual[x, 4.8e+43], t$95$0, If[LessEqual[x, 1.35e+111], 1.0, If[LessEqual[x, 4e+182], N[(x / y), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-y}\\
\mathbf{if}\;x \leq -8.8 \cdot 10^{+111}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+43}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{+111}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+182}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.79999999999999994e111 or 1.3499999999999999e111 < x < 4.0000000000000003e182Initial program 99.9%
add-sqr-sqrt39.4%
fabs-sqr39.4%
add-sqr-sqrt20.5%
fabs-sqr20.5%
add-sqr-sqrt20.8%
add-sqr-sqrt55.0%
Applied egg-rr55.0%
Taylor expanded in x around inf 53.7%
if -8.79999999999999994e111 < x < 1.6e16 or 4.80000000000000046e43 < x < 1.3499999999999999e111Initial program 100.0%
add-sqr-sqrt46.1%
fabs-sqr46.1%
add-sqr-sqrt5.8%
fabs-sqr5.8%
add-sqr-sqrt6.4%
add-sqr-sqrt15.9%
clear-num15.9%
Applied egg-rr15.9%
div-inv15.9%
Applied egg-rr15.9%
*-commutative15.9%
associate-/r/15.9%
metadata-eval15.9%
div-sub15.9%
*-inverses15.9%
sub-neg15.9%
metadata-eval15.9%
associate-/r*15.9%
+-commutative15.9%
distribute-lft-in15.9%
metadata-eval15.9%
neg-mul-115.9%
sub-neg15.9%
rem-square-sqrt1.2%
fabs-sqr1.2%
rem-square-sqrt1.3%
fabs-sub1.3%
sub-neg1.3%
metadata-eval1.3%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt85.3%
Simplified85.3%
Taylor expanded in y around inf 71.6%
if 1.6e16 < x < 4.80000000000000046e43 or 4.0000000000000003e182 < x Initial program 100.0%
add-sqr-sqrt93.6%
fabs-sqr93.6%
add-sqr-sqrt27.0%
fabs-sqr27.0%
add-sqr-sqrt27.3%
add-sqr-sqrt27.6%
clear-num27.6%
Applied egg-rr27.6%
div-inv27.6%
Applied egg-rr27.6%
*-commutative27.6%
associate-/r/27.6%
metadata-eval27.6%
div-sub27.6%
*-inverses27.6%
sub-neg27.6%
metadata-eval27.6%
associate-/r*27.6%
+-commutative27.6%
distribute-lft-in27.6%
metadata-eval27.6%
neg-mul-127.6%
sub-neg27.6%
rem-square-sqrt0.3%
fabs-sqr0.3%
rem-square-sqrt0.4%
fabs-sub0.4%
sub-neg0.4%
metadata-eval0.4%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt72.7%
Simplified72.7%
Taylor expanded in y around 0 66.8%
associate-*r/66.8%
neg-mul-166.8%
Simplified66.8%
Final simplification67.3%
(FPCore (x y) :precision binary64 (if (or (<= y -3.5e-252) (not (<= y 2.25e-287))) (- 1.0 (/ x y)) (+ (/ x y) -1.0)))
double code(double x, double y) {
double tmp;
if ((y <= -3.5e-252) || !(y <= 2.25e-287)) {
tmp = 1.0 - (x / y);
} else {
tmp = (x / y) + -1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-3.5d-252)) .or. (.not. (y <= 2.25d-287))) then
tmp = 1.0d0 - (x / y)
else
tmp = (x / y) + (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3.5e-252) || !(y <= 2.25e-287)) {
tmp = 1.0 - (x / y);
} else {
tmp = (x / y) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3.5e-252) or not (y <= 2.25e-287): tmp = 1.0 - (x / y) else: tmp = (x / y) + -1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -3.5e-252) || !(y <= 2.25e-287)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(Float64(x / y) + -1.0); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3.5e-252) || ~((y <= 2.25e-287))) tmp = 1.0 - (x / y); else tmp = (x / y) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3.5e-252], N[Not[LessEqual[y, 2.25e-287]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-252} \lor \neg \left(y \leq 2.25 \cdot 10^{-287}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -1\\
\end{array}
\end{array}
if y < -3.49999999999999986e-252 or 2.25000000000000008e-287 < y Initial program 100.0%
add-sqr-sqrt52.2%
fabs-sqr52.2%
add-sqr-sqrt11.8%
fabs-sqr11.8%
add-sqr-sqrt12.4%
add-sqr-sqrt21.9%
clear-num21.9%
Applied egg-rr21.9%
div-inv21.9%
Applied egg-rr21.9%
*-commutative21.9%
associate-/r/21.9%
metadata-eval21.9%
div-sub21.9%
*-inverses21.9%
sub-neg21.9%
metadata-eval21.9%
associate-/r*21.9%
+-commutative21.9%
distribute-lft-in21.9%
metadata-eval21.9%
neg-mul-121.9%
sub-neg21.9%
rem-square-sqrt1.0%
fabs-sqr1.0%
rem-square-sqrt1.1%
fabs-sub1.1%
sub-neg1.1%
metadata-eval1.1%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt79.1%
Simplified79.1%
Taylor expanded in y around 0 79.2%
neg-mul-179.2%
sub-neg79.2%
div-sub79.2%
*-inverses79.2%
Simplified79.2%
if -3.49999999999999986e-252 < y < 2.25000000000000008e-287Initial program 100.0%
Taylor expanded in x around -inf 100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-sub100.0%
fabs-div100.0%
rem-square-sqrt63.4%
fabs-sqr63.4%
rem-square-sqrt63.9%
div-sub63.9%
sub-neg63.9%
*-inverses63.9%
metadata-eval63.9%
+-commutative63.9%
Simplified63.9%
Final simplification77.9%
(FPCore (x y) :precision binary64 (if (or (<= x -4.9e+107) (not (<= x 1.45e+110))) (/ x y) 1.0))
double code(double x, double y) {
double tmp;
if ((x <= -4.9e+107) || !(x <= 1.45e+110)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((x <= (-4.9d+107)) .or. (.not. (x <= 1.45d+110))) then
tmp = x / y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((x <= -4.9e+107) || !(x <= 1.45e+110)) {
tmp = x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -4.9e+107) or not (x <= 1.45e+110): tmp = x / y else: tmp = 1.0 return tmp
function code(x, y) tmp = 0.0 if ((x <= -4.9e+107) || !(x <= 1.45e+110)) tmp = Float64(x / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -4.9e+107) || ~((x <= 1.45e+110))) tmp = x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -4.9e+107], N[Not[LessEqual[x, 1.45e+110]], $MachinePrecision]], N[(x / y), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.9 \cdot 10^{+107} \lor \neg \left(x \leq 1.45 \cdot 10^{+110}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -4.9000000000000001e107 or 1.45e110 < x Initial program 100.0%
add-sqr-sqrt56.9%
fabs-sqr56.9%
add-sqr-sqrt21.8%
fabs-sqr21.8%
add-sqr-sqrt22.1%
add-sqr-sqrt45.7%
Applied egg-rr45.7%
Taylor expanded in x around inf 44.9%
if -4.9000000000000001e107 < x < 1.45e110Initial program 100.0%
add-sqr-sqrt48.2%
fabs-sqr48.2%
add-sqr-sqrt7.2%
fabs-sqr7.2%
add-sqr-sqrt7.8%
add-sqr-sqrt16.8%
clear-num16.8%
Applied egg-rr16.8%
div-inv16.8%
Applied egg-rr16.8%
*-commutative16.8%
associate-/r/16.8%
metadata-eval16.8%
div-sub16.8%
*-inverses16.8%
sub-neg16.8%
metadata-eval16.8%
associate-/r*16.8%
+-commutative16.8%
distribute-lft-in16.8%
metadata-eval16.8%
neg-mul-116.8%
sub-neg16.8%
rem-square-sqrt1.2%
fabs-sqr1.2%
rem-square-sqrt1.3%
fabs-sub1.3%
sub-neg1.3%
metadata-eval1.3%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt84.4%
Simplified84.4%
Taylor expanded in y around inf 68.5%
Final simplification61.4%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
add-sqr-sqrt50.8%
fabs-sqr50.8%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt12.1%
add-sqr-sqrt25.5%
clear-num25.5%
Applied egg-rr25.5%
div-inv25.5%
Applied egg-rr25.5%
*-commutative25.5%
associate-/r/25.5%
metadata-eval25.5%
div-sub25.5%
*-inverses25.5%
sub-neg25.5%
metadata-eval25.5%
associate-/r*25.5%
+-commutative25.5%
distribute-lft-in25.5%
metadata-eval25.5%
neg-mul-125.5%
sub-neg25.5%
rem-square-sqrt0.9%
fabs-sqr0.9%
rem-square-sqrt1.1%
fabs-sub1.1%
sub-neg1.1%
metadata-eval1.1%
rem-square-sqrt0.1%
fabs-sqr0.1%
rem-square-sqrt75.5%
Simplified75.5%
Taylor expanded in y around inf 52.9%
(FPCore (x y) :precision binary64 -1.0)
double code(double x, double y) {
return -1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -1.0d0
end function
public static double code(double x, double y) {
return -1.0;
}
def code(x, y): return -1.0
function code(x, y) return -1.0 end
function tmp = code(x, y) tmp = -1.0; end
code[x_, y_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 100.0%
add-sqr-sqrt50.8%
fabs-sqr50.8%
add-sqr-sqrt11.6%
fabs-sqr11.6%
add-sqr-sqrt12.1%
add-sqr-sqrt25.5%
Applied egg-rr25.5%
Taylor expanded in x around 0 1.3%
herbie shell --seed 2024096
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))