
(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 7 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%
Taylor expanded in x around -inf 100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-div100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (or (<= y -1.25e+79) (not (<= y 1.8e-37))) (/ y (+ x y)) (fabs (/ x y))))
double code(double x, double y) {
double tmp;
if ((y <= -1.25e+79) || !(y <= 1.8e-37)) {
tmp = y / (x + y);
} else {
tmp = fabs((x / y));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.25d+79)) .or. (.not. (y <= 1.8d-37))) then
tmp = y / (x + y)
else
tmp = abs((x / y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.25e+79) || !(y <= 1.8e-37)) {
tmp = y / (x + y);
} else {
tmp = Math.abs((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.25e+79) or not (y <= 1.8e-37): tmp = y / (x + y) else: tmp = math.fabs((x / y)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.25e+79) || !(y <= 1.8e-37)) tmp = Float64(y / Float64(x + y)); else tmp = abs(Float64(x / y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.25e+79) || ~((y <= 1.8e-37))) tmp = y / (x + y); else tmp = abs((x / y)); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.25e+79], N[Not[LessEqual[y, 1.8e-37]], $MachinePrecision]], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+79} \lor \neg \left(y \leq 1.8 \cdot 10^{-37}\right):\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\
\end{array}
\end{array}
if y < -1.25e79 or 1.80000000000000004e-37 < y Initial 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-sqrt12.5%
fabs-sqr12.5%
rem-square-sqrt13.9%
div-sub13.9%
sub-neg13.9%
*-inverses13.9%
metadata-eval13.9%
+-commutative13.9%
Simplified13.9%
+-commutative13.9%
metadata-eval13.9%
sub-neg13.9%
*-inverses13.9%
div-sub13.9%
clear-num13.8%
associate-/r/13.9%
flip--4.2%
associate-*r/4.2%
Applied egg-rr4.2%
Taylor expanded in y around inf 1.8%
neg-mul-11.8%
Simplified1.8%
expm1-log1p-u1.8%
expm1-udef1.7%
*-un-lft-identity1.7%
*-commutative1.7%
*-commutative1.7%
*-un-lft-identity1.7%
add-sqr-sqrt0.6%
sqrt-unprod24.0%
sqr-neg24.0%
sqrt-unprod45.0%
add-sqr-sqrt80.7%
Applied egg-rr80.7%
expm1-def80.9%
expm1-log1p80.9%
Simplified80.9%
if -1.25e79 < y < 1.80000000000000004e-37Initial program 100.0%
Taylor expanded in x around -inf 100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-div100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Taylor expanded in x around inf 77.5%
mul-1-neg77.5%
distribute-frac-neg77.5%
Simplified77.5%
Final simplification79.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ x y))))
(if (<= y -9.8e-132)
t_0
(if (<= y 5.1e-252)
(/ x y)
(if (<= y 6.5e-71)
(* x (/ (/ x y) (- y x)))
(if (<= y 3.4e-39) (+ (/ x y) -1.0) t_0))))))
double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (y <= -9.8e-132) {
tmp = t_0;
} else if (y <= 5.1e-252) {
tmp = x / y;
} else if (y <= 6.5e-71) {
tmp = x * ((x / y) / (y - x));
} else if (y <= 3.4e-39) {
tmp = (x / y) + -1.0;
} 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 = y / (x + y)
if (y <= (-9.8d-132)) then
tmp = t_0
else if (y <= 5.1d-252) then
tmp = x / y
else if (y <= 6.5d-71) then
tmp = x * ((x / y) / (y - x))
else if (y <= 3.4d-39) then
tmp = (x / y) + (-1.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (y <= -9.8e-132) {
tmp = t_0;
} else if (y <= 5.1e-252) {
tmp = x / y;
} else if (y <= 6.5e-71) {
tmp = x * ((x / y) / (y - x));
} else if (y <= 3.4e-39) {
tmp = (x / y) + -1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = y / (x + y) tmp = 0 if y <= -9.8e-132: tmp = t_0 elif y <= 5.1e-252: tmp = x / y elif y <= 6.5e-71: tmp = x * ((x / y) / (y - x)) elif y <= 3.4e-39: tmp = (x / y) + -1.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(y / Float64(x + y)) tmp = 0.0 if (y <= -9.8e-132) tmp = t_0; elseif (y <= 5.1e-252) tmp = Float64(x / y); elseif (y <= 6.5e-71) tmp = Float64(x * Float64(Float64(x / y) / Float64(y - x))); elseif (y <= 3.4e-39) tmp = Float64(Float64(x / y) + -1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = y / (x + y); tmp = 0.0; if (y <= -9.8e-132) tmp = t_0; elseif (y <= 5.1e-252) tmp = x / y; elseif (y <= 6.5e-71) tmp = x * ((x / y) / (y - x)); elseif (y <= 3.4e-39) tmp = (x / y) + -1.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.8e-132], t$95$0, If[LessEqual[y, 5.1e-252], N[(x / y), $MachinePrecision], If[LessEqual[y, 6.5e-71], N[(x * N[(N[(x / y), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e-39], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;y \leq -9.8 \cdot 10^{-132}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5.1 \cdot 10^{-252}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-71}:\\
\;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-39}:\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -9.79999999999999961e-132 or 3.3999999999999999e-39 < y Initial 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-sqrt15.5%
fabs-sqr15.5%
rem-square-sqrt16.8%
div-sub16.8%
sub-neg16.8%
*-inverses16.8%
metadata-eval16.8%
+-commutative16.8%
Simplified16.8%
+-commutative16.8%
metadata-eval16.8%
sub-neg16.8%
*-inverses16.8%
div-sub16.8%
clear-num16.7%
associate-/r/16.7%
flip--6.4%
associate-*r/6.3%
Applied egg-rr6.3%
Taylor expanded in y around inf 2.0%
neg-mul-12.0%
Simplified2.0%
expm1-log1p-u2.0%
expm1-udef1.8%
*-un-lft-identity1.8%
*-commutative1.8%
*-commutative1.8%
*-un-lft-identity1.8%
add-sqr-sqrt1.0%
sqrt-unprod18.2%
sqr-neg18.2%
sqrt-unprod33.0%
add-sqr-sqrt70.0%
Applied egg-rr70.0%
expm1-def70.2%
expm1-log1p70.2%
Simplified70.2%
if -9.79999999999999961e-132 < y < 5.1000000000000004e-252Initial 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-sqrt64.8%
fabs-sqr64.8%
rem-square-sqrt65.2%
div-sub65.2%
sub-neg65.2%
*-inverses65.2%
metadata-eval65.2%
+-commutative65.2%
Simplified65.2%
Taylor expanded in x around inf 65.4%
if 5.1000000000000004e-252 < y < 6.50000000000000005e-71Initial 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-sqrt31.2%
fabs-sqr31.2%
rem-square-sqrt31.9%
div-sub31.9%
sub-neg31.9%
*-inverses31.9%
metadata-eval31.9%
+-commutative31.9%
Simplified31.9%
+-commutative31.9%
metadata-eval31.9%
sub-neg31.9%
*-inverses31.9%
div-sub31.9%
clear-num31.9%
associate-/r/31.8%
flip--28.9%
associate-*r/23.2%
Applied egg-rr23.2%
Taylor expanded in y around 0 24.0%
unpow224.0%
associate-/l*27.5%
associate-/r/27.5%
Simplified27.5%
associate-*l/24.0%
*-un-lft-identity24.0%
associate-*l/24.0%
frac-2neg24.0%
div-inv24.0%
associate-*l/24.0%
*-un-lft-identity24.0%
distribute-neg-frac24.0%
add-sqr-sqrt24.0%
sqrt-unprod17.5%
sqr-neg17.5%
sqrt-unprod0.0%
add-sqr-sqrt38.8%
frac-2neg38.8%
associate-*r/38.7%
distribute-neg-in38.7%
neg-mul-138.7%
add-sqr-sqrt0.0%
sqrt-unprod39.5%
sqr-neg39.5%
sqrt-unprod39.4%
add-sqr-sqrt39.4%
fma-def39.4%
Applied egg-rr39.4%
associate-*l*45.3%
associate-*r/45.3%
*-rgt-identity45.3%
fma-udef45.3%
neg-mul-145.3%
+-commutative45.3%
sub-neg45.3%
Simplified45.3%
if 6.50000000000000005e-71 < y < 3.3999999999999999e-39Initial 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.2%
fabs-sqr63.2%
rem-square-sqrt64.0%
div-sub64.0%
sub-neg64.0%
*-inverses64.0%
metadata-eval64.0%
+-commutative64.0%
Simplified64.0%
Final simplification66.1%
(FPCore (x y)
:precision binary64
(if (<= y -1.45e-132)
1.0
(if (<= y 4.5e-255)
(/ x y)
(if (<= y 2.7e-73)
(* x (/ (/ x y) (- y x)))
(if (<= y 3.8e-39) (+ (/ x y) -1.0) (/ y (+ x y)))))))
double code(double x, double y) {
double tmp;
if (y <= -1.45e-132) {
tmp = 1.0;
} else if (y <= 4.5e-255) {
tmp = x / y;
} else if (y <= 2.7e-73) {
tmp = x * ((x / y) / (y - x));
} else if (y <= 3.8e-39) {
tmp = (x / y) + -1.0;
} else {
tmp = y / (x + y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.45d-132)) then
tmp = 1.0d0
else if (y <= 4.5d-255) then
tmp = x / y
else if (y <= 2.7d-73) then
tmp = x * ((x / y) / (y - x))
else if (y <= 3.8d-39) then
tmp = (x / y) + (-1.0d0)
else
tmp = y / (x + y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.45e-132) {
tmp = 1.0;
} else if (y <= 4.5e-255) {
tmp = x / y;
} else if (y <= 2.7e-73) {
tmp = x * ((x / y) / (y - x));
} else if (y <= 3.8e-39) {
tmp = (x / y) + -1.0;
} else {
tmp = y / (x + y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.45e-132: tmp = 1.0 elif y <= 4.5e-255: tmp = x / y elif y <= 2.7e-73: tmp = x * ((x / y) / (y - x)) elif y <= 3.8e-39: tmp = (x / y) + -1.0 else: tmp = y / (x + y) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.45e-132) tmp = 1.0; elseif (y <= 4.5e-255) tmp = Float64(x / y); elseif (y <= 2.7e-73) tmp = Float64(x * Float64(Float64(x / y) / Float64(y - x))); elseif (y <= 3.8e-39) tmp = Float64(Float64(x / y) + -1.0); else tmp = Float64(y / Float64(x + y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.45e-132) tmp = 1.0; elseif (y <= 4.5e-255) tmp = x / y; elseif (y <= 2.7e-73) tmp = x * ((x / y) / (y - x)); elseif (y <= 3.8e-39) tmp = (x / y) + -1.0; else tmp = y / (x + y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.45e-132], 1.0, If[LessEqual[y, 4.5e-255], N[(x / y), $MachinePrecision], If[LessEqual[y, 2.7e-73], N[(x * N[(N[(x / y), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e-39], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-132}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-255}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-73}:\\
\;\;\;\;x \cdot \frac{\frac{x}{y}}{y - x}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-39}:\\
\;\;\;\;\frac{x}{y} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x + y}\\
\end{array}
\end{array}
if y < -1.44999999999999992e-132Initial program 100.0%
Taylor expanded in x around -inf 100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-div100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
Taylor expanded in x around 0 64.8%
if -1.44999999999999992e-132 < y < 4.49999999999999979e-255Initial 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-sqrt64.8%
fabs-sqr64.8%
rem-square-sqrt65.2%
div-sub65.2%
sub-neg65.2%
*-inverses65.2%
metadata-eval65.2%
+-commutative65.2%
Simplified65.2%
Taylor expanded in x around inf 65.4%
if 4.49999999999999979e-255 < y < 2.69999999999999994e-73Initial 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-sqrt31.2%
fabs-sqr31.2%
rem-square-sqrt31.9%
div-sub31.9%
sub-neg31.9%
*-inverses31.9%
metadata-eval31.9%
+-commutative31.9%
Simplified31.9%
+-commutative31.9%
metadata-eval31.9%
sub-neg31.9%
*-inverses31.9%
div-sub31.9%
clear-num31.9%
associate-/r/31.8%
flip--28.9%
associate-*r/23.2%
Applied egg-rr23.2%
Taylor expanded in y around 0 24.0%
unpow224.0%
associate-/l*27.5%
associate-/r/27.5%
Simplified27.5%
associate-*l/24.0%
*-un-lft-identity24.0%
associate-*l/24.0%
frac-2neg24.0%
div-inv24.0%
associate-*l/24.0%
*-un-lft-identity24.0%
distribute-neg-frac24.0%
add-sqr-sqrt24.0%
sqrt-unprod17.5%
sqr-neg17.5%
sqrt-unprod0.0%
add-sqr-sqrt38.8%
frac-2neg38.8%
associate-*r/38.7%
distribute-neg-in38.7%
neg-mul-138.7%
add-sqr-sqrt0.0%
sqrt-unprod39.5%
sqr-neg39.5%
sqrt-unprod39.4%
add-sqr-sqrt39.4%
fma-def39.4%
Applied egg-rr39.4%
associate-*l*45.3%
associate-*r/45.3%
*-rgt-identity45.3%
fma-udef45.3%
neg-mul-145.3%
+-commutative45.3%
sub-neg45.3%
Simplified45.3%
if 2.69999999999999994e-73 < y < 3.8000000000000002e-39Initial 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.2%
fabs-sqr63.2%
rem-square-sqrt64.0%
div-sub64.0%
sub-neg64.0%
*-inverses64.0%
metadata-eval64.0%
+-commutative64.0%
Simplified64.0%
if 3.8000000000000002e-39 < y Initial 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-sqrt13.6%
fabs-sqr13.6%
rem-square-sqrt15.0%
div-sub15.0%
sub-neg15.0%
*-inverses15.0%
metadata-eval15.0%
+-commutative15.0%
Simplified15.0%
+-commutative15.0%
metadata-eval15.0%
sub-neg15.0%
*-inverses15.0%
div-sub15.0%
clear-num14.9%
associate-/r/14.9%
flip--6.7%
associate-*r/6.6%
Applied egg-rr6.6%
Taylor expanded in y around inf 1.8%
neg-mul-11.8%
Simplified1.8%
expm1-log1p-u1.8%
expm1-udef1.7%
*-un-lft-identity1.7%
*-commutative1.7%
*-commutative1.7%
*-un-lft-identity1.7%
add-sqr-sqrt0.0%
sqrt-unprod41.3%
sqr-neg41.3%
sqrt-unprod78.3%
add-sqr-sqrt78.4%
Applied egg-rr78.4%
expm1-def78.6%
expm1-log1p78.6%
Simplified78.6%
Final simplification66.3%
(FPCore (x y) :precision binary64 (if (or (<= y -1.08e-131) (not (<= y 3.4e-39))) (/ y (+ x y)) (+ (/ x y) -1.0)))
double code(double x, double y) {
double tmp;
if ((y <= -1.08e-131) || !(y <= 3.4e-39)) {
tmp = y / (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 <= (-1.08d-131)) .or. (.not. (y <= 3.4d-39))) then
tmp = y / (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 <= -1.08e-131) || !(y <= 3.4e-39)) {
tmp = y / (x + y);
} else {
tmp = (x / y) + -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.08e-131) or not (y <= 3.4e-39): tmp = y / (x + y) else: tmp = (x / y) + -1.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.08e-131) || !(y <= 3.4e-39)) tmp = Float64(y / 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 <= -1.08e-131) || ~((y <= 3.4e-39))) tmp = y / (x + y); else tmp = (x / y) + -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.08e-131], N[Not[LessEqual[y, 3.4e-39]], $MachinePrecision]], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.08 \cdot 10^{-131} \lor \neg \left(y \leq 3.4 \cdot 10^{-39}\right):\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -1\\
\end{array}
\end{array}
if y < -1.07999999999999996e-131 or 3.3999999999999999e-39 < y Initial 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-sqrt15.5%
fabs-sqr15.5%
rem-square-sqrt16.8%
div-sub16.8%
sub-neg16.8%
*-inverses16.8%
metadata-eval16.8%
+-commutative16.8%
Simplified16.8%
+-commutative16.8%
metadata-eval16.8%
sub-neg16.8%
*-inverses16.8%
div-sub16.8%
clear-num16.7%
associate-/r/16.7%
flip--6.4%
associate-*r/6.3%
Applied egg-rr6.3%
Taylor expanded in y around inf 2.0%
neg-mul-12.0%
Simplified2.0%
expm1-log1p-u2.0%
expm1-udef1.8%
*-un-lft-identity1.8%
*-commutative1.8%
*-commutative1.8%
*-un-lft-identity1.8%
add-sqr-sqrt1.0%
sqrt-unprod18.2%
sqr-neg18.2%
sqrt-unprod33.0%
add-sqr-sqrt70.0%
Applied egg-rr70.0%
expm1-def70.2%
expm1-log1p70.2%
Simplified70.2%
if -1.07999999999999996e-131 < y < 3.3999999999999999e-39Initial 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-sqrt51.6%
fabs-sqr51.6%
rem-square-sqrt52.2%
div-sub52.2%
sub-neg52.2%
*-inverses52.2%
metadata-eval52.2%
+-commutative52.2%
Simplified52.2%
Final simplification64.3%
(FPCore (x y) :precision binary64 (/ x y))
double code(double x, double y) {
return x / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
public static double code(double x, double y) {
return x / y;
}
def code(x, y): return x / y
function code(x, y) return Float64(x / y) end
function tmp = code(x, y) tmp = x / y; end
code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial 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-sqrt27.2%
fabs-sqr27.2%
rem-square-sqrt28.3%
div-sub28.3%
sub-neg28.3%
*-inverses28.3%
metadata-eval28.3%
+-commutative28.3%
Simplified28.3%
Taylor expanded in x around inf 29.0%
Final simplification29.0%
(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%
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-sqrt27.2%
fabs-sqr27.2%
rem-square-sqrt28.3%
div-sub28.3%
sub-neg28.3%
*-inverses28.3%
metadata-eval28.3%
+-commutative28.3%
Simplified28.3%
Taylor expanded in x around 0 1.3%
Final simplification1.3%
herbie shell --seed 2023293
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))