
(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 (<= x -6.1e+88)
(/ x y)
(if (<= x 4e+23)
(/ y (+ x y))
(if (<= x 6.8e+100)
(/ x y)
(if (<= x 1.72e+168)
(* y (/ 1.0 (- y x)))
(if (<= x 3.4e+257) (* x (/ (/ (- x) y) (+ x y))) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -6.1e+88) {
tmp = x / y;
} else if (x <= 4e+23) {
tmp = y / (x + y);
} else if (x <= 6.8e+100) {
tmp = x / y;
} else if (x <= 1.72e+168) {
tmp = y * (1.0 / (y - x));
} else if (x <= 3.4e+257) {
tmp = x * ((-x / y) / (x + y));
} else {
tmp = 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 <= (-6.1d+88)) then
tmp = x / y
else if (x <= 4d+23) then
tmp = y / (x + y)
else if (x <= 6.8d+100) then
tmp = x / y
else if (x <= 1.72d+168) then
tmp = y * (1.0d0 / (y - x))
else if (x <= 3.4d+257) then
tmp = x * ((-x / y) / (x + y))
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -6.1e+88) {
tmp = x / y;
} else if (x <= 4e+23) {
tmp = y / (x + y);
} else if (x <= 6.8e+100) {
tmp = x / y;
} else if (x <= 1.72e+168) {
tmp = y * (1.0 / (y - x));
} else if (x <= 3.4e+257) {
tmp = x * ((-x / y) / (x + y));
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.1e+88: tmp = x / y elif x <= 4e+23: tmp = y / (x + y) elif x <= 6.8e+100: tmp = x / y elif x <= 1.72e+168: tmp = y * (1.0 / (y - x)) elif x <= 3.4e+257: tmp = x * ((-x / y) / (x + y)) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -6.1e+88) tmp = Float64(x / y); elseif (x <= 4e+23) tmp = Float64(y / Float64(x + y)); elseif (x <= 6.8e+100) tmp = Float64(x / y); elseif (x <= 1.72e+168) tmp = Float64(y * Float64(1.0 / Float64(y - x))); elseif (x <= 3.4e+257) tmp = Float64(x * Float64(Float64(Float64(-x) / y) / Float64(x + y))); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -6.1e+88) tmp = x / y; elseif (x <= 4e+23) tmp = y / (x + y); elseif (x <= 6.8e+100) tmp = x / y; elseif (x <= 1.72e+168) tmp = y * (1.0 / (y - x)); elseif (x <= 3.4e+257) tmp = x * ((-x / y) / (x + y)); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -6.1e+88], N[(x / y), $MachinePrecision], If[LessEqual[x, 4e+23], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.8e+100], N[(x / y), $MachinePrecision], If[LessEqual[x, 1.72e+168], N[(y * N[(1.0 / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.4e+257], N[(x * N[(N[((-x) / y), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.1 \cdot 10^{+88}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+23}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{+100}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 1.72 \cdot 10^{+168}:\\
\;\;\;\;y \cdot \frac{1}{y - x}\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+257}:\\
\;\;\;\;x \cdot \frac{\frac{-x}{y}}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -6.0999999999999998e88 or 3.9999999999999997e23 < x < 6.79999999999999988e100 or 3.4000000000000002e257 < x Initial program 100.0%
div-inv99.8%
add-sqr-sqrt30.5%
fabs-sqr30.5%
add-sqr-sqrt31.0%
*-commutative31.0%
add-sqr-sqrt21.5%
fabs-sqr21.5%
add-sqr-sqrt60.2%
Applied egg-rr60.2%
Taylor expanded in y around 0 60.8%
if -6.0999999999999998e88 < x < 3.9999999999999997e23Initial program 100.0%
div-inv99.7%
add-sqr-sqrt48.5%
fabs-sqr48.5%
add-sqr-sqrt49.4%
*-commutative49.4%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt13.8%
Applied egg-rr13.8%
flip--12.3%
associate-*r/12.3%
+-commutative12.3%
Applied egg-rr12.3%
Taylor expanded in y around inf 1.9%
neg-mul-11.9%
Simplified1.9%
*-un-lft-identity1.9%
add-sqr-sqrt0.9%
sqrt-unprod20.5%
sqr-neg20.5%
sqrt-unprod37.6%
times-frac37.6%
Applied egg-rr37.6%
/-rgt-identity37.6%
associate-*r/37.6%
rem-square-sqrt73.9%
Simplified73.9%
if 6.79999999999999988e100 < x < 1.7200000000000001e168Initial program 100.0%
div-inv99.6%
add-sqr-sqrt99.4%
fabs-sqr99.4%
add-sqr-sqrt99.6%
*-commutative99.6%
add-sqr-sqrt33.2%
fabs-sqr33.2%
add-sqr-sqrt34.3%
Applied egg-rr34.3%
flip--33.8%
associate-*r/26.2%
+-commutative26.2%
Applied egg-rr26.2%
Taylor expanded in y around inf 2.4%
neg-mul-12.4%
Simplified2.4%
frac-2neg2.4%
div-inv2.4%
remove-double-neg2.4%
distribute-neg-in2.4%
add-sqr-sqrt1.9%
sqrt-unprod3.2%
sqr-neg3.2%
sqrt-unprod0.5%
add-sqr-sqrt51.2%
sub-neg51.2%
Applied egg-rr51.2%
if 1.7200000000000001e168 < x < 3.4000000000000002e257Initial program 99.9%
div-inv99.8%
add-sqr-sqrt95.7%
fabs-sqr95.7%
add-sqr-sqrt96.0%
*-commutative96.0%
add-sqr-sqrt27.0%
fabs-sqr27.0%
add-sqr-sqrt27.5%
Applied egg-rr27.5%
flip--15.8%
associate-*r/15.8%
+-commutative15.8%
Applied egg-rr15.8%
Taylor expanded in x around inf 16.2%
unpow216.2%
Simplified16.2%
frac-2neg16.2%
distribute-frac-neg16.2%
*-commutative16.2%
div-inv16.2%
frac-2neg16.2%
add-sqr-sqrt0.2%
sqrt-unprod0.1%
sqr-neg0.1%
sqrt-unprod0.1%
add-sqr-sqrt25.1%
distribute-neg-frac25.1%
associate-*l/53.8%
frac-2neg53.8%
associate-/l*64.8%
associate-/r/64.7%
Applied egg-rr64.7%
Final simplification68.1%
(FPCore (x y)
:precision binary64
(if (<= x -3e+91)
(/ x y)
(if (<= x 4e+23)
(/ y (+ x y))
(if (<= x 1.6e+103)
(/ x y)
(if (<= x 3.5e+169)
(* y (/ 1.0 (- y x)))
(if (<= x 7.8e+251) (/ (/ x (/ y x)) (- y x)) (/ x y)))))))
double code(double x, double y) {
double tmp;
if (x <= -3e+91) {
tmp = x / y;
} else if (x <= 4e+23) {
tmp = y / (x + y);
} else if (x <= 1.6e+103) {
tmp = x / y;
} else if (x <= 3.5e+169) {
tmp = y * (1.0 / (y - x));
} else if (x <= 7.8e+251) {
tmp = (x / (y / x)) / (y - x);
} else {
tmp = 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 <= (-3d+91)) then
tmp = x / y
else if (x <= 4d+23) then
tmp = y / (x + y)
else if (x <= 1.6d+103) then
tmp = x / y
else if (x <= 3.5d+169) then
tmp = y * (1.0d0 / (y - x))
else if (x <= 7.8d+251) then
tmp = (x / (y / x)) / (y - x)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -3e+91) {
tmp = x / y;
} else if (x <= 4e+23) {
tmp = y / (x + y);
} else if (x <= 1.6e+103) {
tmp = x / y;
} else if (x <= 3.5e+169) {
tmp = y * (1.0 / (y - x));
} else if (x <= 7.8e+251) {
tmp = (x / (y / x)) / (y - x);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -3e+91: tmp = x / y elif x <= 4e+23: tmp = y / (x + y) elif x <= 1.6e+103: tmp = x / y elif x <= 3.5e+169: tmp = y * (1.0 / (y - x)) elif x <= 7.8e+251: tmp = (x / (y / x)) / (y - x) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -3e+91) tmp = Float64(x / y); elseif (x <= 4e+23) tmp = Float64(y / Float64(x + y)); elseif (x <= 1.6e+103) tmp = Float64(x / y); elseif (x <= 3.5e+169) tmp = Float64(y * Float64(1.0 / Float64(y - x))); elseif (x <= 7.8e+251) tmp = Float64(Float64(x / Float64(y / x)) / Float64(y - x)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -3e+91) tmp = x / y; elseif (x <= 4e+23) tmp = y / (x + y); elseif (x <= 1.6e+103) tmp = x / y; elseif (x <= 3.5e+169) tmp = y * (1.0 / (y - x)); elseif (x <= 7.8e+251) tmp = (x / (y / x)) / (y - x); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -3e+91], N[(x / y), $MachinePrecision], If[LessEqual[x, 4e+23], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+103], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.5e+169], N[(y * N[(1.0 / N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.8e+251], N[(N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision] / N[(y - x), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+91}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+23}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{elif}\;x \leq 1.6 \cdot 10^{+103}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+169}:\\
\;\;\;\;y \cdot \frac{1}{y - x}\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{+251}:\\
\;\;\;\;\frac{\frac{x}{\frac{y}{x}}}{y - x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -3.00000000000000006e91 or 3.9999999999999997e23 < x < 1.59999999999999996e103 or 7.79999999999999951e251 < x Initial program 100.0%
div-inv99.8%
add-sqr-sqrt30.5%
fabs-sqr30.5%
add-sqr-sqrt31.0%
*-commutative31.0%
add-sqr-sqrt21.5%
fabs-sqr21.5%
add-sqr-sqrt60.2%
Applied egg-rr60.2%
Taylor expanded in y around 0 60.8%
if -3.00000000000000006e91 < x < 3.9999999999999997e23Initial program 100.0%
div-inv99.7%
add-sqr-sqrt48.5%
fabs-sqr48.5%
add-sqr-sqrt49.4%
*-commutative49.4%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt13.8%
Applied egg-rr13.8%
flip--12.3%
associate-*r/12.3%
+-commutative12.3%
Applied egg-rr12.3%
Taylor expanded in y around inf 1.9%
neg-mul-11.9%
Simplified1.9%
*-un-lft-identity1.9%
add-sqr-sqrt0.9%
sqrt-unprod20.5%
sqr-neg20.5%
sqrt-unprod37.6%
times-frac37.6%
Applied egg-rr37.6%
/-rgt-identity37.6%
associate-*r/37.6%
rem-square-sqrt73.9%
Simplified73.9%
if 1.59999999999999996e103 < x < 3.50000000000000019e169Initial program 100.0%
div-inv99.6%
add-sqr-sqrt99.4%
fabs-sqr99.4%
add-sqr-sqrt99.6%
*-commutative99.6%
add-sqr-sqrt33.2%
fabs-sqr33.2%
add-sqr-sqrt34.3%
Applied egg-rr34.3%
flip--33.8%
associate-*r/26.2%
+-commutative26.2%
Applied egg-rr26.2%
Taylor expanded in y around inf 2.4%
neg-mul-12.4%
Simplified2.4%
frac-2neg2.4%
div-inv2.4%
remove-double-neg2.4%
distribute-neg-in2.4%
add-sqr-sqrt1.9%
sqrt-unprod3.2%
sqr-neg3.2%
sqrt-unprod0.5%
add-sqr-sqrt51.2%
sub-neg51.2%
Applied egg-rr51.2%
if 3.50000000000000019e169 < x < 7.79999999999999951e251Initial program 99.9%
div-inv99.8%
add-sqr-sqrt95.7%
fabs-sqr95.7%
add-sqr-sqrt96.0%
*-commutative96.0%
add-sqr-sqrt27.0%
fabs-sqr27.0%
add-sqr-sqrt27.5%
Applied egg-rr27.5%
flip--15.8%
associate-*r/15.8%
+-commutative15.8%
Applied egg-rr15.8%
Taylor expanded in x around inf 16.2%
unpow216.2%
Simplified16.2%
frac-2neg16.2%
div-inv16.2%
associate-*l/16.2%
*-un-lft-identity16.2%
distribute-neg-frac16.2%
add-sqr-sqrt15.9%
sqrt-unprod39.9%
sqr-neg39.9%
sqrt-unprod25.0%
add-sqr-sqrt25.1%
frac-2neg25.1%
associate-*r/53.7%
distribute-neg-in53.7%
add-sqr-sqrt53.6%
sqrt-unprod36.2%
sqr-neg36.2%
sqrt-unprod0.3%
add-sqr-sqrt51.7%
sub-neg51.7%
Applied egg-rr51.7%
associate-*r/51.8%
*-rgt-identity51.8%
associate-*r/25.2%
associate-/l*51.7%
Simplified51.7%
Final simplification66.8%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ x y))))
(if (<= x -9.8e+91)
(/ x y)
(if (<= x 3e+22)
t_0
(if (<= x 3e+99)
(/ x y)
(if (<= x 7.5e+115)
t_0
(if (<= x 3.4e+236) (/ (* x x) (* y y)) (/ x y))))))))
double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (x <= -9.8e+91) {
tmp = x / y;
} else if (x <= 3e+22) {
tmp = t_0;
} else if (x <= 3e+99) {
tmp = x / y;
} else if (x <= 7.5e+115) {
tmp = t_0;
} else if (x <= 3.4e+236) {
tmp = (x * x) / (y * y);
} else {
tmp = x / y;
}
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 (x <= (-9.8d+91)) then
tmp = x / y
else if (x <= 3d+22) then
tmp = t_0
else if (x <= 3d+99) then
tmp = x / y
else if (x <= 7.5d+115) then
tmp = t_0
else if (x <= 3.4d+236) then
tmp = (x * x) / (y * y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y / (x + y);
double tmp;
if (x <= -9.8e+91) {
tmp = x / y;
} else if (x <= 3e+22) {
tmp = t_0;
} else if (x <= 3e+99) {
tmp = x / y;
} else if (x <= 7.5e+115) {
tmp = t_0;
} else if (x <= 3.4e+236) {
tmp = (x * x) / (y * y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): t_0 = y / (x + y) tmp = 0 if x <= -9.8e+91: tmp = x / y elif x <= 3e+22: tmp = t_0 elif x <= 3e+99: tmp = x / y elif x <= 7.5e+115: tmp = t_0 elif x <= 3.4e+236: tmp = (x * x) / (y * y) else: tmp = x / y return tmp
function code(x, y) t_0 = Float64(y / Float64(x + y)) tmp = 0.0 if (x <= -9.8e+91) tmp = Float64(x / y); elseif (x <= 3e+22) tmp = t_0; elseif (x <= 3e+99) tmp = Float64(x / y); elseif (x <= 7.5e+115) tmp = t_0; elseif (x <= 3.4e+236) tmp = Float64(Float64(x * x) / Float64(y * y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) t_0 = y / (x + y); tmp = 0.0; if (x <= -9.8e+91) tmp = x / y; elseif (x <= 3e+22) tmp = t_0; elseif (x <= 3e+99) tmp = x / y; elseif (x <= 7.5e+115) tmp = t_0; elseif (x <= 3.4e+236) tmp = (x * x) / (y * y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.8e+91], N[(x / y), $MachinePrecision], If[LessEqual[x, 3e+22], t$95$0, If[LessEqual[x, 3e+99], N[(x / y), $MachinePrecision], If[LessEqual[x, 7.5e+115], t$95$0, If[LessEqual[x, 3.4e+236], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{x + y}\\
\mathbf{if}\;x \leq -9.8 \cdot 10^{+91}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+22}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+99}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+115}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+236}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -9.8000000000000006e91 or 3e22 < x < 3.00000000000000014e99 or 3.40000000000000007e236 < x Initial program 99.9%
div-inv99.8%
add-sqr-sqrt35.6%
fabs-sqr35.6%
add-sqr-sqrt36.1%
*-commutative36.1%
add-sqr-sqrt21.1%
fabs-sqr21.1%
add-sqr-sqrt57.1%
Applied egg-rr57.1%
Taylor expanded in y around 0 57.6%
if -9.8000000000000006e91 < x < 3e22 or 3.00000000000000014e99 < x < 7.4999999999999997e115Initial program 100.0%
div-inv99.7%
add-sqr-sqrt50.2%
fabs-sqr50.2%
add-sqr-sqrt51.1%
*-commutative51.1%
add-sqr-sqrt8.7%
fabs-sqr8.7%
add-sqr-sqrt14.0%
Applied egg-rr14.0%
flip--12.5%
associate-*r/11.9%
+-commutative11.9%
Applied egg-rr11.9%
Taylor expanded in y around inf 1.9%
neg-mul-11.9%
Simplified1.9%
*-un-lft-identity1.9%
add-sqr-sqrt0.9%
sqrt-unprod19.8%
sqr-neg19.8%
sqrt-unprod36.3%
times-frac36.4%
Applied egg-rr36.4%
/-rgt-identity36.4%
associate-*r/36.3%
rem-square-sqrt74.1%
Simplified74.1%
if 7.4999999999999997e115 < x < 3.40000000000000007e236Initial program 100.0%
div-inv99.8%
add-sqr-sqrt95.8%
fabs-sqr95.8%
add-sqr-sqrt96.1%
*-commutative96.1%
add-sqr-sqrt33.3%
fabs-sqr33.3%
add-sqr-sqrt33.9%
Applied egg-rr33.9%
flip--26.2%
associate-*r/26.2%
+-commutative26.2%
Applied egg-rr26.2%
Taylor expanded in x around inf 26.8%
unpow226.8%
Simplified26.8%
Taylor expanded in y around inf 42.9%
unpow242.9%
unpow242.9%
Simplified42.9%
Final simplification65.6%
(FPCore (x y) :precision binary64 (if (<= x -2.2e+90) (/ x y) (if (<= x 3.8e+23) (/ y (+ x y)) (/ x y))))
double code(double x, double y) {
double tmp;
if (x <= -2.2e+90) {
tmp = x / y;
} else if (x <= 3.8e+23) {
tmp = y / (x + y);
} else {
tmp = 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 <= (-2.2d+90)) then
tmp = x / y
else if (x <= 3.8d+23) then
tmp = y / (x + y)
else
tmp = x / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -2.2e+90) {
tmp = x / y;
} else if (x <= 3.8e+23) {
tmp = y / (x + y);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.2e+90: tmp = x / y elif x <= 3.8e+23: tmp = y / (x + y) else: tmp = x / y return tmp
function code(x, y) tmp = 0.0 if (x <= -2.2e+90) tmp = Float64(x / y); elseif (x <= 3.8e+23) tmp = Float64(y / Float64(x + y)); else tmp = Float64(x / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -2.2e+90) tmp = x / y; elseif (x <= 3.8e+23) tmp = y / (x + y); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -2.2e+90], N[(x / y), $MachinePrecision], If[LessEqual[x, 3.8e+23], N[(y / N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+90}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+23}:\\
\;\;\;\;\frac{y}{x + y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -2.1999999999999999e90 or 3.79999999999999975e23 < x Initial program 100.0%
div-inv99.8%
add-sqr-sqrt52.8%
fabs-sqr52.8%
add-sqr-sqrt53.3%
*-commutative53.3%
add-sqr-sqrt24.0%
fabs-sqr24.0%
add-sqr-sqrt50.0%
Applied egg-rr50.0%
Taylor expanded in y around 0 50.4%
if -2.1999999999999999e90 < x < 3.79999999999999975e23Initial program 100.0%
div-inv99.7%
add-sqr-sqrt48.5%
fabs-sqr48.5%
add-sqr-sqrt49.4%
*-commutative49.4%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt13.8%
Applied egg-rr13.8%
flip--12.3%
associate-*r/12.3%
+-commutative12.3%
Applied egg-rr12.3%
Taylor expanded in y around inf 1.9%
neg-mul-11.9%
Simplified1.9%
*-un-lft-identity1.9%
add-sqr-sqrt0.9%
sqrt-unprod20.5%
sqr-neg20.5%
sqrt-unprod37.6%
times-frac37.6%
Applied egg-rr37.6%
/-rgt-identity37.6%
associate-*r/37.6%
rem-square-sqrt73.9%
Simplified73.9%
Final simplification63.5%
(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%
div-inv99.7%
add-sqr-sqrt50.4%
fabs-sqr50.4%
add-sqr-sqrt51.1%
*-commutative51.1%
add-sqr-sqrt15.2%
fabs-sqr15.2%
add-sqr-sqrt29.7%
Applied egg-rr29.7%
Taylor expanded in y around 0 30.9%
Final simplification30.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%
div-inv99.7%
add-sqr-sqrt50.4%
fabs-sqr50.4%
add-sqr-sqrt51.1%
*-commutative51.1%
add-sqr-sqrt15.2%
fabs-sqr15.2%
add-sqr-sqrt29.7%
Applied egg-rr29.7%
Taylor expanded in y around inf 1.3%
Final simplification1.3%
herbie shell --seed 2023257
(FPCore (x y)
:name "Numeric.LinearAlgebra.Util:formatSparse from hmatrix-0.16.1.5"
:precision binary64
(/ (fabs (- x y)) (fabs y)))