
(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 10 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 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= t_0 (- INFINITY))
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= t_0 1e+298)
(/ (/ (fma b d (* a c)) (hypot c d)) (hypot c d))
(+ (/ b d) (* c (* (/ 1.0 d) (/ a d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (t_0 <= 1e+298) {
tmp = (fma(b, d, (a * c)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (t_0 <= 1e+298) tmp = Float64(Float64(fma(b, d, Float64(a * c)) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(1.0 / d) * Float64(a / d)))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+298], N[(N[(N[(b * d + N[(a * c), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;t_0 \leq 10^{+298}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, d, a \cdot c\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + c \cdot \left(\frac{1}{d} \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 56.1%
*-un-lft-identity56.1%
+-commutative56.1%
fma-udef56.1%
add-sqr-sqrt56.1%
times-frac56.1%
fma-udef56.1%
+-commutative56.1%
hypot-def56.1%
fma-def56.1%
fma-udef56.1%
+-commutative56.1%
hypot-def63.2%
Applied egg-rr63.2%
Taylor expanded in c around inf 54.0%
associate-/l*54.0%
Simplified54.0%
Taylor expanded in c around inf 100.0%
if -inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999996e297Initial program 82.4%
*-un-lft-identity82.4%
+-commutative82.4%
fma-udef82.4%
add-sqr-sqrt82.4%
times-frac82.4%
fma-udef82.4%
+-commutative82.4%
hypot-def82.4%
fma-def82.4%
fma-udef82.4%
+-commutative82.4%
hypot-def99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-*l/99.7%
div-inv99.8%
fma-def99.8%
+-commutative99.8%
fma-def99.8%
Applied egg-rr99.8%
if 9.9999999999999996e297 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 8.3%
Taylor expanded in c around 0 39.1%
associate-/l*48.6%
associate-/r/48.6%
Simplified48.6%
*-un-lft-identity48.6%
unpow248.6%
times-frac55.0%
Applied egg-rr55.0%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 (- INFINITY))
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= t_1 1e+298)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(+ (/ b d) (* c (* (/ 1.0 d) (/ a d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (t_1 <= 1e+298) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (t_1 <= 1e+298) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= -math.inf: tmp = (1.0 / c) * (a + (b / (c / d))) elif t_1 <= 1e+298: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (b / d) + (c * ((1.0 / d) * (a / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (t_1 <= 1e+298) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(1.0 / d) * Float64(a / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= -Inf) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (t_1 <= 1e+298) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (b / d) + (c * ((1.0 / d) * (a / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+298], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;t_1 \leq 10^{+298}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d} + c \cdot \left(\frac{1}{d} \cdot \frac{a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 56.1%
*-un-lft-identity56.1%
+-commutative56.1%
fma-udef56.1%
add-sqr-sqrt56.1%
times-frac56.1%
fma-udef56.1%
+-commutative56.1%
hypot-def56.1%
fma-def56.1%
fma-udef56.1%
+-commutative56.1%
hypot-def63.2%
Applied egg-rr63.2%
Taylor expanded in c around inf 54.0%
associate-/l*54.0%
Simplified54.0%
Taylor expanded in c around inf 100.0%
if -inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 9.9999999999999996e297Initial program 82.4%
*-un-lft-identity82.4%
+-commutative82.4%
fma-udef82.4%
add-sqr-sqrt82.4%
times-frac82.4%
fma-udef82.4%
+-commutative82.4%
hypot-def82.4%
fma-def82.4%
fma-udef82.4%
+-commutative82.4%
hypot-def99.6%
Applied egg-rr99.6%
fma-def82.4%
+-commutative82.4%
Applied egg-rr99.6%
if 9.9999999999999996e297 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 8.3%
Taylor expanded in c around 0 39.1%
associate-/l*48.6%
associate-/r/48.6%
Simplified48.6%
*-un-lft-identity48.6%
unpow248.6%
times-frac55.0%
Applied egg-rr55.0%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ c (hypot c d)) (/ a (hypot c d)))))
(if (<= d -2.6e+92)
(+ (/ b d) (* c (* (/ 1.0 d) (/ a d))))
(if (<= d -3.6e-69)
t_0
(if (<= d 4.2e-87)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= d 1.62e-12)
(/ (+ (* a c) (* b d)) (fma d d (* c c)))
(if (<= d 3.4e+61) t_0 (/ (+ b (/ a (/ d c))) (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c / hypot(c, d)) * (a / hypot(c, d));
double tmp;
if (d <= -2.6e+92) {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
} else if (d <= -3.6e-69) {
tmp = t_0;
} else if (d <= 4.2e-87) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 1.62e-12) {
tmp = ((a * c) + (b * d)) / fma(d, d, (c * c));
} else if (d <= 3.4e+61) {
tmp = t_0;
} else {
tmp = (b + (a / (d / c))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c / hypot(c, d)) * Float64(a / hypot(c, d))) tmp = 0.0 if (d <= -2.6e+92) tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(1.0 / d) * Float64(a / d)))); elseif (d <= -3.6e-69) tmp = t_0; elseif (d <= 4.2e-87) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (d <= 1.62e-12) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / fma(d, d, Float64(c * c))); elseif (d <= 3.4e+61) tmp = t_0; else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.6e+92], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.6e-69], t$95$0, If[LessEqual[d, 4.2e-87], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.62e-12], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.4e+61], t$95$0, N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{+92}:\\
\;\;\;\;\frac{b}{d} + c \cdot \left(\frac{1}{d} \cdot \frac{a}{d}\right)\\
\mathbf{elif}\;d \leq -3.6 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.2 \cdot 10^{-87}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.62 \cdot 10^{-12}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;d \leq 3.4 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -2.5999999999999999e92Initial program 37.2%
Taylor expanded in c around 0 64.8%
associate-/l*70.3%
associate-/r/72.7%
Simplified72.7%
*-un-lft-identity72.7%
unpow272.7%
times-frac80.0%
Applied egg-rr80.0%
if -2.5999999999999999e92 < d < -3.60000000000000018e-69 or 1.62e-12 < d < 3.40000000000000026e61Initial program 66.5%
Taylor expanded in a around inf 56.5%
*-commutative56.5%
Simplified56.5%
add-sqr-sqrt56.5%
hypot-udef56.5%
hypot-udef56.5%
times-frac83.7%
Applied egg-rr83.7%
if -3.60000000000000018e-69 < d < 4.20000000000000014e-87Initial program 68.9%
*-un-lft-identity68.9%
+-commutative68.9%
fma-udef68.9%
add-sqr-sqrt68.9%
times-frac68.9%
fma-udef68.9%
+-commutative68.9%
hypot-def68.9%
fma-def68.9%
fma-udef68.9%
+-commutative68.9%
hypot-def79.4%
Applied egg-rr79.4%
Taylor expanded in c around inf 50.9%
associate-/l*52.0%
Simplified52.0%
Taylor expanded in c around inf 86.4%
if 4.20000000000000014e-87 < d < 1.62e-12Initial program 82.3%
fma-def82.3%
+-commutative82.3%
fma-def82.3%
Simplified82.3%
fma-def82.3%
+-commutative82.3%
Applied egg-rr82.3%
if 3.40000000000000026e61 < d Initial program 46.3%
*-un-lft-identity46.3%
+-commutative46.3%
fma-udef46.3%
add-sqr-sqrt46.3%
times-frac46.3%
fma-udef46.3%
+-commutative46.3%
hypot-def46.3%
fma-def46.3%
fma-udef46.3%
+-commutative46.3%
hypot-def61.1%
Applied egg-rr61.1%
*-commutative61.1%
associate-*l/61.1%
div-inv61.2%
fma-def61.1%
+-commutative61.1%
fma-def61.1%
Applied egg-rr61.1%
Taylor expanded in d around inf 81.1%
associate-/l*88.2%
Simplified88.2%
Final simplification84.7%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.8e+91)
(+ (/ b d) (* c (* (/ 1.0 d) (/ a d))))
(if (<= d 2.05e-88)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= d 2.2e+45)
(/ (+ (* a c) (* b d)) (fma d d (* c c)))
(/ (+ b (/ a (/ d c))) (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.8e+91) {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
} else if (d <= 2.05e-88) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 2.2e+45) {
tmp = ((a * c) + (b * d)) / fma(d, d, (c * c));
} else {
tmp = (b + (a / (d / c))) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -4.8e+91) tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(1.0 / d) * Float64(a / d)))); elseif (d <= 2.05e-88) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (d <= 2.2e+45) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / fma(d, d, Float64(c * c))); else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.8e+91], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.05e-88], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.2e+45], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{+91}:\\
\;\;\;\;\frac{b}{d} + c \cdot \left(\frac{1}{d} \cdot \frac{a}{d}\right)\\
\mathbf{elif}\;d \leq 2.05 \cdot 10^{-88}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{+45}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -4.79999999999999966e91Initial program 37.2%
Taylor expanded in c around 0 64.8%
associate-/l*70.3%
associate-/r/72.7%
Simplified72.7%
*-un-lft-identity72.7%
unpow272.7%
times-frac80.0%
Applied egg-rr80.0%
if -4.79999999999999966e91 < d < 2.0500000000000001e-88Initial program 69.6%
*-un-lft-identity69.6%
+-commutative69.6%
fma-udef69.6%
add-sqr-sqrt69.6%
times-frac69.6%
fma-udef69.6%
+-commutative69.6%
hypot-def69.6%
fma-def69.6%
fma-udef69.6%
+-commutative69.6%
hypot-def80.9%
Applied egg-rr80.9%
Taylor expanded in c around inf 48.8%
associate-/l*49.6%
Simplified49.6%
Taylor expanded in c around inf 81.9%
if 2.0500000000000001e-88 < d < 2.2e45Initial program 72.9%
fma-def72.9%
+-commutative72.9%
fma-def73.0%
Simplified73.0%
fma-def73.0%
+-commutative73.0%
Applied egg-rr73.0%
if 2.2e45 < d Initial program 46.4%
*-un-lft-identity46.4%
+-commutative46.4%
fma-udef46.4%
add-sqr-sqrt46.4%
times-frac46.5%
fma-udef46.5%
+-commutative46.5%
hypot-def46.5%
fma-def46.5%
fma-udef46.5%
+-commutative46.5%
hypot-def60.8%
Applied egg-rr60.8%
*-commutative60.8%
associate-*l/60.8%
div-inv60.8%
fma-def60.8%
+-commutative60.8%
fma-def60.8%
Applied egg-rr60.8%
Taylor expanded in d around inf 80.1%
associate-/l*86.9%
Simplified86.9%
Final simplification81.3%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.8e+91)
(+ (/ b d) (* c (* (/ 1.0 d) (/ a d))))
(if (<= d 4e-88)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= d 2.2e+45)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(/ (+ b (/ a (/ d c))) (hypot c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.8e+91) {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
} else if (d <= 4e-88) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 2.2e+45) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (b + (a / (d / c))) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.8e+91) {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
} else if (d <= 4e-88) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 2.2e+45) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (b + (a / (d / c))) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.8e+91: tmp = (b / d) + (c * ((1.0 / d) * (a / d))) elif d <= 4e-88: tmp = (1.0 / c) * (a + (b / (c / d))) elif d <= 2.2e+45: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = (b + (a / (d / c))) / math.hypot(c, d) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.8e+91) tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(1.0 / d) * Float64(a / d)))); elseif (d <= 4e-88) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (d <= 2.2e+45) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(b + Float64(a / Float64(d / c))) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -4.8e+91) tmp = (b / d) + (c * ((1.0 / d) * (a / d))); elseif (d <= 4e-88) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (d <= 2.2e+45) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = (b + (a / (d / c))) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.8e+91], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4e-88], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.2e+45], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{+91}:\\
\;\;\;\;\frac{b}{d} + c \cdot \left(\frac{1}{d} \cdot \frac{a}{d}\right)\\
\mathbf{elif}\;d \leq 4 \cdot 10^{-88}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{+45}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + \frac{a}{\frac{d}{c}}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -4.79999999999999966e91Initial program 37.2%
Taylor expanded in c around 0 64.8%
associate-/l*70.3%
associate-/r/72.7%
Simplified72.7%
*-un-lft-identity72.7%
unpow272.7%
times-frac80.0%
Applied egg-rr80.0%
if -4.79999999999999966e91 < d < 3.99999999999999974e-88Initial program 69.6%
*-un-lft-identity69.6%
+-commutative69.6%
fma-udef69.6%
add-sqr-sqrt69.6%
times-frac69.6%
fma-udef69.6%
+-commutative69.6%
hypot-def69.6%
fma-def69.6%
fma-udef69.6%
+-commutative69.6%
hypot-def80.9%
Applied egg-rr80.9%
Taylor expanded in c around inf 48.8%
associate-/l*49.6%
Simplified49.6%
Taylor expanded in c around inf 81.9%
if 3.99999999999999974e-88 < d < 2.2e45Initial program 72.9%
if 2.2e45 < d Initial program 46.4%
*-un-lft-identity46.4%
+-commutative46.4%
fma-udef46.4%
add-sqr-sqrt46.4%
times-frac46.5%
fma-udef46.5%
+-commutative46.5%
hypot-def46.5%
fma-def46.5%
fma-udef46.5%
+-commutative46.5%
hypot-def60.8%
Applied egg-rr60.8%
*-commutative60.8%
associate-*l/60.8%
div-inv60.8%
fma-def60.8%
+-commutative60.8%
fma-def60.8%
Applied egg-rr60.8%
Taylor expanded in d around inf 80.1%
associate-/l*86.9%
Simplified86.9%
Final simplification81.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ b d) (* c (* (/ 1.0 d) (/ a d))))))
(if (<= d -4.8e+91)
t_0
(if (<= d 4.6e-88)
(* (/ 1.0 c) (+ a (/ b (/ c d))))
(if (<= d 1.55e+43) (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / d) + (c * ((1.0 / d) * (a / d)));
double tmp;
if (d <= -4.8e+91) {
tmp = t_0;
} else if (d <= 4.6e-88) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 1.55e+43) {
tmp = ((a * c) + (b * d)) / ((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 = (b / d) + (c * ((1.0d0 / d) * (a / d)))
if (d <= (-4.8d+91)) then
tmp = t_0
else if (d <= 4.6d-88) then
tmp = (1.0d0 / c) * (a + (b / (c / d)))
else if (d <= 1.55d+43) then
tmp = ((a * c) + (b * d)) / ((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 = (b / d) + (c * ((1.0 / d) * (a / d)));
double tmp;
if (d <= -4.8e+91) {
tmp = t_0;
} else if (d <= 4.6e-88) {
tmp = (1.0 / c) * (a + (b / (c / d)));
} else if (d <= 1.55e+43) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / d) + (c * ((1.0 / d) * (a / d))) tmp = 0 if d <= -4.8e+91: tmp = t_0 elif d <= 4.6e-88: tmp = (1.0 / c) * (a + (b / (c / d))) elif d <= 1.55e+43: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / d) + Float64(c * Float64(Float64(1.0 / d) * Float64(a / d)))) tmp = 0.0 if (d <= -4.8e+91) tmp = t_0; elseif (d <= 4.6e-88) tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); elseif (d <= 1.55e+43) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / 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 = (b / d) + (c * ((1.0 / d) * (a / d))); tmp = 0.0; if (d <= -4.8e+91) tmp = t_0; elseif (d <= 4.6e-88) tmp = (1.0 / c) * (a + (b / (c / d))); elseif (d <= 1.55e+43) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.8e+91], t$95$0, If[LessEqual[d, 4.6e-88], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.55e+43], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $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{b}{d} + c \cdot \left(\frac{1}{d} \cdot \frac{a}{d}\right)\\
\mathbf{if}\;d \leq -4.8 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{-88}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.55 \cdot 10^{+43}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -4.79999999999999966e91 or 1.5500000000000001e43 < d Initial program 42.0%
Taylor expanded in c around 0 72.5%
associate-/l*75.3%
associate-/r/77.1%
Simplified77.1%
*-un-lft-identity77.1%
unpow277.1%
times-frac82.4%
Applied egg-rr82.4%
if -4.79999999999999966e91 < d < 4.59999999999999972e-88Initial program 69.6%
*-un-lft-identity69.6%
+-commutative69.6%
fma-udef69.6%
add-sqr-sqrt69.6%
times-frac69.6%
fma-udef69.6%
+-commutative69.6%
hypot-def69.6%
fma-def69.6%
fma-udef69.6%
+-commutative69.6%
hypot-def80.9%
Applied egg-rr80.9%
Taylor expanded in c around inf 48.8%
associate-/l*49.6%
Simplified49.6%
Taylor expanded in c around inf 81.9%
if 4.59999999999999972e-88 < d < 1.5500000000000001e43Initial program 72.9%
Final simplification80.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -6.2e+91) (not (<= d 1.3e+43))) (+ (/ b d) (* c (* (/ 1.0 d) (/ a d)))) (* (/ 1.0 c) (+ a (/ b (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6.2e+91) || !(d <= 1.3e+43)) {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
} else {
tmp = (1.0 / c) * (a + (b / (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 ((d <= (-6.2d+91)) .or. (.not. (d <= 1.3d+43))) then
tmp = (b / d) + (c * ((1.0d0 / d) * (a / d)))
else
tmp = (1.0d0 / c) * (a + (b / (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -6.2e+91) || !(d <= 1.3e+43)) {
tmp = (b / d) + (c * ((1.0 / d) * (a / d)));
} else {
tmp = (1.0 / c) * (a + (b / (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -6.2e+91) or not (d <= 1.3e+43): tmp = (b / d) + (c * ((1.0 / d) * (a / d))) else: tmp = (1.0 / c) * (a + (b / (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -6.2e+91) || !(d <= 1.3e+43)) tmp = Float64(Float64(b / d) + Float64(c * Float64(Float64(1.0 / d) * Float64(a / d)))); else tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -6.2e+91) || ~((d <= 1.3e+43))) tmp = (b / d) + (c * ((1.0 / d) * (a / d))); else tmp = (1.0 / c) * (a + (b / (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -6.2e+91], N[Not[LessEqual[d, 1.3e+43]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -6.2 \cdot 10^{+91} \lor \neg \left(d \leq 1.3 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{b}{d} + c \cdot \left(\frac{1}{d} \cdot \frac{a}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if d < -6.19999999999999995e91 or 1.3000000000000001e43 < d Initial program 42.0%
Taylor expanded in c around 0 72.5%
associate-/l*75.3%
associate-/r/77.1%
Simplified77.1%
*-un-lft-identity77.1%
unpow277.1%
times-frac82.4%
Applied egg-rr82.4%
if -6.19999999999999995e91 < d < 1.3000000000000001e43Initial program 70.4%
*-un-lft-identity70.4%
+-commutative70.4%
fma-udef70.5%
add-sqr-sqrt70.5%
times-frac70.4%
fma-udef70.4%
+-commutative70.4%
hypot-def70.4%
fma-def70.4%
fma-udef70.4%
+-commutative70.4%
hypot-def82.3%
Applied egg-rr82.3%
Taylor expanded in c around inf 44.5%
associate-/l*45.8%
Simplified45.8%
Taylor expanded in c around inf 76.7%
Final simplification79.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.1e+92) (not (<= d 8e+44))) (/ b d) (* (/ 1.0 c) (+ a (/ b (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.1e+92) || !(d <= 8e+44)) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + (b / (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 ((d <= (-2.1d+92)) .or. (.not. (d <= 8d+44))) then
tmp = b / d
else
tmp = (1.0d0 / c) * (a + (b / (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.1e+92) || !(d <= 8e+44)) {
tmp = b / d;
} else {
tmp = (1.0 / c) * (a + (b / (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.1e+92) or not (d <= 8e+44): tmp = b / d else: tmp = (1.0 / c) * (a + (b / (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.1e+92) || !(d <= 8e+44)) tmp = Float64(b / d); else tmp = Float64(Float64(1.0 / c) * Float64(a + Float64(b / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.1e+92) || ~((d <= 8e+44))) tmp = b / d; else tmp = (1.0 / c) * (a + (b / (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.1e+92], N[Not[LessEqual[d, 8e+44]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.1 \cdot 10^{+92} \lor \neg \left(d \leq 8 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if d < -2.09999999999999986e92 or 8.0000000000000007e44 < d Initial program 42.0%
Taylor expanded in c around 0 71.7%
if -2.09999999999999986e92 < d < 8.0000000000000007e44Initial program 70.4%
*-un-lft-identity70.4%
+-commutative70.4%
fma-udef70.5%
add-sqr-sqrt70.5%
times-frac70.4%
fma-udef70.4%
+-commutative70.4%
hypot-def70.4%
fma-def70.4%
fma-udef70.4%
+-commutative70.4%
hypot-def82.3%
Applied egg-rr82.3%
Taylor expanded in c around inf 44.5%
associate-/l*45.8%
Simplified45.8%
Taylor expanded in c around inf 76.7%
Final simplification74.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5e+91) (not (<= d 1.15e+43))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5e+91) || !(d <= 1.15e+43)) {
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 <= (-5d+91)) .or. (.not. (d <= 1.15d+43))) 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 <= -5e+91) || !(d <= 1.15e+43)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5e+91) or not (d <= 1.15e+43): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5e+91) || !(d <= 1.15e+43)) 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 <= -5e+91) || ~((d <= 1.15e+43))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5e+91], N[Not[LessEqual[d, 1.15e+43]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5 \cdot 10^{+91} \lor \neg \left(d \leq 1.15 \cdot 10^{+43}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -5.0000000000000002e91 or 1.1500000000000001e43 < d Initial program 42.0%
Taylor expanded in c around 0 71.7%
if -5.0000000000000002e91 < d < 1.1500000000000001e43Initial program 70.4%
Taylor expanded in c around inf 61.7%
Final simplification65.9%
(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 58.2%
Taylor expanded in c around inf 44.3%
Final simplification44.3%
(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 2024010
(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))))