
(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 (* (/ 1.0 (hypot c d)) (/ (+ (* d b) (* c a)) (hypot c d)))))
(if (<= c -1.8e+150)
(* (/ c (hypot c d)) (/ a (hypot c d)))
(if (<= c -5.3e-141)
t_0
(if (<= c 1.75e-80)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(if (<= c 6.6e+69) t_0 (/ (+ a (/ b (/ c d))) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / hypot(c, d)) * (((d * b) + (c * a)) / hypot(c, d));
double tmp;
if (c <= -1.8e+150) {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
} else if (c <= -5.3e-141) {
tmp = t_0;
} else if (c <= 1.75e-80) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else if (c <= 6.6e+69) {
tmp = t_0;
} else {
tmp = (a + (b / (c / d))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / Math.hypot(c, d)) * (((d * b) + (c * a)) / Math.hypot(c, d));
double tmp;
if (c <= -1.8e+150) {
tmp = (c / Math.hypot(c, d)) * (a / Math.hypot(c, d));
} else if (c <= -5.3e-141) {
tmp = t_0;
} else if (c <= 1.75e-80) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else if (c <= 6.6e+69) {
tmp = t_0;
} else {
tmp = (a + (b / (c / d))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / math.hypot(c, d)) * (((d * b) + (c * a)) / math.hypot(c, d)) tmp = 0 if c <= -1.8e+150: tmp = (c / math.hypot(c, d)) * (a / math.hypot(c, d)) elif c <= -5.3e-141: tmp = t_0 elif c <= 1.75e-80: tmp = (1.0 / d) * (b + (a / (d / c))) elif c <= 6.6e+69: tmp = t_0 else: tmp = (a + (b / (c / d))) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / hypot(c, d)) * Float64(Float64(Float64(d * b) + Float64(c * a)) / hypot(c, d))) tmp = 0.0 if (c <= -1.8e+150) tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); elseif (c <= -5.3e-141) tmp = t_0; elseif (c <= 1.75e-80) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); elseif (c <= 6.6e+69) tmp = t_0; else tmp = Float64(Float64(a + Float64(b / Float64(c / d))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / hypot(c, d)) * (((d * b) + (c * a)) / hypot(c, d)); tmp = 0.0; if (c <= -1.8e+150) tmp = (c / hypot(c, d)) * (a / hypot(c, d)); elseif (c <= -5.3e-141) tmp = t_0; elseif (c <= 1.75e-80) tmp = (1.0 / d) * (b + (a / (d / c))); elseif (c <= 6.6e+69) tmp = t_0; else tmp = (a + (b / (c / d))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.8e+150], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.3e-141], t$95$0, If[LessEqual[c, 1.75e-80], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.6e+69], t$95$0, N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{d \cdot b + c \cdot a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;c \leq -1.8 \cdot 10^{+150}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -5.3 \cdot 10^{-141}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.75 \cdot 10^{-80}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{elif}\;c \leq 6.6 \cdot 10^{+69}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -1.79999999999999993e150Initial program 31.2%
Taylor expanded in a around inf 31.2%
*-commutative31.2%
Simplified31.2%
add-sqr-sqrt31.2%
hypot-udef31.2%
hypot-udef31.2%
times-frac99.9%
Applied egg-rr99.9%
if -1.79999999999999993e150 < c < -5.30000000000000007e-141 or 1.75000000000000007e-80 < c < 6.5999999999999997e69Initial program 80.6%
*-un-lft-identity80.6%
+-commutative80.6%
fma-udef80.6%
add-sqr-sqrt80.6%
times-frac80.6%
fma-udef80.6%
+-commutative80.6%
hypot-def80.6%
fma-def80.6%
fma-udef80.6%
+-commutative80.6%
hypot-def87.2%
Applied egg-rr87.2%
fma-def87.2%
+-commutative87.2%
Applied egg-rr87.2%
if -5.30000000000000007e-141 < c < 1.75000000000000007e-80Initial program 63.5%
*-un-lft-identity63.5%
+-commutative63.5%
fma-udef63.5%
add-sqr-sqrt63.5%
times-frac63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def63.5%
fma-def63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def77.8%
Applied egg-rr77.8%
Taylor expanded in c around 0 61.0%
associate-/l*60.9%
Simplified60.9%
Taylor expanded in c around 0 94.9%
if 6.5999999999999997e69 < c Initial program 46.2%
*-un-lft-identity46.2%
+-commutative46.2%
fma-udef46.2%
add-sqr-sqrt46.2%
times-frac46.2%
fma-udef46.2%
+-commutative46.2%
hypot-def46.2%
fma-def46.2%
fma-udef46.2%
+-commutative46.2%
hypot-def56.4%
Applied egg-rr56.4%
Taylor expanded in c around inf 78.2%
associate-*l/78.3%
*-un-lft-identity78.3%
associate-/l*88.6%
Applied egg-rr88.6%
Final simplification91.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* d b) (* c a))))
(if (<= c -2e+141)
(* (/ c (hypot c d)) (/ a (hypot c d)))
(if (<= c -9.8e-141)
(/ t_0 (fma d d (* c c)))
(if (<= c 1.3e-77)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(if (<= c 250000.0)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 4.2e+21)
(fma (/ (/ a d) d) c (/ b d))
(/ (+ a (/ b (/ c d))) (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (d * b) + (c * a);
double tmp;
if (c <= -2e+141) {
tmp = (c / hypot(c, d)) * (a / hypot(c, d));
} else if (c <= -9.8e-141) {
tmp = t_0 / fma(d, d, (c * c));
} else if (c <= 1.3e-77) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else if (c <= 250000.0) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 4.2e+21) {
tmp = fma(((a / d) / d), c, (b / d));
} else {
tmp = (a + (b / (c / d))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(d * b) + Float64(c * a)) tmp = 0.0 if (c <= -2e+141) tmp = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))); elseif (c <= -9.8e-141) tmp = Float64(t_0 / fma(d, d, Float64(c * c))); elseif (c <= 1.3e-77) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); elseif (c <= 250000.0) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 4.2e+21) tmp = fma(Float64(Float64(a / d) / d), c, Float64(b / d)); else tmp = Float64(Float64(a + Float64(b / Float64(c / d))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2e+141], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -9.8e-141], N[(t$95$0 / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.3e-77], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 250000.0], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.2e+21], N[(N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision] * c + N[(b / d), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d \cdot b + c \cdot a\\
\mathbf{if}\;c \leq -2 \cdot 10^{+141}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -9.8 \cdot 10^{-141}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 1.3 \cdot 10^{-77}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{elif}\;c \leq 250000:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 4.2 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{a}{d}}{d}, c, \frac{b}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -2.00000000000000003e141Initial program 33.1%
Taylor expanded in a around inf 33.1%
*-commutative33.1%
Simplified33.1%
add-sqr-sqrt33.1%
hypot-udef33.1%
hypot-udef33.1%
times-frac99.9%
Applied egg-rr99.9%
if -2.00000000000000003e141 < c < -9.80000000000000012e-141Initial program 83.5%
fma-def83.5%
+-commutative83.5%
fma-def83.6%
Simplified83.6%
fma-def87.1%
+-commutative87.1%
Applied egg-rr83.6%
if -9.80000000000000012e-141 < c < 1.3000000000000001e-77Initial program 63.5%
*-un-lft-identity63.5%
+-commutative63.5%
fma-udef63.5%
add-sqr-sqrt63.5%
times-frac63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def63.5%
fma-def63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def77.8%
Applied egg-rr77.8%
Taylor expanded in c around 0 61.0%
associate-/l*60.9%
Simplified60.9%
Taylor expanded in c around 0 94.9%
if 1.3000000000000001e-77 < c < 2.5e5Initial program 79.5%
if 2.5e5 < c < 4.2e21Initial program 27.0%
Taylor expanded in c around 0 75.8%
+-commutative75.8%
associate-/l*76.1%
associate-/r/76.1%
fma-def76.1%
Simplified76.1%
*-un-lft-identity76.1%
pow276.1%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
if 4.2e21 < c Initial program 53.3%
*-un-lft-identity53.3%
+-commutative53.3%
fma-udef53.3%
add-sqr-sqrt53.3%
times-frac53.3%
fma-udef53.3%
+-commutative53.3%
hypot-def53.3%
fma-def53.3%
fma-udef53.3%
+-commutative53.3%
hypot-def63.0%
Applied egg-rr63.0%
Taylor expanded in c around inf 79.5%
associate-*l/79.6%
*-un-lft-identity79.6%
associate-/l*88.0%
Applied egg-rr88.0%
Final simplification90.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* d b) (* c a)) (+ (* c c) (* d d)))))
(if (<= c -6.8e+67)
(+ (/ a c) (/ b (/ (pow c 2.0) d)))
(if (<= c -1.3e-140)
t_0
(if (<= c 1.6e-78)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(if (<= c 205000.0)
t_0
(if (<= c 1.7e+22)
(fma (/ (/ a d) d) c (/ b d))
(/ (+ a (/ b (/ c d))) (hypot c 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 (c <= -6.8e+67) {
tmp = (a / c) + (b / (pow(c, 2.0) / d));
} else if (c <= -1.3e-140) {
tmp = t_0;
} else if (c <= 1.6e-78) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else if (c <= 205000.0) {
tmp = t_0;
} else if (c <= 1.7e+22) {
tmp = fma(((a / d) / d), c, (b / d));
} else {
tmp = (a + (b / (c / d))) / hypot(c, 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 (c <= -6.8e+67) tmp = Float64(Float64(a / c) + Float64(b / Float64((c ^ 2.0) / d))); elseif (c <= -1.3e-140) tmp = t_0; elseif (c <= 1.6e-78) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); elseif (c <= 205000.0) tmp = t_0; elseif (c <= 1.7e+22) tmp = fma(Float64(Float64(a / d) / d), c, Float64(b / d)); else tmp = Float64(Float64(a + Float64(b / Float64(c / d))) / hypot(c, d)); end return 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[c, -6.8e+67], N[(N[(a / c), $MachinePrecision] + N[(b / N[(N[Power[c, 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -1.3e-140], t$95$0, If[LessEqual[c, 1.6e-78], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 205000.0], t$95$0, If[LessEqual[c, 1.7e+22], N[(N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision] * c + N[(b / d), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -6.8 \cdot 10^{+67}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{{c}^{2}}{d}}\\
\mathbf{elif}\;c \leq -1.3 \cdot 10^{-140}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{-78}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{elif}\;c \leq 205000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.7 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{a}{d}}{d}, c, \frac{b}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -6.8000000000000003e67Initial program 47.2%
Taylor expanded in c around inf 84.7%
associate-/l*86.6%
Simplified86.6%
if -6.8000000000000003e67 < c < -1.2999999999999999e-140 or 1.6e-78 < c < 205000Initial program 82.9%
if -1.2999999999999999e-140 < c < 1.6e-78Initial program 63.5%
*-un-lft-identity63.5%
+-commutative63.5%
fma-udef63.5%
add-sqr-sqrt63.5%
times-frac63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def63.5%
fma-def63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def77.8%
Applied egg-rr77.8%
Taylor expanded in c around 0 61.0%
associate-/l*60.9%
Simplified60.9%
Taylor expanded in c around 0 94.9%
if 205000 < c < 1.7e22Initial program 27.0%
Taylor expanded in c around 0 75.8%
+-commutative75.8%
associate-/l*76.1%
associate-/r/76.1%
fma-def76.1%
Simplified76.1%
*-un-lft-identity76.1%
pow276.1%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
if 1.7e22 < c Initial program 53.3%
*-un-lft-identity53.3%
+-commutative53.3%
fma-udef53.3%
add-sqr-sqrt53.3%
times-frac53.3%
fma-udef53.3%
+-commutative53.3%
hypot-def53.3%
fma-def53.3%
fma-udef53.3%
+-commutative53.3%
hypot-def63.0%
Applied egg-rr63.0%
Taylor expanded in c around inf 79.5%
associate-*l/79.6%
*-un-lft-identity79.6%
associate-/l*88.0%
Applied egg-rr88.0%
Final simplification88.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* d b) (* c a))))
(if (<= c -4.2e+67)
(+ (/ a c) (/ b (/ (pow c 2.0) d)))
(if (<= c -5.5e-139)
(/ t_0 (fma d d (* c c)))
(if (<= c 4.8e-80)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(if (<= c 250000.0)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 1.9e+22)
(fma (/ (/ a d) d) c (/ b d))
(/ (+ a (/ b (/ c d))) (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (d * b) + (c * a);
double tmp;
if (c <= -4.2e+67) {
tmp = (a / c) + (b / (pow(c, 2.0) / d));
} else if (c <= -5.5e-139) {
tmp = t_0 / fma(d, d, (c * c));
} else if (c <= 4.8e-80) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else if (c <= 250000.0) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 1.9e+22) {
tmp = fma(((a / d) / d), c, (b / d));
} else {
tmp = (a + (b / (c / d))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(d * b) + Float64(c * a)) tmp = 0.0 if (c <= -4.2e+67) tmp = Float64(Float64(a / c) + Float64(b / Float64((c ^ 2.0) / d))); elseif (c <= -5.5e-139) tmp = Float64(t_0 / fma(d, d, Float64(c * c))); elseif (c <= 4.8e-80) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); elseif (c <= 250000.0) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.9e+22) tmp = fma(Float64(Float64(a / d) / d), c, Float64(b / d)); else tmp = Float64(Float64(a + Float64(b / Float64(c / d))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.2e+67], N[(N[(a / c), $MachinePrecision] + N[(b / N[(N[Power[c, 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -5.5e-139], N[(t$95$0 / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.8e-80], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 250000.0], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.9e+22], N[(N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision] * c + N[(b / d), $MachinePrecision]), $MachinePrecision], N[(N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d \cdot b + c \cdot a\\
\mathbf{if}\;c \leq -4.2 \cdot 10^{+67}:\\
\;\;\;\;\frac{a}{c} + \frac{b}{\frac{{c}^{2}}{d}}\\
\mathbf{elif}\;c \leq -5.5 \cdot 10^{-139}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;c \leq 4.8 \cdot 10^{-80}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{elif}\;c \leq 250000:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.9 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{a}{d}}{d}, c, \frac{b}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a + \frac{b}{\frac{c}{d}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -4.2000000000000003e67Initial program 47.2%
Taylor expanded in c around inf 84.7%
associate-/l*86.6%
Simplified86.6%
if -4.2000000000000003e67 < c < -5.4999999999999997e-139Initial program 84.8%
fma-def84.8%
+-commutative84.8%
fma-def84.9%
Simplified84.9%
fma-def89.6%
+-commutative89.6%
Applied egg-rr84.9%
if -5.4999999999999997e-139 < c < 4.7999999999999998e-80Initial program 63.5%
*-un-lft-identity63.5%
+-commutative63.5%
fma-udef63.5%
add-sqr-sqrt63.5%
times-frac63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def63.5%
fma-def63.5%
fma-udef63.5%
+-commutative63.5%
hypot-def77.8%
Applied egg-rr77.8%
Taylor expanded in c around 0 61.0%
associate-/l*60.9%
Simplified60.9%
Taylor expanded in c around 0 94.9%
if 4.7999999999999998e-80 < c < 2.5e5Initial program 79.5%
if 2.5e5 < c < 1.9000000000000002e22Initial program 27.0%
Taylor expanded in c around 0 75.8%
+-commutative75.8%
associate-/l*76.1%
associate-/r/76.1%
fma-def76.1%
Simplified76.1%
*-un-lft-identity76.1%
pow276.1%
times-frac99.6%
Applied egg-rr99.6%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
if 1.9000000000000002e22 < c Initial program 53.3%
*-un-lft-identity53.3%
+-commutative53.3%
fma-udef53.3%
add-sqr-sqrt53.3%
times-frac53.3%
fma-udef53.3%
+-commutative53.3%
hypot-def53.3%
fma-def53.3%
fma-udef53.3%
+-commutative53.3%
hypot-def63.0%
Applied egg-rr63.0%
Taylor expanded in c around inf 79.5%
associate-*l/79.6%
*-un-lft-identity79.6%
associate-/l*88.0%
Applied egg-rr88.0%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(if (<= d -2.3e+46)
(* (/ 1.0 d) (+ b (/ a (/ d c))))
(if (<= d 4e-125)
(* (/ 1.0 c) (+ a (/ (* d b) c)))
(if (<= d 7.2e+106)
(/ (+ (* d b) (* c a)) (+ (* c c) (* d d)))
(fma (/ (/ a d) d) c (/ b d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.3e+46) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else if (d <= 4e-125) {
tmp = (1.0 / c) * (a + ((d * b) / c));
} else if (d <= 7.2e+106) {
tmp = ((d * b) + (c * a)) / ((c * c) + (d * d));
} else {
tmp = fma(((a / d) / d), c, (b / d));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -2.3e+46) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); elseif (d <= 4e-125) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(Float64(d * b) / c))); elseif (d <= 7.2e+106) tmp = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = fma(Float64(Float64(a / d) / d), c, Float64(b / d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.3e+46], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4e-125], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.2e+106], N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision] * c + N[(b / d), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.3 \cdot 10^{+46}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{elif}\;d \leq 4 \cdot 10^{-125}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d \cdot b}{c}\right)\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{+106}:\\
\;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{a}{d}}{d}, c, \frac{b}{d}\right)\\
\end{array}
\end{array}
if d < -2.3000000000000001e46Initial program 39.0%
*-un-lft-identity39.0%
+-commutative39.0%
fma-udef39.0%
add-sqr-sqrt39.0%
times-frac39.0%
fma-udef39.0%
+-commutative39.0%
hypot-def39.0%
fma-def39.0%
fma-udef39.0%
+-commutative39.0%
hypot-def55.4%
Applied egg-rr55.4%
Taylor expanded in c around 0 26.3%
associate-/l*26.5%
Simplified26.5%
Taylor expanded in c around 0 86.5%
if -2.3000000000000001e46 < d < 4.00000000000000005e-125Initial program 73.0%
*-un-lft-identity73.0%
+-commutative73.0%
fma-udef73.0%
add-sqr-sqrt73.0%
times-frac73.1%
fma-udef73.1%
+-commutative73.1%
hypot-def73.1%
fma-def73.1%
fma-udef73.1%
+-commutative73.1%
hypot-def83.6%
Applied egg-rr83.6%
Taylor expanded in c around inf 50.9%
Taylor expanded in c around inf 84.5%
if 4.00000000000000005e-125 < d < 7.2000000000000002e106Initial program 76.2%
if 7.2000000000000002e106 < d Initial program 24.6%
Taylor expanded in c around 0 75.0%
+-commutative75.0%
associate-/l*72.6%
associate-/r/75.7%
fma-def75.7%
Simplified75.7%
*-un-lft-identity75.7%
pow275.7%
times-frac87.6%
Applied egg-rr87.6%
associate-*l/87.6%
*-lft-identity87.6%
Simplified87.6%
Final simplification83.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 d) (+ b (/ a (/ d c))))))
(if (<= d -3.5e+47)
t_0
(if (<= d 2e-126)
(* (/ 1.0 c) (+ a (/ (* d b) c)))
(if (<= d 7e+108) (/ (+ (* d b) (* c a)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a / (d / c)));
double tmp;
if (d <= -3.5e+47) {
tmp = t_0;
} else if (d <= 2e-126) {
tmp = (1.0 / c) * (a + ((d * b) / c));
} else if (d <= 7e+108) {
tmp = ((d * b) + (c * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
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 = (1.0d0 / d) * (b + (a / (d / c)))
if (d <= (-3.5d+47)) then
tmp = t_0
else if (d <= 2d-126) then
tmp = (1.0d0 / c) * (a + ((d * b) / c))
else if (d <= 7d+108) then
tmp = ((d * b) + (c * a)) / ((c * c) + (d * d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / d) * (b + (a / (d / c)));
double tmp;
if (d <= -3.5e+47) {
tmp = t_0;
} else if (d <= 2e-126) {
tmp = (1.0 / c) * (a + ((d * b) / c));
} else if (d <= 7e+108) {
tmp = ((d * b) + (c * a)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / d) * (b + (a / (d / c))) tmp = 0 if d <= -3.5e+47: tmp = t_0 elif d <= 2e-126: tmp = (1.0 / c) * (a + ((d * b) / c)) elif d <= 7e+108: tmp = ((d * b) + (c * a)) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))) tmp = 0.0 if (d <= -3.5e+47) tmp = t_0; elseif (d <= 2e-126) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(Float64(d * b) / c))); elseif (d <= 7e+108) tmp = Float64(Float64(Float64(d * b) + Float64(c * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / d) * (b + (a / (d / c))); tmp = 0.0; if (d <= -3.5e+47) tmp = t_0; elseif (d <= 2e-126) tmp = (1.0 / c) * (a + ((d * b) / c)); elseif (d <= 7e+108) tmp = ((d * b) + (c * a)) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.5e+47], t$95$0, If[LessEqual[d, 2e-126], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7e+108], N[(N[(N[(d * b), $MachinePrecision] + N[(c * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{if}\;d \leq -3.5 \cdot 10^{+47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2 \cdot 10^{-126}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d \cdot b}{c}\right)\\
\mathbf{elif}\;d \leq 7 \cdot 10^{+108}:\\
\;\;\;\;\frac{d \cdot b + c \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -3.50000000000000015e47 or 7.0000000000000005e108 < d Initial program 33.3%
*-un-lft-identity33.3%
+-commutative33.3%
fma-udef33.4%
add-sqr-sqrt33.4%
times-frac33.3%
fma-udef33.3%
+-commutative33.3%
hypot-def33.3%
fma-def33.3%
fma-udef33.3%
+-commutative33.3%
hypot-def50.7%
Applied egg-rr50.7%
Taylor expanded in c around 0 47.7%
associate-/l*50.5%
Simplified50.5%
Taylor expanded in c around 0 86.9%
if -3.50000000000000015e47 < d < 1.9999999999999999e-126Initial program 73.0%
*-un-lft-identity73.0%
+-commutative73.0%
fma-udef73.0%
add-sqr-sqrt73.0%
times-frac73.1%
fma-udef73.1%
+-commutative73.1%
hypot-def73.1%
fma-def73.1%
fma-udef73.1%
+-commutative73.1%
hypot-def83.6%
Applied egg-rr83.6%
Taylor expanded in c around inf 50.9%
Taylor expanded in c around inf 84.5%
if 1.9999999999999999e-126 < d < 7.0000000000000005e108Initial program 76.2%
Final simplification83.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.2e+47) (not (<= d 1.9e+103))) (/ b d) (* (/ 1.0 c) (+ a (/ (* d b) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.2e+47) || !(d <= 1.9e+103)) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + ((d * b) / 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 <= (-2.2d+47)) .or. (.not. (d <= 1.9d+103))) then
tmp = b / d
else
tmp = (1.0d0 / c) * (a + ((d * b) / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.2e+47) || !(d <= 1.9e+103)) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + ((d * b) / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.2e+47) or not (d <= 1.9e+103): tmp = b / d else: tmp = (1.0 / c) * (a + ((d * b) / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.2e+47) || !(d <= 1.9e+103)) tmp = Float64(b / d); else tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(Float64(d * b) / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.2e+47) || ~((d <= 1.9e+103))) tmp = b / d; else tmp = (1.0 / c) * (a + ((d * b) / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.2e+47], N[Not[LessEqual[d, 1.9e+103]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.2 \cdot 10^{+47} \lor \neg \left(d \leq 1.9 \cdot 10^{+103}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d \cdot b}{c}\right)\\
\end{array}
\end{array}
if d < -2.1999999999999999e47 or 1.8999999999999998e103 < d Initial program 35.8%
Taylor expanded in c around 0 72.5%
if -2.1999999999999999e47 < d < 1.8999999999999998e103Initial program 73.6%
*-un-lft-identity73.6%
+-commutative73.6%
fma-udef73.6%
add-sqr-sqrt73.6%
times-frac73.7%
fma-udef73.6%
+-commutative73.6%
hypot-def73.7%
fma-def73.7%
fma-udef73.7%
+-commutative73.7%
hypot-def83.5%
Applied egg-rr83.5%
Taylor expanded in c around inf 50.2%
Taylor expanded in c around inf 78.8%
Final simplification76.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.4e+47) (not (<= d 1.75e+62))) (* (/ 1.0 d) (+ b (/ a (/ d c)))) (* (/ 1.0 c) (+ a (/ (* d b) c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.4e+47) || !(d <= 1.75e+62)) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (1.0 / c) * (a + ((d * b) / 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 <= (-4.4d+47)) .or. (.not. (d <= 1.75d+62))) then
tmp = (1.0d0 / d) * (b + (a / (d / c)))
else
tmp = (1.0d0 / c) * (a + ((d * b) / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.4e+47) || !(d <= 1.75e+62)) {
tmp = (1.0 / d) * (b + (a / (d / c)));
} else {
tmp = (1.0 / c) * (a + ((d * b) / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.4e+47) or not (d <= 1.75e+62): tmp = (1.0 / d) * (b + (a / (d / c))) else: tmp = (1.0 / c) * (a + ((d * b) / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.4e+47) || !(d <= 1.75e+62)) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(a / Float64(d / c)))); else tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(Float64(d * b) / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.4e+47) || ~((d <= 1.75e+62))) tmp = (1.0 / d) * (b + (a / (d / c))); else tmp = (1.0 / c) * (a + ((d * b) / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.4e+47], N[Not[LessEqual[d, 1.75e+62]], $MachinePrecision]], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(N[(d * b), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.4 \cdot 10^{+47} \lor \neg \left(d \leq 1.75 \cdot 10^{+62}\right):\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a}{\frac{d}{c}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{d \cdot b}{c}\right)\\
\end{array}
\end{array}
if d < -4.3999999999999999e47 or 1.74999999999999992e62 < d Initial program 36.5%
*-un-lft-identity36.5%
+-commutative36.5%
fma-udef36.5%
add-sqr-sqrt36.5%
times-frac36.4%
fma-udef36.4%
+-commutative36.4%
hypot-def36.4%
fma-def36.4%
fma-udef36.4%
+-commutative36.4%
hypot-def53.0%
Applied egg-rr53.0%
Taylor expanded in c around 0 48.3%
associate-/l*50.8%
Simplified50.8%
Taylor expanded in c around 0 83.0%
if -4.3999999999999999e47 < d < 1.74999999999999992e62Initial program 74.8%
*-un-lft-identity74.8%
+-commutative74.8%
fma-udef74.8%
add-sqr-sqrt74.8%
times-frac74.9%
fma-udef74.9%
+-commutative74.9%
hypot-def74.9%
fma-def74.9%
fma-udef74.9%
+-commutative74.9%
hypot-def84.6%
Applied egg-rr84.6%
Taylor expanded in c around inf 51.5%
Taylor expanded in c around inf 80.3%
Final simplification81.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.65e+67) (not (<= c 0.016))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.65e+67) || !(c <= 0.016)) {
tmp = a / c;
} else {
tmp = b / 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 ((c <= (-2.65d+67)) .or. (.not. (c <= 0.016d0))) then
tmp = a / c
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.65e+67) || !(c <= 0.016)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.65e+67) or not (c <= 0.016): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.65e+67) || !(c <= 0.016)) tmp = Float64(a / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.65e+67) || ~((c <= 0.016))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.65e+67], N[Not[LessEqual[c, 0.016]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.65 \cdot 10^{+67} \lor \neg \left(c \leq 0.016\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -2.65e67 or 0.016 < c Initial program 51.9%
Taylor expanded in c around inf 75.4%
if -2.65e67 < c < 0.016Initial program 71.3%
Taylor expanded in c around 0 60.7%
Final simplification68.2%
(FPCore (a b c d) :precision binary64 (if (<= d -4.4e+240) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.4e+240) {
tmp = a / 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 <= (-4.4d+240)) then
tmp = a / 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 <= -4.4e+240) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.4e+240: tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.4e+240) tmp = Float64(a / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -4.4e+240) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.4e+240], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.4 \cdot 10^{+240}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -4.4000000000000003e240Initial program 48.7%
*-un-lft-identity48.7%
+-commutative48.7%
fma-udef48.7%
add-sqr-sqrt48.7%
times-frac48.7%
fma-udef48.7%
+-commutative48.7%
hypot-def48.7%
fma-def48.7%
fma-udef48.7%
+-commutative48.7%
hypot-def54.4%
Applied egg-rr54.4%
Taylor expanded in c around inf 31.9%
Taylor expanded in c around 0 32.4%
if -4.4000000000000003e240 < d Initial program 62.3%
Taylor expanded in c around inf 51.6%
Final simplification50.5%
(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 61.5%
Taylor expanded in c around inf 48.8%
Final simplification48.8%
(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 2023309
(FPCore (a b c d)
:name "Complex division, real part"
:precision binary64
:herbie-target
(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))))