
(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 14 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 2e+300)
(/ (/ (fma b d (* a c)) (hypot c d)) (hypot c d))
(if (<= t_0 INFINITY)
(+ (/ b d) (/ a (* d (/ d c))))
(* (/ -1.0 c) (- (/ (- b) (/ c d)) a))))))
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 <= 2e+300) {
tmp = (fma(b, d, (a * c)) / hypot(c, d)) / hypot(c, d);
} else if (t_0 <= ((double) INFINITY)) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (-1.0 / c) * ((-b / (c / d)) - a);
}
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 <= 2e+300) tmp = Float64(Float64(fma(b, d, Float64(a * c)) / hypot(c, d)) / hypot(c, d)); elseif (t_0 <= Inf) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); else tmp = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(-b) / Float64(c / d)) - a)); 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, 2e+300], 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], If[LessEqual[t$95$0, Infinity], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $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 2 \cdot 10^{+300}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, d, a \cdot c\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{-b}{\frac{c}{d}} - a\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.0000000000000001e300Initial program 84.3%
add-sqr-sqrt84.3%
*-un-lft-identity84.3%
times-frac84.3%
hypot-def84.3%
fma-def84.3%
hypot-def98.6%
Applied egg-rr98.6%
fma-def98.6%
*-commutative98.6%
associate-*l/98.7%
div-inv98.8%
+-commutative98.8%
fma-def98.8%
Applied egg-rr98.8%
if 2.0000000000000001e300 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 32.5%
Taylor expanded in c around 0 58.5%
associate-/l*63.6%
Simplified63.6%
pow263.6%
*-un-lft-identity63.6%
times-frac81.4%
Applied egg-rr81.4%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
add-sqr-sqrt0.0%
*-un-lft-identity0.0%
times-frac0.0%
hypot-def0.0%
fma-def0.0%
hypot-def2.6%
Applied egg-rr2.6%
Taylor expanded in c around -inf 34.5%
neg-mul-134.5%
+-commutative34.5%
unsub-neg34.5%
mul-1-neg34.5%
associate-/l*40.4%
distribute-neg-frac40.4%
Simplified40.4%
Taylor expanded in c around -inf 66.2%
Final simplification91.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (fma b d (* a c)) (pow (hypot c d) -2.0))))
(if (<= c -2.35e+80)
(/ (- (fma d (/ b c) a)) (hypot c d))
(if (<= c -8.6e-138)
t_0
(if (<= c 5.5e-153)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 1.76e+81)
t_0
(* (/ 1.0 (hypot c d)) (+ a (/ b (/ c d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma(b, d, (a * c)) * pow(hypot(c, d), -2.0);
double tmp;
if (c <= -2.35e+80) {
tmp = -fma(d, (b / c), a) / hypot(c, d);
} else if (c <= -8.6e-138) {
tmp = t_0;
} else if (c <= 5.5e-153) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 1.76e+81) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (a + (b / (c / d)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(fma(b, d, Float64(a * c)) * (hypot(c, d) ^ -2.0)) tmp = 0.0 if (c <= -2.35e+80) tmp = Float64(Float64(-fma(d, Float64(b / c), a)) / hypot(c, d)); elseif (c <= -8.6e-138) tmp = t_0; elseif (c <= 5.5e-153) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 1.76e+81) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(b / Float64(c / d)))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * d + N[(a * c), $MachinePrecision]), $MachinePrecision] * N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -2.35e+80], N[((-N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision]) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8.6e-138], t$95$0, If[LessEqual[c, 5.5e-153], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.76e+81], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(b, d, a \cdot c\right) \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\
\mathbf{if}\;c \leq -2.35 \cdot 10^{+80}:\\
\;\;\;\;\frac{-\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -8.6 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 5.5 \cdot 10^{-153}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 1.76 \cdot 10^{+81}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if c < -2.35000000000000005e80Initial program 34.8%
add-sqr-sqrt34.8%
*-un-lft-identity34.8%
times-frac34.8%
hypot-def34.8%
fma-def34.8%
hypot-def45.0%
Applied egg-rr45.0%
fma-def44.9%
*-commutative44.9%
associate-*l/44.9%
div-inv45.0%
+-commutative45.0%
fma-def45.1%
Applied egg-rr45.1%
Taylor expanded in c around -inf 84.9%
distribute-lft-out84.9%
associate-*r/90.3%
+-commutative90.3%
fma-udef90.3%
neg-mul-190.3%
fma-udef90.3%
associate-*r/84.9%
associate-*l/90.3%
*-commutative90.3%
fma-def90.3%
Simplified90.3%
if -2.35000000000000005e80 < c < -8.6000000000000001e-138 or 5.49999999999999962e-153 < c < 1.76000000000000002e81Initial program 86.4%
add-sqr-sqrt86.4%
*-un-lft-identity86.4%
times-frac86.3%
hypot-def86.3%
fma-def86.3%
hypot-def93.8%
Applied egg-rr93.8%
fma-def93.8%
frac-times86.4%
*-un-lft-identity86.4%
unpow286.4%
expm1-log1p-u63.0%
expm1-udef35.2%
Applied egg-rr35.2%
expm1-def63.0%
expm1-log1p86.4%
*-lft-identity86.4%
unpow286.4%
times-frac93.8%
associate-*r/93.9%
*-rgt-identity93.9%
times-frac87.3%
*-rgt-identity87.3%
associate-*r/87.0%
unpow-187.0%
unpow-187.0%
pow-sqr87.4%
metadata-eval87.4%
/-rgt-identity87.4%
*-commutative87.4%
*-commutative87.4%
Simplified87.4%
if -8.6000000000000001e-138 < c < 5.49999999999999962e-153Initial program 65.3%
Taylor expanded in c around 0 77.7%
associate-/l*80.6%
Simplified80.6%
pow280.6%
*-un-lft-identity80.6%
times-frac89.6%
Applied egg-rr89.6%
if 1.76000000000000002e81 < c Initial program 40.1%
add-sqr-sqrt40.1%
*-un-lft-identity40.1%
times-frac40.0%
hypot-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
Taylor expanded in c around inf 75.8%
associate-/l*87.8%
Simplified87.8%
Final simplification88.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))))
(if (<= c -1.72e+78)
(/ (- (fma d (/ b c) a)) (hypot c d))
(if (<= c -8.2e-138)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 8.5e-150)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 1.6e+80)
(/ t_0 (fma c c (* d d)))
(* (/ 1.0 (hypot c d)) (+ a (/ b (/ c d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if (c <= -1.72e+78) {
tmp = -fma(d, (b / c), a) / hypot(c, d);
} else if (c <= -8.2e-138) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 8.5e-150) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 1.6e+80) {
tmp = t_0 / fma(c, c, (d * d));
} else {
tmp = (1.0 / hypot(c, d)) * (a + (b / (c / d)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) tmp = 0.0 if (c <= -1.72e+78) tmp = Float64(Float64(-fma(d, Float64(b / c), a)) / hypot(c, d)); elseif (c <= -8.2e-138) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 8.5e-150) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 1.6e+80) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(b / Float64(c / d)))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.72e+78], N[((-N[(d * N[(b / c), $MachinePrecision] + a), $MachinePrecision]) / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8.2e-138], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 8.5e-150], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.6e+80], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
\mathbf{if}\;c \leq -1.72 \cdot 10^{+78}:\\
\;\;\;\;\frac{-\mathsf{fma}\left(d, \frac{b}{c}, a\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-138}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 8.5 \cdot 10^{-150}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 1.6 \cdot 10^{+80}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if c < -1.71999999999999997e78Initial program 36.4%
add-sqr-sqrt36.4%
*-un-lft-identity36.4%
times-frac36.4%
hypot-def36.4%
fma-def36.4%
hypot-def46.4%
Applied egg-rr46.4%
fma-def46.3%
*-commutative46.3%
associate-*l/46.3%
div-inv46.4%
+-commutative46.4%
fma-def46.5%
Applied egg-rr46.5%
Taylor expanded in c around -inf 85.3%
distribute-lft-out85.3%
associate-*r/90.5%
+-commutative90.5%
fma-udef90.5%
neg-mul-190.5%
fma-udef90.5%
associate-*r/85.3%
associate-*l/90.5%
*-commutative90.5%
fma-def90.5%
Simplified90.5%
if -1.71999999999999997e78 < c < -8.19999999999999998e-138Initial program 90.0%
if -8.19999999999999998e-138 < c < 8.4999999999999997e-150Initial program 65.7%
Taylor expanded in c around 0 78.0%
associate-/l*80.9%
Simplified80.9%
pow280.9%
*-un-lft-identity80.9%
times-frac89.8%
Applied egg-rr89.8%
if 8.4999999999999997e-150 < c < 1.59999999999999995e80Initial program 82.4%
fma-def82.4%
fma-def82.4%
Simplified82.4%
fma-def82.4%
+-commutative82.4%
Applied egg-rr82.4%
if 1.59999999999999995e80 < c Initial program 40.1%
add-sqr-sqrt40.1%
*-un-lft-identity40.1%
times-frac40.0%
hypot-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
Taylor expanded in c around inf 75.8%
associate-/l*87.8%
Simplified87.8%
Final simplification88.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))))
(if (<= c -6.4e+78)
(/ (- (/ (- b) (/ c d)) a) (hypot c d))
(if (<= c -8.2e-138)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 5.2e-151)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 2.7e+80)
(/ t_0 (fma c c (* d d)))
(* (/ 1.0 (hypot c d)) (+ a (/ b (/ c d))))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if (c <= -6.4e+78) {
tmp = ((-b / (c / d)) - a) / hypot(c, d);
} else if (c <= -8.2e-138) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 5.2e-151) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 2.7e+80) {
tmp = t_0 / fma(c, c, (d * d));
} else {
tmp = (1.0 / hypot(c, d)) * (a + (b / (c / d)));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) tmp = 0.0 if (c <= -6.4e+78) tmp = Float64(Float64(Float64(Float64(-b) / Float64(c / d)) - a) / hypot(c, d)); elseif (c <= -8.2e-138) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 5.2e-151) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 2.7e+80) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(b / Float64(c / d)))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -6.4e+78], N[(N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8.2e-138], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.2e-151], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.7e+80], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(b / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
\mathbf{if}\;c \leq -6.4 \cdot 10^{+78}:\\
\;\;\;\;\frac{\frac{-b}{\frac{c}{d}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-138}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{-151}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 2.7 \cdot 10^{+80}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if c < -6.39999999999999989e78Initial program 36.4%
add-sqr-sqrt36.4%
*-un-lft-identity36.4%
times-frac36.4%
hypot-def36.4%
fma-def36.4%
hypot-def46.4%
Applied egg-rr46.4%
fma-def46.3%
*-commutative46.3%
associate-*l/46.3%
div-inv46.4%
+-commutative46.4%
fma-def46.5%
Applied egg-rr46.5%
Taylor expanded in c around -inf 85.3%
add-sqr-sqrt34.9%
sqrt-unprod43.6%
mul-1-neg43.6%
mul-1-neg43.6%
sqr-neg43.6%
sqrt-unprod23.1%
add-sqr-sqrt18.0%
sqrt-unprod20.8%
mul-1-neg20.8%
mul-1-neg20.8%
sqr-neg20.8%
sqrt-unprod10.7%
add-sqr-sqrt16.1%
add-sqr-sqrt22.5%
*-un-lft-identity22.5%
metadata-eval22.5%
distribute-lft-neg-in22.5%
distribute-lft-out22.5%
Applied egg-rr90.5%
if -6.39999999999999989e78 < c < -8.19999999999999998e-138Initial program 90.0%
if -8.19999999999999998e-138 < c < 5.2000000000000001e-151Initial program 65.7%
Taylor expanded in c around 0 78.0%
associate-/l*80.9%
Simplified80.9%
pow280.9%
*-un-lft-identity80.9%
times-frac89.8%
Applied egg-rr89.8%
if 5.2000000000000001e-151 < c < 2.69999999999999983e80Initial program 82.4%
fma-def82.4%
fma-def82.4%
Simplified82.4%
fma-def82.4%
+-commutative82.4%
Applied egg-rr82.4%
if 2.69999999999999983e80 < c Initial program 40.1%
add-sqr-sqrt40.1%
*-un-lft-identity40.1%
times-frac40.0%
hypot-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
Taylor expanded in c around inf 75.8%
associate-/l*87.8%
Simplified87.8%
Final simplification88.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -2.2e+79)
(/ (- (/ (- b) (/ c d)) a) (hypot c d))
(if (<= c -9.5e-138)
t_0
(if (<= c 1.25e-148)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 4e+80) t_0 (* (/ 1.0 (hypot c d)) (+ a (/ b (/ c 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 (c <= -2.2e+79) {
tmp = ((-b / (c / d)) - a) / hypot(c, d);
} else if (c <= -9.5e-138) {
tmp = t_0;
} else if (c <= 1.25e-148) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 4e+80) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (a + (b / (c / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (c <= -2.2e+79) {
tmp = ((-b / (c / d)) - a) / Math.hypot(c, d);
} else if (c <= -9.5e-138) {
tmp = t_0;
} else if (c <= 1.25e-148) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 4e+80) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (a + (b / (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -2.2e+79: tmp = ((-b / (c / d)) - a) / math.hypot(c, d) elif c <= -9.5e-138: tmp = t_0 elif c <= 1.25e-148: tmp = (b / d) + (a / (d * (d / c))) elif c <= 4e+80: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (a + (b / (c / 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 (c <= -2.2e+79) tmp = Float64(Float64(Float64(Float64(-b) / Float64(c / d)) - a) / hypot(c, d)); elseif (c <= -9.5e-138) tmp = t_0; elseif (c <= 1.25e-148) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 4e+80) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a + Float64(b / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -2.2e+79) tmp = ((-b / (c / d)) - a) / hypot(c, d); elseif (c <= -9.5e-138) tmp = t_0; elseif (c <= 1.25e-148) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 4e+80) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (a + (b / (c / d))); end tmp_2 = 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[c, -2.2e+79], N[(N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -9.5e-138], t$95$0, If[LessEqual[c, 1.25e-148], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4e+80], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a + N[(b / N[(c / 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}\;c \leq -2.2 \cdot 10^{+79}:\\
\;\;\;\;\frac{\frac{-b}{\frac{c}{d}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -9.5 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{-148}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 4 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a + \frac{b}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if c < -2.1999999999999999e79Initial program 36.4%
add-sqr-sqrt36.4%
*-un-lft-identity36.4%
times-frac36.4%
hypot-def36.4%
fma-def36.4%
hypot-def46.4%
Applied egg-rr46.4%
fma-def46.3%
*-commutative46.3%
associate-*l/46.3%
div-inv46.4%
+-commutative46.4%
fma-def46.5%
Applied egg-rr46.5%
Taylor expanded in c around -inf 85.3%
add-sqr-sqrt34.9%
sqrt-unprod43.6%
mul-1-neg43.6%
mul-1-neg43.6%
sqr-neg43.6%
sqrt-unprod23.1%
add-sqr-sqrt18.0%
sqrt-unprod20.8%
mul-1-neg20.8%
mul-1-neg20.8%
sqr-neg20.8%
sqrt-unprod10.7%
add-sqr-sqrt16.1%
add-sqr-sqrt22.5%
*-un-lft-identity22.5%
metadata-eval22.5%
distribute-lft-neg-in22.5%
distribute-lft-out22.5%
Applied egg-rr90.5%
if -2.1999999999999999e79 < c < -9.49999999999999997e-138 or 1.25e-148 < c < 4e80Initial program 86.1%
if -9.49999999999999997e-138 < c < 1.25e-148Initial program 65.7%
Taylor expanded in c around 0 78.0%
associate-/l*80.9%
Simplified80.9%
pow280.9%
*-un-lft-identity80.9%
times-frac89.8%
Applied egg-rr89.8%
if 4e80 < c Initial program 40.1%
add-sqr-sqrt40.1%
*-un-lft-identity40.1%
times-frac40.0%
hypot-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
Taylor expanded in c around inf 75.8%
associate-/l*87.8%
Simplified87.8%
Final simplification88.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (- (/ (- b) (/ c d)) a)))
(if (<= c -1.95e+78)
(/ t_1 (hypot c d))
(if (<= c -8.2e-138)
t_0
(if (<= c 1.7e-149)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 3.1e+80) t_0 (* (/ -1.0 c) t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (-b / (c / d)) - a;
double tmp;
if (c <= -1.95e+78) {
tmp = t_1 / hypot(c, d);
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 1.7e-149) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 3.1e+80) {
tmp = t_0;
} else {
tmp = (-1.0 / c) * t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (-b / (c / d)) - a;
double tmp;
if (c <= -1.95e+78) {
tmp = t_1 / Math.hypot(c, d);
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 1.7e-149) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 3.1e+80) {
tmp = t_0;
} else {
tmp = (-1.0 / c) * t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (-b / (c / d)) - a tmp = 0 if c <= -1.95e+78: tmp = t_1 / math.hypot(c, d) elif c <= -8.2e-138: tmp = t_0 elif c <= 1.7e-149: tmp = (b / d) + (a / (d * (d / c))) elif c <= 3.1e+80: tmp = t_0 else: tmp = (-1.0 / c) * t_1 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))) t_1 = Float64(Float64(Float64(-b) / Float64(c / d)) - a) tmp = 0.0 if (c <= -1.95e+78) tmp = Float64(t_1 / hypot(c, d)); elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 1.7e-149) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 3.1e+80) tmp = t_0; else tmp = Float64(Float64(-1.0 / c) * t_1); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = (-b / (c / d)) - a; tmp = 0.0; if (c <= -1.95e+78) tmp = t_1 / hypot(c, d); elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 1.7e-149) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 3.1e+80) tmp = t_0; else tmp = (-1.0 / c) * t_1; end tmp_2 = 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]}, Block[{t$95$1 = N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]}, If[LessEqual[c, -1.95e+78], N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -8.2e-138], t$95$0, If[LessEqual[c, 1.7e-149], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3.1e+80], t$95$0, N[(N[(-1.0 / c), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{-b}{\frac{c}{d}} - a\\
\mathbf{if}\;c \leq -1.95 \cdot 10^{+78}:\\
\;\;\;\;\frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.7 \cdot 10^{-149}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 3.1 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{c} \cdot t_1\\
\end{array}
\end{array}
if c < -1.9500000000000002e78Initial program 36.4%
add-sqr-sqrt36.4%
*-un-lft-identity36.4%
times-frac36.4%
hypot-def36.4%
fma-def36.4%
hypot-def46.4%
Applied egg-rr46.4%
fma-def46.3%
*-commutative46.3%
associate-*l/46.3%
div-inv46.4%
+-commutative46.4%
fma-def46.5%
Applied egg-rr46.5%
Taylor expanded in c around -inf 85.3%
add-sqr-sqrt34.9%
sqrt-unprod43.6%
mul-1-neg43.6%
mul-1-neg43.6%
sqr-neg43.6%
sqrt-unprod23.1%
add-sqr-sqrt18.0%
sqrt-unprod20.8%
mul-1-neg20.8%
mul-1-neg20.8%
sqr-neg20.8%
sqrt-unprod10.7%
add-sqr-sqrt16.1%
add-sqr-sqrt22.5%
*-un-lft-identity22.5%
metadata-eval22.5%
distribute-lft-neg-in22.5%
distribute-lft-out22.5%
Applied egg-rr90.5%
if -1.9500000000000002e78 < c < -8.19999999999999998e-138 or 1.6999999999999999e-149 < c < 3.09999999999999988e80Initial program 86.1%
if -8.19999999999999998e-138 < c < 1.6999999999999999e-149Initial program 65.7%
Taylor expanded in c around 0 78.0%
associate-/l*80.9%
Simplified80.9%
pow280.9%
*-un-lft-identity80.9%
times-frac89.8%
Applied egg-rr89.8%
if 3.09999999999999988e80 < c Initial program 40.1%
add-sqr-sqrt40.1%
*-un-lft-identity40.1%
times-frac40.0%
hypot-def40.0%
fma-def40.0%
hypot-def59.4%
Applied egg-rr59.4%
Taylor expanded in c around -inf 23.0%
neg-mul-123.0%
+-commutative23.0%
unsub-neg23.0%
mul-1-neg23.0%
associate-/l*23.3%
distribute-neg-frac23.3%
Simplified23.3%
Taylor expanded in c around -inf 86.0%
Final simplification87.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (* (/ -1.0 c) (- (/ (- b) (/ c d)) a))))
(if (<= c -1.8e+79)
t_1
(if (<= c -8.2e-138)
t_0
(if (<= c 9.6e-151)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 4.3e+80) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (-1.0 / c) * ((-b / (c / d)) - a);
double tmp;
if (c <= -1.8e+79) {
tmp = t_1;
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 9.6e-151) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 4.3e+80) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
t_1 = ((-1.0d0) / c) * ((-b / (c / d)) - a)
if (c <= (-1.8d+79)) then
tmp = t_1
else if (c <= (-8.2d-138)) then
tmp = t_0
else if (c <= 9.6d-151) then
tmp = (b / d) + (a / (d * (d / c)))
else if (c <= 4.3d+80) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double t_1 = (-1.0 / c) * ((-b / (c / d)) - a);
double tmp;
if (c <= -1.8e+79) {
tmp = t_1;
} else if (c <= -8.2e-138) {
tmp = t_0;
} else if (c <= 9.6e-151) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 4.3e+80) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (-1.0 / c) * ((-b / (c / d)) - a) tmp = 0 if c <= -1.8e+79: tmp = t_1 elif c <= -8.2e-138: tmp = t_0 elif c <= 9.6e-151: tmp = (b / d) + (a / (d * (d / c))) elif c <= 4.3e+80: tmp = t_0 else: tmp = t_1 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))) t_1 = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(-b) / Float64(c / d)) - a)) tmp = 0.0 if (c <= -1.8e+79) tmp = t_1; elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 9.6e-151) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 4.3e+80) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)); t_1 = (-1.0 / c) * ((-b / (c / d)) - a); tmp = 0.0; if (c <= -1.8e+79) tmp = t_1; elseif (c <= -8.2e-138) tmp = t_0; elseif (c <= 9.6e-151) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 4.3e+80) tmp = t_0; else tmp = t_1; end tmp_2 = 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]}, Block[{t$95$1 = N[(N[(-1.0 / c), $MachinePrecision] * N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.8e+79], t$95$1, If[LessEqual[c, -8.2e-138], t$95$0, If[LessEqual[c, 9.6e-151], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 4.3e+80], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{-1}{c} \cdot \left(\frac{-b}{\frac{c}{d}} - a\right)\\
\mathbf{if}\;c \leq -1.8 \cdot 10^{+79}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -8.2 \cdot 10^{-138}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 9.6 \cdot 10^{-151}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 4.3 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -1.8e79 or 4.30000000000000004e80 < c Initial program 38.3%
add-sqr-sqrt38.3%
*-un-lft-identity38.3%
times-frac38.2%
hypot-def38.2%
fma-def38.2%
hypot-def53.0%
Applied egg-rr53.0%
Taylor expanded in c around -inf 53.6%
neg-mul-153.6%
+-commutative53.6%
unsub-neg53.6%
mul-1-neg53.6%
associate-/l*56.4%
distribute-neg-frac56.4%
Simplified56.4%
Taylor expanded in c around -inf 87.0%
if -1.8e79 < c < -8.19999999999999998e-138 or 9.6e-151 < c < 4.30000000000000004e80Initial program 86.1%
if -8.19999999999999998e-138 < c < 9.6e-151Initial program 65.7%
Taylor expanded in c around 0 78.0%
associate-/l*80.9%
Simplified80.9%
pow280.9%
*-un-lft-identity80.9%
times-frac89.8%
Applied egg-rr89.8%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(if (<= c -1.9e+50)
(/ a c)
(if (<= c 7.2e-79)
(/ b d)
(if (<= c 2.6e+80) (/ (* a c) (+ (* c c) (* d d))) (/ a c)))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.9e+50) {
tmp = a / c;
} else if (c <= 7.2e-79) {
tmp = b / d;
} else if (c <= 2.6e+80) {
tmp = (a * c) / ((c * c) + (d * 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 (c <= (-1.9d+50)) then
tmp = a / c
else if (c <= 7.2d-79) then
tmp = b / d
else if (c <= 2.6d+80) then
tmp = (a * c) / ((c * c) + (d * 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 (c <= -1.9e+50) {
tmp = a / c;
} else if (c <= 7.2e-79) {
tmp = b / d;
} else if (c <= 2.6e+80) {
tmp = (a * c) / ((c * c) + (d * d));
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.9e+50: tmp = a / c elif c <= 7.2e-79: tmp = b / d elif c <= 2.6e+80: tmp = (a * c) / ((c * c) + (d * d)) else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.9e+50) tmp = Float64(a / c); elseif (c <= 7.2e-79) tmp = Float64(b / d); elseif (c <= 2.6e+80) tmp = Float64(Float64(a * c) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -1.9e+50) tmp = a / c; elseif (c <= 7.2e-79) tmp = b / d; elseif (c <= 2.6e+80) tmp = (a * c) / ((c * c) + (d * d)); else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.9e+50], N[(a / c), $MachinePrecision], If[LessEqual[c, 7.2e-79], N[(b / d), $MachinePrecision], If[LessEqual[c, 2.6e+80], N[(N[(a * c), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / c), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.9 \cdot 10^{+50}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{-79}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{+80}:\\
\;\;\;\;\frac{a \cdot c}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -1.89999999999999994e50 or 2.59999999999999982e80 < c Initial program 43.8%
Taylor expanded in c around inf 78.7%
if -1.89999999999999994e50 < c < 7.2000000000000005e-79Initial program 75.2%
Taylor expanded in c around 0 66.6%
if 7.2000000000000005e-79 < c < 2.59999999999999982e80Initial program 80.1%
Taylor expanded in a around inf 61.6%
*-commutative61.6%
Simplified61.6%
Final simplification70.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7.5e-15) (not (<= d 1.1e+66))) (/ b d) (* (/ -1.0 c) (- (/ (- b) (/ c d)) a))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.5e-15) || !(d <= 1.1e+66)) {
tmp = b / d;
} else {
tmp = (-1.0 / c) * ((-b / (c / d)) - a);
}
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 <= (-7.5d-15)) .or. (.not. (d <= 1.1d+66))) then
tmp = b / d
else
tmp = ((-1.0d0) / c) * ((-b / (c / d)) - a)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.5e-15) || !(d <= 1.1e+66)) {
tmp = b / d;
} else {
tmp = (-1.0 / c) * ((-b / (c / d)) - a);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.5e-15) or not (d <= 1.1e+66): tmp = b / d else: tmp = (-1.0 / c) * ((-b / (c / d)) - a) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.5e-15) || !(d <= 1.1e+66)) tmp = Float64(b / d); else tmp = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(-b) / Float64(c / d)) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.5e-15) || ~((d <= 1.1e+66))) tmp = b / d; else tmp = (-1.0 / c) * ((-b / (c / d)) - a); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.5e-15], N[Not[LessEqual[d, 1.1e+66]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \cdot 10^{-15} \lor \neg \left(d \leq 1.1 \cdot 10^{+66}\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{-b}{\frac{c}{d}} - a\right)\\
\end{array}
\end{array}
if d < -7.4999999999999996e-15 or 1.0999999999999999e66 < d Initial program 55.9%
Taylor expanded in c around 0 71.1%
if -7.4999999999999996e-15 < d < 1.0999999999999999e66Initial program 72.3%
add-sqr-sqrt72.3%
*-un-lft-identity72.3%
times-frac72.2%
hypot-def72.3%
fma-def72.3%
hypot-def83.2%
Applied egg-rr83.2%
Taylor expanded in c around -inf 48.4%
neg-mul-148.4%
+-commutative48.4%
unsub-neg48.4%
mul-1-neg48.4%
associate-/l*48.8%
distribute-neg-frac48.8%
Simplified48.8%
Taylor expanded in c around -inf 79.8%
Final simplification75.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.8e-15) (not (<= d 2.7e-40))) (+ (/ b d) (/ a (* d (/ d c)))) (* (/ -1.0 c) (- (/ (- b) (/ c d)) a))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.8e-15) || !(d <= 2.7e-40)) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (-1.0 / c) * ((-b / (c / d)) - a);
}
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.8d-15)) .or. (.not. (d <= 2.7d-40))) then
tmp = (b / d) + (a / (d * (d / c)))
else
tmp = ((-1.0d0) / c) * ((-b / (c / d)) - a)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.8e-15) || !(d <= 2.7e-40)) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (-1.0 / c) * ((-b / (c / d)) - a);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.8e-15) or not (d <= 2.7e-40): tmp = (b / d) + (a / (d * (d / c))) else: tmp = (-1.0 / c) * ((-b / (c / d)) - a) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.8e-15) || !(d <= 2.7e-40)) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); else tmp = Float64(Float64(-1.0 / c) * Float64(Float64(Float64(-b) / Float64(c / d)) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.8e-15) || ~((d <= 2.7e-40))) tmp = (b / d) + (a / (d * (d / c))); else tmp = (-1.0 / c) * ((-b / (c / d)) - a); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.8e-15], N[Not[LessEqual[d, 2.7e-40]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[((-b) / N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.8 \cdot 10^{-15} \lor \neg \left(d \leq 2.7 \cdot 10^{-40}\right):\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{-b}{\frac{c}{d}} - a\right)\\
\end{array}
\end{array}
if d < -1.8000000000000001e-15 or 2.7e-40 < d Initial program 59.8%
Taylor expanded in c around 0 72.3%
associate-/l*73.2%
Simplified73.2%
pow273.2%
*-un-lft-identity73.2%
times-frac74.0%
Applied egg-rr74.0%
if -1.8000000000000001e-15 < d < 2.7e-40Initial program 71.0%
add-sqr-sqrt70.9%
*-un-lft-identity70.9%
times-frac70.8%
hypot-def70.9%
fma-def70.9%
hypot-def82.3%
Applied egg-rr82.3%
Taylor expanded in c around -inf 50.5%
neg-mul-150.5%
+-commutative50.5%
unsub-neg50.5%
mul-1-neg50.5%
associate-/l*50.9%
distribute-neg-frac50.9%
Simplified50.9%
Taylor expanded in c around -inf 85.6%
Final simplification79.3%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.6e+78)
(/ b d)
(if (<= d -3.6e-153)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 6.5e-34) (/ a c) (/ b d)))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.6e+78) {
tmp = b / d;
} else if (d <= -3.6e-153) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 6.5e-34) {
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 (d <= (-4.6d+78)) then
tmp = b / d
else if (d <= (-3.6d-153)) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 6.5d-34) 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 (d <= -4.6e+78) {
tmp = b / d;
} else if (d <= -3.6e-153) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 6.5e-34) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -4.6e+78: tmp = b / d elif d <= -3.6e-153: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 6.5e-34: tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -4.6e+78) tmp = Float64(b / d); elseif (d <= -3.6e-153) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 6.5e-34) 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 (d <= -4.6e+78) tmp = b / d; elseif (d <= -3.6e-153) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 6.5e-34) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.6e+78], N[(b / d), $MachinePrecision], If[LessEqual[d, -3.6e-153], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.5e-34], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.6 \cdot 10^{+78}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -3.6 \cdot 10^{-153}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 6.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -4.6000000000000004e78 or 6.49999999999999985e-34 < d Initial program 55.4%
Taylor expanded in c around 0 70.5%
if -4.6000000000000004e78 < d < -3.5999999999999998e-153Initial program 89.2%
Taylor expanded in a around 0 60.3%
if -3.5999999999999998e-153 < d < 6.49999999999999985e-34Initial program 65.3%
Taylor expanded in c around inf 73.9%
Final simplification69.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -3.7e+49) (not (<= c 6.4e+79))) (/ a c) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -3.7e+49) || !(c <= 6.4e+79)) {
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 <= (-3.7d+49)) .or. (.not. (c <= 6.4d+79))) 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 <= -3.7e+49) || !(c <= 6.4e+79)) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -3.7e+49) or not (c <= 6.4e+79): tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -3.7e+49) || !(c <= 6.4e+79)) 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 <= -3.7e+49) || ~((c <= 6.4e+79))) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -3.7e+49], N[Not[LessEqual[c, 6.4e+79]], $MachinePrecision]], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.7 \cdot 10^{+49} \lor \neg \left(c \leq 6.4 \cdot 10^{+79}\right):\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -3.70000000000000018e49 or 6.40000000000000005e79 < c Initial program 43.8%
Taylor expanded in c around inf 78.7%
if -3.70000000000000018e49 < c < 6.40000000000000005e79Initial program 76.2%
Taylor expanded in c around 0 62.7%
Final simplification68.2%
(FPCore (a b c d) :precision binary64 (if (<= d 4.5e+178) (/ a c) (/ a d)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= 4.5e+178) {
tmp = a / c;
} else {
tmp = a / 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 <= 4.5d+178) then
tmp = a / c
else
tmp = a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= 4.5e+178) {
tmp = a / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= 4.5e+178: tmp = a / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= 4.5e+178) tmp = Float64(a / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= 4.5e+178) tmp = a / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, 4.5e+178], N[(a / c), $MachinePrecision], N[(a / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq 4.5 \cdot 10^{+178}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < 4.4999999999999997e178Initial program 66.3%
Taylor expanded in c around inf 45.7%
if 4.4999999999999997e178 < d Initial program 51.4%
add-sqr-sqrt51.4%
*-un-lft-identity51.4%
times-frac51.4%
hypot-def51.4%
fma-def51.4%
hypot-def67.5%
Applied egg-rr67.5%
Taylor expanded in c around -inf 7.3%
neg-mul-17.3%
+-commutative7.3%
unsub-neg7.3%
mul-1-neg7.3%
associate-/l*6.9%
distribute-neg-frac6.9%
Simplified6.9%
Taylor expanded in d around -inf 7.9%
+-commutative7.9%
Simplified7.9%
Taylor expanded in b around 0 44.0%
Final simplification45.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 64.9%
Taylor expanded in c around inf 42.4%
Final simplification42.4%
(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 2024019
(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))))