
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((a * c) + (b * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((a * c) + (b * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((a * c) + (b * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (sqrt (hypot c d)))
(t_1 (/ (/ (/ c (/ (hypot c d) a)) t_0) t_0))
(t_2 (fma b (/ d (pow (hypot c d) 2.0)) t_1)))
(if (<= d -1.05e+124)
(fma b (/ 1.0 d) (* c (/ (/ a (hypot c d)) (hypot c d))))
(if (<= d -5.05e-144)
t_2
(if (<= d 9.2e-205)
(/ (+ a (/ (* d b) c)) c)
(if (<= d 7.2e+106) t_2 (fma b (/ 1.0 d) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = sqrt(hypot(c, d));
double t_1 = ((c / (hypot(c, d) / a)) / t_0) / t_0;
double t_2 = fma(b, (d / pow(hypot(c, d), 2.0)), t_1);
double tmp;
if (d <= -1.05e+124) {
tmp = fma(b, (1.0 / d), (c * ((a / hypot(c, d)) / hypot(c, d))));
} else if (d <= -5.05e-144) {
tmp = t_2;
} else if (d <= 9.2e-205) {
tmp = (a + ((d * b) / c)) / c;
} else if (d <= 7.2e+106) {
tmp = t_2;
} else {
tmp = fma(b, (1.0 / d), t_1);
}
return tmp;
}
function code(a, b, c, d) t_0 = sqrt(hypot(c, d)) t_1 = Float64(Float64(Float64(c / Float64(hypot(c, d) / a)) / t_0) / t_0) t_2 = fma(b, Float64(d / (hypot(c, d) ^ 2.0)), t_1) tmp = 0.0 if (d <= -1.05e+124) tmp = fma(b, Float64(1.0 / d), Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))); elseif (d <= -5.05e-144) tmp = t_2; elseif (d <= 9.2e-205) tmp = Float64(Float64(a + Float64(Float64(d * b) / c)) / c); elseif (d <= 7.2e+106) tmp = t_2; else tmp = fma(b, Float64(1.0 / d), t_1); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[d, -1.05e+124], N[(b * N[(1.0 / d), $MachinePrecision] + N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.05e-144], t$95$2, If[LessEqual[d, 9.2e-205], N[(N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.2e+106], t$95$2, N[(b * N[(1.0 / d), $MachinePrecision] + t$95$1), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{t\_0}}{t\_0}\\
t_2 := \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, t\_1\right)\\
\mathbf{if}\;d \leq -1.05 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{elif}\;d \leq -5.05 \cdot 10^{-144}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{-205}:\\
\;\;\;\;\frac{a + \frac{d \cdot b}{c}}{c}\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+106}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, t\_1\right)\\
\end{array}
\end{array}
if d < -1.05000000000000006e124Initial program 41.9%
Taylor expanded in a around 0 41.9%
+-commutative41.9%
associate-/l*42.7%
fma-define42.7%
rem-square-sqrt42.7%
unpow242.7%
unpow242.7%
hypot-undefine42.7%
unpow242.7%
unpow242.7%
hypot-undefine42.7%
unpow242.7%
rem-square-sqrt42.7%
Simplified43.3%
*-un-lft-identity43.3%
unpow243.3%
times-frac50.1%
hypot-undefine43.3%
+-commutative43.3%
hypot-define50.1%
hypot-undefine43.3%
+-commutative43.3%
hypot-define50.1%
Applied egg-rr50.1%
associate-*l/50.1%
*-lft-identity50.1%
hypot-undefine43.3%
unpow243.3%
unpow243.3%
+-commutative43.3%
unpow243.3%
unpow243.3%
hypot-define50.1%
hypot-undefine43.3%
unpow243.3%
unpow243.3%
+-commutative43.3%
unpow243.3%
unpow243.3%
hypot-define50.1%
Simplified50.1%
Taylor expanded in d around inf 96.8%
if -1.05000000000000006e124 < d < -5.0499999999999999e-144 or 9.1999999999999997e-205 < d < 7.2000000000000002e106Initial program 72.9%
Taylor expanded in a around 0 72.0%
+-commutative72.0%
associate-/l*75.6%
fma-define75.6%
rem-square-sqrt75.6%
unpow275.6%
unpow275.6%
hypot-undefine75.6%
unpow275.6%
unpow275.6%
hypot-undefine75.6%
unpow275.6%
rem-square-sqrt75.6%
Simplified79.6%
*-un-lft-identity79.6%
unpow279.6%
times-frac85.0%
hypot-undefine79.7%
+-commutative79.7%
hypot-define85.0%
hypot-undefine79.7%
+-commutative79.7%
hypot-define85.0%
Applied egg-rr85.0%
associate-*l/85.1%
*-lft-identity85.1%
hypot-undefine79.7%
unpow279.7%
unpow279.7%
+-commutative79.7%
unpow279.7%
unpow279.7%
hypot-define85.1%
hypot-undefine79.7%
unpow279.7%
unpow279.7%
+-commutative79.7%
unpow279.7%
unpow279.7%
hypot-define85.1%
Simplified85.1%
associate-*r/95.3%
add-sqr-sqrt95.0%
associate-/r*95.1%
clear-num95.0%
un-div-inv95.1%
Applied egg-rr95.1%
if -5.0499999999999999e-144 < d < 9.1999999999999997e-205Initial program 66.3%
Taylor expanded in c around inf 95.5%
if 7.2000000000000002e106 < d Initial program 29.9%
Taylor expanded in a around 0 29.9%
+-commutative29.9%
associate-/l*31.2%
fma-define31.2%
rem-square-sqrt31.2%
unpow231.2%
unpow231.2%
hypot-undefine31.2%
unpow231.2%
unpow231.2%
hypot-undefine31.2%
unpow231.2%
rem-square-sqrt31.2%
Simplified31.7%
*-un-lft-identity31.7%
unpow231.7%
times-frac36.4%
hypot-undefine31.7%
+-commutative31.7%
hypot-define36.4%
hypot-undefine31.7%
+-commutative31.7%
hypot-define36.4%
Applied egg-rr36.4%
associate-*l/36.5%
*-lft-identity36.5%
hypot-undefine31.7%
unpow231.7%
unpow231.7%
+-commutative31.7%
unpow231.7%
unpow231.7%
hypot-define36.5%
hypot-undefine31.7%
unpow231.7%
unpow231.7%
+-commutative31.7%
unpow231.7%
unpow231.7%
hypot-define36.5%
Simplified36.5%
associate-*r/41.9%
add-sqr-sqrt41.7%
associate-/r*41.7%
clear-num41.7%
un-div-inv41.7%
Applied egg-rr41.7%
Taylor expanded in d around inf 95.1%
Final simplification95.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (sqrt (hypot c d)))
(t_1
(fma
b
(/ d (pow (hypot c d) 2.0))
(* c (/ (/ a (hypot c d)) (hypot c d)))))
(t_2 (fma b (/ 1.0 d) (/ (/ (/ c (/ (hypot c d) a)) t_0) t_0))))
(if (<= d -2e+150)
t_2
(if (<= d -3.2e-83)
t_1
(if (<= d 1.45e-88)
(/ (+ a (* b (/ d c))) c)
(if (<= d 1.9e+106) t_1 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = sqrt(hypot(c, d));
double t_1 = fma(b, (d / pow(hypot(c, d), 2.0)), (c * ((a / hypot(c, d)) / hypot(c, d))));
double t_2 = fma(b, (1.0 / d), (((c / (hypot(c, d) / a)) / t_0) / t_0));
double tmp;
if (d <= -2e+150) {
tmp = t_2;
} else if (d <= -3.2e-83) {
tmp = t_1;
} else if (d <= 1.45e-88) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 1.9e+106) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(a, b, c, d) t_0 = sqrt(hypot(c, d)) t_1 = fma(b, Float64(d / (hypot(c, d) ^ 2.0)), Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))) t_2 = fma(b, Float64(1.0 / d), Float64(Float64(Float64(c / Float64(hypot(c, d) / a)) / t_0) / t_0)) tmp = 0.0 if (d <= -2e+150) tmp = t_2; elseif (d <= -3.2e-83) tmp = t_1; elseif (d <= 1.45e-88) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 1.9e+106) tmp = t_1; else tmp = t_2; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[Sqrt[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b * N[(1.0 / d), $MachinePrecision] + N[(N[(N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2e+150], t$95$2, If[LessEqual[d, -3.2e-83], t$95$1, If[LessEqual[d, 1.45e-88], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.9e+106], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\
t_2 := \mathsf{fma}\left(b, \frac{1}{d}, \frac{\frac{\frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{a}}}{t\_0}}{t\_0}\right)\\
\mathbf{if}\;d \leq -2 \cdot 10^{+150}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;d \leq -3.2 \cdot 10^{-83}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{-88}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{+106}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if d < -1.99999999999999996e150 or 1.8999999999999999e106 < d Initial program 32.7%
Taylor expanded in a around 0 32.7%
+-commutative32.7%
associate-/l*33.8%
fma-define33.8%
rem-square-sqrt33.8%
unpow233.8%
unpow233.8%
hypot-undefine33.8%
unpow233.8%
unpow233.8%
hypot-undefine33.8%
unpow233.8%
rem-square-sqrt33.8%
Simplified34.4%
*-un-lft-identity34.4%
unpow234.4%
times-frac40.5%
hypot-undefine34.4%
+-commutative34.4%
hypot-define40.5%
hypot-undefine34.4%
+-commutative34.4%
hypot-define40.5%
Applied egg-rr40.5%
associate-*l/40.5%
*-lft-identity40.5%
hypot-undefine34.4%
unpow234.4%
unpow234.4%
+-commutative34.4%
unpow234.4%
unpow234.4%
hypot-define40.5%
hypot-undefine34.4%
unpow234.4%
unpow234.4%
+-commutative34.4%
unpow234.4%
unpow234.4%
hypot-define40.5%
Simplified40.5%
associate-*r/43.7%
add-sqr-sqrt43.6%
associate-/r*43.6%
clear-num43.2%
un-div-inv43.3%
Applied egg-rr43.3%
Taylor expanded in d around inf 95.8%
if -1.99999999999999996e150 < d < -3.2000000000000001e-83 or 1.4500000000000001e-88 < d < 1.8999999999999999e106Initial program 76.9%
Taylor expanded in a around 0 76.9%
+-commutative76.9%
associate-/l*81.8%
fma-define81.8%
rem-square-sqrt81.8%
unpow281.8%
unpow281.8%
hypot-undefine81.8%
unpow281.8%
unpow281.8%
hypot-undefine81.8%
unpow281.8%
rem-square-sqrt81.8%
Simplified85.9%
*-un-lft-identity85.9%
unpow285.9%
times-frac90.9%
hypot-undefine85.9%
+-commutative85.9%
hypot-define90.9%
hypot-undefine85.9%
+-commutative85.9%
hypot-define90.9%
Applied egg-rr90.9%
associate-*l/91.0%
*-lft-identity91.0%
hypot-undefine85.9%
unpow285.9%
unpow285.9%
+-commutative85.9%
unpow285.9%
unpow285.9%
hypot-define91.0%
hypot-undefine85.9%
unpow285.9%
unpow285.9%
+-commutative85.9%
unpow285.9%
unpow285.9%
hypot-define91.0%
Simplified91.0%
if -3.2000000000000001e-83 < d < 1.4500000000000001e-88Initial program 66.8%
Taylor expanded in c around inf 94.3%
associate-/l*94.6%
Simplified94.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* c (/ (/ a (hypot c d)) (hypot c d))))
(t_1 (fma b (/ d (pow (hypot c d) 2.0)) t_0)))
(if (<= d -6.9e+149)
(fma b (/ 1.0 d) t_0)
(if (<= d -3e-85)
t_1
(if (<= d 6.6e-88)
(/ (+ a (* b (/ d c))) c)
(if (<= d 2.9e+155) t_1 (/ (+ b (* c (/ a d))) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = c * ((a / hypot(c, d)) / hypot(c, d));
double t_1 = fma(b, (d / pow(hypot(c, d), 2.0)), t_0);
double tmp;
if (d <= -6.9e+149) {
tmp = fma(b, (1.0 / d), t_0);
} else if (d <= -3e-85) {
tmp = t_1;
} else if (d <= 6.6e-88) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 2.9e+155) {
tmp = t_1;
} else {
tmp = (b + (c * (a / d))) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d))) t_1 = fma(b, Float64(d / (hypot(c, d) ^ 2.0)), t_0) tmp = 0.0 if (d <= -6.9e+149) tmp = fma(b, Float64(1.0 / d), t_0); elseif (d <= -3e-85) tmp = t_1; elseif (d <= 6.6e-88) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 2.9e+155) tmp = t_1; else tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b * N[(d / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[d, -6.9e+149], N[(b * N[(1.0 / d), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[d, -3e-85], t$95$1, If[LessEqual[d, 6.6e-88], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.9e+155], t$95$1, N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \mathsf{fma}\left(b, \frac{d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}, t\_0\right)\\
\mathbf{if}\;d \leq -6.9 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, t\_0\right)\\
\mathbf{elif}\;d \leq -3 \cdot 10^{-85}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq 6.6 \cdot 10^{-88}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.9 \cdot 10^{+155}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\end{array}
\end{array}
if d < -6.9000000000000004e149Initial program 35.9%
Taylor expanded in a around 0 35.9%
+-commutative35.9%
associate-/l*36.7%
fma-define36.7%
rem-square-sqrt36.7%
unpow236.7%
unpow236.7%
hypot-undefine36.7%
unpow236.7%
unpow236.7%
hypot-undefine36.7%
unpow236.7%
rem-square-sqrt36.7%
Simplified37.3%
*-un-lft-identity37.3%
unpow237.3%
times-frac44.9%
hypot-undefine37.3%
+-commutative37.3%
hypot-define44.9%
hypot-undefine37.3%
+-commutative37.3%
hypot-define44.9%
Applied egg-rr44.9%
associate-*l/44.9%
*-lft-identity44.9%
hypot-undefine37.3%
unpow237.3%
unpow237.3%
+-commutative37.3%
unpow237.3%
unpow237.3%
hypot-define44.9%
hypot-undefine37.3%
unpow237.3%
unpow237.3%
+-commutative37.3%
unpow237.3%
unpow237.3%
hypot-define44.9%
Simplified44.9%
Taylor expanded in d around inf 96.5%
if -6.9000000000000004e149 < d < -3.00000000000000022e-85 or 6.59999999999999987e-88 < d < 2.8999999999999999e155Initial program 74.7%
Taylor expanded in a around 0 74.8%
+-commutative74.8%
associate-/l*79.1%
fma-define79.1%
rem-square-sqrt79.1%
unpow279.1%
unpow279.1%
hypot-undefine79.1%
unpow279.1%
unpow279.1%
hypot-undefine79.1%
unpow279.1%
rem-square-sqrt79.1%
Simplified82.9%
*-un-lft-identity82.9%
unpow282.9%
times-frac89.6%
hypot-undefine82.8%
+-commutative82.8%
hypot-define89.6%
hypot-undefine82.8%
+-commutative82.8%
hypot-define89.6%
Applied egg-rr89.6%
associate-*l/89.7%
*-lft-identity89.7%
hypot-undefine82.9%
unpow282.9%
unpow282.9%
+-commutative82.9%
unpow282.9%
unpow282.9%
hypot-define89.7%
hypot-undefine82.9%
unpow282.9%
unpow282.9%
+-commutative82.9%
unpow282.9%
unpow282.9%
hypot-define89.7%
Simplified89.7%
if -3.00000000000000022e-85 < d < 6.59999999999999987e-88Initial program 66.8%
Taylor expanded in c around inf 94.3%
associate-/l*94.6%
Simplified94.6%
if 2.8999999999999999e155 < d Initial program 22.6%
Taylor expanded in d around inf 85.4%
*-commutative85.4%
Simplified85.4%
associate-/l*94.2%
Applied egg-rr94.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (fma b (/ 1.0 d) (* c (/ (/ a (hypot c d)) (hypot c d)))))
(t_1 (pow (hypot c d) 2.0)))
(if (<= d -1.02e-69)
t_0
(if (<= d 6.2e-87)
(/ (+ a (* b (/ d c))) c)
(if (<= d 2.3e+106) (fma b (/ d t_1) (* c (/ a t_1))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = fma(b, (1.0 / d), (c * ((a / hypot(c, d)) / hypot(c, d))));
double t_1 = pow(hypot(c, d), 2.0);
double tmp;
if (d <= -1.02e-69) {
tmp = t_0;
} else if (d <= 6.2e-87) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 2.3e+106) {
tmp = fma(b, (d / t_1), (c * (a / t_1)));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(b, Float64(1.0 / d), Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))) t_1 = hypot(c, d) ^ 2.0 tmp = 0.0 if (d <= -1.02e-69) tmp = t_0; elseif (d <= 6.2e-87) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 2.3e+106) tmp = fma(b, Float64(d / t_1), Float64(c * Float64(a / t_1))); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(b * N[(1.0 / d), $MachinePrecision] + N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[d, -1.02e-69], t$95$0, If[LessEqual[d, 6.2e-87], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.3e+106], N[(b * N[(d / t$95$1), $MachinePrecision] + N[(c * N[(a / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\
t_1 := {\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}\\
\mathbf{if}\;d \leq -1.02 \cdot 10^{-69}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 6.2 \cdot 10^{-87}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{+106}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{d}{t\_1}, c \cdot \frac{a}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -1.02000000000000005e-69 or 2.3000000000000002e106 < d Initial program 49.5%
Taylor expanded in a around 0 49.5%
+-commutative49.5%
associate-/l*51.8%
fma-define51.8%
rem-square-sqrt51.8%
unpow251.8%
unpow251.8%
hypot-undefine51.8%
unpow251.8%
unpow251.8%
hypot-undefine51.8%
unpow251.8%
rem-square-sqrt51.8%
Simplified52.3%
*-un-lft-identity52.3%
unpow252.3%
times-frac57.1%
hypot-undefine52.3%
+-commutative52.3%
hypot-define57.1%
hypot-undefine52.3%
+-commutative52.3%
hypot-define57.1%
Applied egg-rr57.1%
associate-*l/57.1%
*-lft-identity57.1%
hypot-undefine52.3%
unpow252.3%
unpow252.3%
+-commutative52.3%
unpow252.3%
unpow252.3%
hypot-define57.1%
hypot-undefine52.3%
unpow252.3%
unpow252.3%
+-commutative52.3%
unpow252.3%
unpow252.3%
hypot-define57.1%
Simplified57.1%
Taylor expanded in d around inf 87.0%
if -1.02000000000000005e-69 < d < 6.19999999999999995e-87Initial program 66.8%
Taylor expanded in c around inf 94.3%
associate-/l*94.6%
Simplified94.6%
if 6.19999999999999995e-87 < d < 2.3000000000000002e106Initial program 71.2%
Taylor expanded in a around 0 71.3%
+-commutative71.3%
associate-/l*76.7%
fma-define76.7%
rem-square-sqrt76.7%
unpow276.7%
unpow276.7%
hypot-undefine76.7%
unpow276.7%
unpow276.7%
hypot-undefine76.7%
unpow276.7%
rem-square-sqrt76.7%
Simplified85.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.1e-69) (not (<= d 1.05e-17))) (fma b (/ 1.0 d) (* c (/ (/ a (hypot c d)) (hypot c d)))) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.1e-69) || !(d <= 1.05e-17)) {
tmp = fma(b, (1.0 / d), (c * ((a / hypot(c, d)) / hypot(c, d))));
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.1e-69) || !(d <= 1.05e-17)) tmp = fma(b, Float64(1.0 / d), Float64(c * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.1e-69], N[Not[LessEqual[d, 1.05e-17]], $MachinePrecision]], N[(b * N[(1.0 / d), $MachinePrecision] + N[(c * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.1 \cdot 10^{-69} \lor \neg \left(d \leq 1.05 \cdot 10^{-17}\right):\\
\;\;\;\;\mathsf{fma}\left(b, \frac{1}{d}, c \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.1e-69 or 1.04999999999999996e-17 < d Initial program 52.8%
Taylor expanded in a around 0 52.8%
+-commutative52.8%
associate-/l*55.9%
fma-define55.9%
rem-square-sqrt55.9%
unpow255.9%
unpow255.9%
hypot-undefine55.9%
unpow255.9%
unpow255.9%
hypot-undefine55.9%
unpow255.9%
rem-square-sqrt55.9%
Simplified58.3%
*-un-lft-identity58.3%
unpow258.3%
times-frac63.6%
hypot-undefine58.3%
+-commutative58.3%
hypot-define63.6%
hypot-undefine58.3%
+-commutative58.3%
hypot-define63.6%
Applied egg-rr63.6%
associate-*l/63.6%
*-lft-identity63.6%
hypot-undefine58.3%
unpow258.3%
unpow258.3%
+-commutative58.3%
unpow258.3%
unpow258.3%
hypot-define63.6%
hypot-undefine58.3%
unpow258.3%
unpow258.3%
+-commutative58.3%
unpow258.3%
unpow258.3%
hypot-define63.6%
Simplified63.6%
Taylor expanded in d around inf 84.0%
if -1.1e-69 < d < 1.04999999999999996e-17Initial program 67.7%
Taylor expanded in c around inf 92.1%
associate-/l*92.4%
Simplified92.4%
Final simplification87.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* c c) (* d d)))))
(if (<= d -1.25e+66)
(/ (+ b (* c (/ a d))) d)
(if (<= d -1.5e-89)
t_0
(if (<= d 1.65e-87)
(/ (+ a (* b (/ d c))) c)
(if (<= d 3.5e+103) t_0 (/ (+ b (* a (/ c d))) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.25e+66) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= -1.5e-89) {
tmp = t_0;
} else if (d <= 1.65e-87) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 3.5e+103) {
tmp = t_0;
} else {
tmp = (b + (a * (c / d))) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d))
if (d <= (-1.25d+66)) then
tmp = (b + (c * (a / d))) / d
else if (d <= (-1.5d-89)) then
tmp = t_0
else if (d <= 1.65d-87) then
tmp = (a + (b * (d / c))) / c
else if (d <= 3.5d+103) then
tmp = t_0
else
tmp = (b + (a * (c / d))) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.25e+66) {
tmp = (b + (c * (a / d))) / d;
} else if (d <= -1.5e-89) {
tmp = t_0;
} else if (d <= 1.65e-87) {
tmp = (a + (b * (d / c))) / c;
} else if (d <= 3.5e+103) {
tmp = t_0;
} else {
tmp = (b + (a * (c / d))) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.25e+66: tmp = (b + (c * (a / d))) / d elif d <= -1.5e-89: tmp = t_0 elif d <= 1.65e-87: tmp = (a + (b * (d / c))) / c elif d <= 3.5e+103: tmp = t_0 else: tmp = (b + (a * (c / d))) / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.25e+66) tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); elseif (d <= -1.5e-89) tmp = t_0; elseif (d <= 1.65e-87) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); elseif (d <= 3.5e+103) tmp = t_0; else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((d * b) + (c * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.25e+66) tmp = (b + (c * (a / d))) / d; elseif (d <= -1.5e-89) tmp = t_0; elseif (d <= 1.65e-87) tmp = (a + (b * (d / c))) / c; elseif (d <= 3.5e+103) tmp = t_0; else tmp = (b + (a * (c / d))) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.25e+66], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.5e-89], t$95$0, If[LessEqual[d, 1.65e-87], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.5e+103], t$95$0, N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.25 \cdot 10^{+66}:\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\mathbf{elif}\;d \leq -1.5 \cdot 10^{-89}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.65 \cdot 10^{-87}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.5 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\end{array}
\end{array}
if d < -1.24999999999999998e66Initial program 49.5%
Taylor expanded in d around inf 82.5%
*-commutative82.5%
Simplified82.5%
associate-/l*91.7%
Applied egg-rr91.7%
if -1.24999999999999998e66 < d < -1.5e-89 or 1.65e-87 < d < 3.5e103Initial program 76.5%
if -1.5e-89 < d < 1.65e-87Initial program 66.8%
Taylor expanded in c around inf 94.3%
associate-/l*94.6%
Simplified94.6%
if 3.5e103 < d Initial program 29.9%
Taylor expanded in d around inf 77.2%
*-commutative77.2%
Simplified77.2%
Taylor expanded in c around 0 77.2%
associate-*r/86.4%
Simplified86.4%
Final simplification88.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -29500000.0) (not (<= d 1.7e-16))) (/ (+ b (* c (/ a d))) d) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -29500000.0) || !(d <= 1.7e-16)) {
tmp = (b + (c * (a / d))) / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-29500000.0d0)) .or. (.not. (d <= 1.7d-16))) then
tmp = (b + (c * (a / d))) / d
else
tmp = (a + (b * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -29500000.0) || !(d <= 1.7e-16)) {
tmp = (b + (c * (a / d))) / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -29500000.0) or not (d <= 1.7e-16): tmp = (b + (c * (a / d))) / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -29500000.0) || !(d <= 1.7e-16)) tmp = Float64(Float64(b + Float64(c * Float64(a / d))) / d); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -29500000.0) || ~((d <= 1.7e-16))) tmp = (b + (c * (a / d))) / d; else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -29500000.0], N[Not[LessEqual[d, 1.7e-16]], $MachinePrecision]], N[(N[(b + N[(c * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -29500000 \lor \neg \left(d \leq 1.7 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{b + c \cdot \frac{a}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -2.95e7 or 1.7e-16 < d Initial program 49.3%
Taylor expanded in d around inf 73.9%
*-commutative73.9%
Simplified73.9%
associate-/l*81.4%
Applied egg-rr81.4%
if -2.95e7 < d < 1.7e-16Initial program 69.8%
Taylor expanded in c around inf 88.4%
associate-/l*88.7%
Simplified88.7%
Final simplification84.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -12800000.0) (not (<= d 3.9e-16))) (/ (+ b (* a (/ c d))) d) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -12800000.0) || !(d <= 3.9e-16)) {
tmp = (b + (a * (c / d))) / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-12800000.0d0)) .or. (.not. (d <= 3.9d-16))) then
tmp = (b + (a * (c / d))) / d
else
tmp = (a + (b * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -12800000.0) || !(d <= 3.9e-16)) {
tmp = (b + (a * (c / d))) / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -12800000.0) or not (d <= 3.9e-16): tmp = (b + (a * (c / d))) / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -12800000.0) || !(d <= 3.9e-16)) tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / d); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -12800000.0) || ~((d <= 3.9e-16))) tmp = (b + (a * (c / d))) / d; else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -12800000.0], N[Not[LessEqual[d, 3.9e-16]], $MachinePrecision]], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -12800000 \lor \neg \left(d \leq 3.9 \cdot 10^{-16}\right):\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.28e7 or 3.89999999999999977e-16 < d Initial program 49.3%
Taylor expanded in d around inf 73.9%
*-commutative73.9%
Simplified73.9%
Taylor expanded in c around 0 73.9%
associate-*r/80.6%
Simplified80.6%
if -1.28e7 < d < 3.89999999999999977e-16Initial program 69.8%
Taylor expanded in c around inf 88.4%
associate-/l*88.7%
Simplified88.7%
Final simplification84.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.6e+48) (not (<= d 3.1e+125))) (/ b d) (/ (+ a (* b (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.6e+48) || !(d <= 3.1e+125)) {
tmp = b / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-1.6d+48)) .or. (.not. (d <= 3.1d+125))) then
tmp = b / d
else
tmp = (a + (b * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.6e+48) || !(d <= 3.1e+125)) {
tmp = b / d;
} else {
tmp = (a + (b * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.6e+48) or not (d <= 3.1e+125): tmp = b / d else: tmp = (a + (b * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.6e+48) || !(d <= 3.1e+125)) tmp = Float64(b / d); else tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.6e+48) || ~((d <= 3.1e+125))) tmp = b / d; else tmp = (a + (b * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.6e+48], N[Not[LessEqual[d, 3.1e+125]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.6 \cdot 10^{+48} \lor \neg \left(d \leq 3.1 \cdot 10^{+125}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.6000000000000001e48 or 3.1e125 < d Initial program 42.1%
Taylor expanded in c around 0 82.2%
if -1.6000000000000001e48 < d < 3.1e125Initial program 69.7%
Taylor expanded in c around inf 78.2%
associate-/l*79.6%
Simplified79.6%
Final simplification80.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -45000.0) (not (<= d 3.1e+125))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -45000.0) || !(d <= 3.1e+125)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-45000.0d0)) .or. (.not. (d <= 3.1d+125))) then
tmp = b / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -45000.0) || !(d <= 3.1e+125)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -45000.0) or not (d <= 3.1e+125): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -45000.0) || !(d <= 3.1e+125)) tmp = Float64(b / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -45000.0) || ~((d <= 3.1e+125))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -45000.0], N[Not[LessEqual[d, 3.1e+125]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -45000 \lor \neg \left(d \leq 3.1 \cdot 10^{+125}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -45000 or 3.1e125 < d Initial program 45.0%
Taylor expanded in c around 0 78.8%
if -45000 < d < 3.1e125Initial program 69.0%
Taylor expanded in c around inf 64.1%
Final simplification70.1%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 59.2%
Taylor expanded in c around inf 43.6%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
else
tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (a + (b * (d / c))) / (c + (d * (d / c))) else: tmp = (b + (a * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (a + (b * (d / c))) / (c + (d * (d / c))); else tmp = (b + (a * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2024131
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:alt
(! :herbie-platform default (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))