
(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 13 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))))
(if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(* (/ d (hypot c d)) (/ b (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (d / hypot(c, d)) * (b / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= Double.POSITIVE_INFINITY) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (d / Math.hypot(c, d)) * (b / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= math.inf: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (d / math.hypot(c, d)) * (b / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= Inf) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (d / hypot(c, d)) * (b / hypot(c, 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]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], 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[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
\mathbf{if}\;\frac{t\_0}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t\_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, 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 78.1%
*-un-lft-identity78.1%
associate-*r/78.1%
fma-define78.1%
add-sqr-sqrt78.1%
times-frac78.0%
fma-define78.0%
hypot-define78.1%
fma-define78.0%
fma-define78.0%
hypot-define96.3%
Applied egg-rr96.3%
fma-define96.3%
+-commutative96.3%
Applied egg-rr96.3%
if +inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in a around 0 1.3%
*-commutative1.3%
add-sqr-sqrt1.3%
hypot-undefine1.3%
hypot-undefine1.3%
times-frac54.7%
Applied egg-rr54.7%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -9.5e+151)
(* (/ d (hypot c d)) (/ b (hypot c d)))
(if (<= d -6e-49)
t_0
(if (<= d 7.2e-139)
(+ (/ a c) (* (/ 1.0 c) (/ (* b d) c)))
(if (<= d 2.4e+92)
t_0
(* (/ 1.0 (hypot c d)) (+ b (* a (/ 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 (d <= -9.5e+151) {
tmp = (d / hypot(c, d)) * (b / hypot(c, d));
} else if (d <= -6e-49) {
tmp = t_0;
} else if (d <= 7.2e-139) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.4e+92) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (b + (a * (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 (d <= -9.5e+151) {
tmp = (d / Math.hypot(c, d)) * (b / Math.hypot(c, d));
} else if (d <= -6e-49) {
tmp = t_0;
} else if (d <= 7.2e-139) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.4e+92) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b + (a * (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -9.5e+151: tmp = (d / math.hypot(c, d)) * (b / math.hypot(c, d)) elif d <= -6e-49: tmp = t_0 elif d <= 7.2e-139: tmp = (a / c) + ((1.0 / c) * ((b * d) / c)) elif d <= 2.4e+92: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * (b + (a * (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 (d <= -9.5e+151) tmp = Float64(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d))); elseif (d <= -6e-49) tmp = t_0; elseif (d <= 7.2e-139) tmp = Float64(Float64(a / c) + Float64(Float64(1.0 / c) * Float64(Float64(b * d) / c))); elseif (d <= 2.4e+92) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(a * 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 (d <= -9.5e+151) tmp = (d / hypot(c, d)) * (b / hypot(c, d)); elseif (d <= -6e-49) tmp = t_0; elseif (d <= 7.2e-139) tmp = (a / c) + ((1.0 / c) * ((b * d) / c)); elseif (d <= 2.4e+92) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * (b + (a * (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[d, -9.5e+151], N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6e-49], t$95$0, If[LessEqual[d, 7.2e-139], N[(N[(a / c), $MachinePrecision] + N[(N[(1.0 / c), $MachinePrecision] * N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.4e+92], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(a * 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}\;d \leq -9.5 \cdot 10^{+151}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -6 \cdot 10^{-49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 7.2 \cdot 10^{-139}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \frac{b \cdot d}{c}\\
\mathbf{elif}\;d \leq 2.4 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\end{array}
\end{array}
if d < -9.5000000000000001e151Initial program 32.0%
Taylor expanded in a around 0 32.4%
*-commutative32.4%
add-sqr-sqrt32.4%
hypot-undefine32.4%
hypot-undefine32.4%
times-frac83.0%
Applied egg-rr83.0%
if -9.5000000000000001e151 < d < -6e-49 or 7.20000000000000007e-139 < d < 2.40000000000000005e92Initial program 82.7%
if -6e-49 < d < 7.20000000000000007e-139Initial program 73.0%
Taylor expanded in c around inf 81.5%
*-un-lft-identity81.5%
pow281.5%
times-frac91.9%
Applied egg-rr91.9%
if 2.40000000000000005e92 < d Initial program 39.5%
*-un-lft-identity39.5%
associate-*r/39.5%
fma-define39.5%
add-sqr-sqrt39.5%
times-frac39.5%
fma-define39.5%
hypot-define39.5%
fma-define39.5%
fma-define39.5%
hypot-define62.5%
Applied egg-rr62.5%
Taylor expanded in c around 0 88.4%
associate-/l*91.9%
Simplified91.9%
Final simplification88.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -3.6e+80)
(fma c (* (/ 1.0 d) (/ a d)) (/ b d))
(if (<= d -5.7e-49)
t_0
(if (<= d 1.4e-140)
(+ (/ a c) (* (/ 1.0 c) (/ (* b d) c)))
(if (<= d 1.7e+92)
t_0
(* (/ 1.0 (hypot c d)) (+ b (* a (/ 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 (d <= -3.6e+80) {
tmp = fma(c, ((1.0 / d) * (a / d)), (b / d));
} else if (d <= -5.7e-49) {
tmp = t_0;
} else if (d <= 1.4e-140) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 1.7e+92) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * (b + (a * (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 (d <= -3.6e+80) tmp = fma(c, Float64(Float64(1.0 / d) * Float64(a / d)), Float64(b / d)); elseif (d <= -5.7e-49) tmp = t_0; elseif (d <= 1.4e-140) tmp = Float64(Float64(a / c) + Float64(Float64(1.0 / c) * Float64(Float64(b * d) / c))); elseif (d <= 1.7e+92) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(a * Float64(c / 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[d, -3.6e+80], N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision] + N[(b / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.7e-49], t$95$0, If[LessEqual[d, 1.4e-140], N[(N[(a / c), $MachinePrecision] + N[(N[(1.0 / c), $MachinePrecision] * N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e+92], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(a * 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}\;d \leq -3.6 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(c, \frac{1}{d} \cdot \frac{a}{d}, \frac{b}{d}\right)\\
\mathbf{elif}\;d \leq -5.7 \cdot 10^{-49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.4 \cdot 10^{-140}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \frac{b \cdot d}{c}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + a \cdot \frac{c}{d}\right)\\
\end{array}
\end{array}
if d < -3.59999999999999995e80Initial program 45.5%
Taylor expanded in c around 0 66.7%
+-commutative66.7%
*-commutative66.7%
associate-/l*71.8%
fma-define71.8%
Simplified71.8%
*-un-lft-identity71.8%
pow271.8%
times-frac78.3%
Applied egg-rr78.3%
if -3.59999999999999995e80 < d < -5.7000000000000003e-49 or 1.4000000000000001e-140 < d < 1.6999999999999999e92Initial program 81.6%
if -5.7000000000000003e-49 < d < 1.4000000000000001e-140Initial program 73.0%
Taylor expanded in c around inf 81.5%
*-un-lft-identity81.5%
pow281.5%
times-frac91.9%
Applied egg-rr91.9%
if 1.6999999999999999e92 < d Initial program 39.5%
*-un-lft-identity39.5%
associate-*r/39.5%
fma-define39.5%
add-sqr-sqrt39.5%
times-frac39.5%
fma-define39.5%
hypot-define39.5%
fma-define39.5%
fma-define39.5%
hypot-define62.5%
Applied egg-rr62.5%
Taylor expanded in c around 0 88.4%
associate-/l*91.9%
Simplified91.9%
Final simplification87.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ b (* a (/ c d)))))
(if (<= d -7.2e+82)
(* t_1 (/ -1.0 (hypot c d)))
(if (<= d -6.2e-49)
t_0
(if (<= d 4.6e-138)
(+ (/ a c) (* (/ 1.0 c) (/ (* b d) c)))
(if (<= d 2.15e+92) t_0 (* (/ 1.0 (hypot c d)) 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 + (a * (c / d));
double tmp;
if (d <= -7.2e+82) {
tmp = t_1 * (-1.0 / hypot(c, d));
} else if (d <= -6.2e-49) {
tmp = t_0;
} else if (d <= 4.6e-138) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.15e+92) {
tmp = t_0;
} else {
tmp = (1.0 / hypot(c, d)) * 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 + (a * (c / d));
double tmp;
if (d <= -7.2e+82) {
tmp = t_1 * (-1.0 / Math.hypot(c, d));
} else if (d <= -6.2e-49) {
tmp = t_0;
} else if (d <= 4.6e-138) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.15e+92) {
tmp = t_0;
} else {
tmp = (1.0 / Math.hypot(c, d)) * t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = b + (a * (c / d)) tmp = 0 if d <= -7.2e+82: tmp = t_1 * (-1.0 / math.hypot(c, d)) elif d <= -6.2e-49: tmp = t_0 elif d <= 4.6e-138: tmp = (a / c) + ((1.0 / c) * ((b * d) / c)) elif d <= 2.15e+92: tmp = t_0 else: tmp = (1.0 / math.hypot(c, d)) * 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(b + Float64(a * Float64(c / d))) tmp = 0.0 if (d <= -7.2e+82) tmp = Float64(t_1 * Float64(-1.0 / hypot(c, d))); elseif (d <= -6.2e-49) tmp = t_0; elseif (d <= 4.6e-138) tmp = Float64(Float64(a / c) + Float64(Float64(1.0 / c) * Float64(Float64(b * d) / c))); elseif (d <= 2.15e+92) tmp = t_0; else tmp = Float64(Float64(1.0 / hypot(c, d)) * 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 + (a * (c / d)); tmp = 0.0; if (d <= -7.2e+82) tmp = t_1 * (-1.0 / hypot(c, d)); elseif (d <= -6.2e-49) tmp = t_0; elseif (d <= 4.6e-138) tmp = (a / c) + ((1.0 / c) * ((b * d) / c)); elseif (d <= 2.15e+92) tmp = t_0; else tmp = (1.0 / hypot(c, d)) * 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[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.2e+82], N[(t$95$1 * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.2e-49], t$95$0, If[LessEqual[d, 4.6e-138], N[(N[(a / c), $MachinePrecision] + N[(N[(1.0 / c), $MachinePrecision] * N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.15e+92], t$95$0, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $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 := b + a \cdot \frac{c}{d}\\
\mathbf{if}\;d \leq -7.2 \cdot 10^{+82}:\\
\;\;\;\;t\_1 \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -6.2 \cdot 10^{-49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{-138}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \frac{b \cdot d}{c}\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t\_1\\
\end{array}
\end{array}
if d < -7.20000000000000028e82Initial program 45.5%
*-un-lft-identity45.5%
associate-*r/45.5%
fma-define45.5%
add-sqr-sqrt45.5%
times-frac45.5%
fma-define45.5%
hypot-define45.5%
fma-define45.5%
fma-define45.5%
hypot-define63.7%
Applied egg-rr63.7%
Taylor expanded in d around -inf 73.6%
distribute-lft-out73.6%
associate-/l*83.1%
Simplified83.1%
if -7.20000000000000028e82 < d < -6.2e-49 or 4.5999999999999998e-138 < d < 2.1499999999999999e92Initial program 81.6%
if -6.2e-49 < d < 4.5999999999999998e-138Initial program 73.0%
Taylor expanded in c around inf 81.5%
*-un-lft-identity81.5%
pow281.5%
times-frac91.9%
Applied egg-rr91.9%
if 2.1499999999999999e92 < d Initial program 39.5%
*-un-lft-identity39.5%
associate-*r/39.5%
fma-define39.5%
add-sqr-sqrt39.5%
times-frac39.5%
fma-define39.5%
hypot-define39.5%
fma-define39.5%
fma-define39.5%
hypot-define62.5%
Applied egg-rr62.5%
Taylor expanded in c around 0 88.4%
associate-/l*91.9%
Simplified91.9%
Final simplification87.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (fma c (* (/ 1.0 d) (/ a d)) (/ b d))))
(if (<= d -3.8e+84)
t_1
(if (<= d -6.4e-49)
t_0
(if (<= d 3.8e-139)
(+ (/ a c) (* (/ 1.0 c) (/ (* b d) c)))
(if (<= d 2.15e+92) 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 = fma(c, ((1.0 / d) * (a / d)), (b / d));
double tmp;
if (d <= -3.8e+84) {
tmp = t_1;
} else if (d <= -6.4e-49) {
tmp = t_0;
} else if (d <= 3.8e-139) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.15e+92) {
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 = fma(c, Float64(Float64(1.0 / d) * Float64(a / d)), Float64(b / d)) tmp = 0.0 if (d <= -3.8e+84) tmp = t_1; elseif (d <= -6.4e-49) tmp = t_0; elseif (d <= 3.8e-139) tmp = Float64(Float64(a / c) + Float64(Float64(1.0 / c) * Float64(Float64(b * d) / c))); elseif (d <= 2.15e+92) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(c * N[(N[(1.0 / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision] + N[(b / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.8e+84], t$95$1, If[LessEqual[d, -6.4e-49], t$95$0, If[LessEqual[d, 3.8e-139], N[(N[(a / c), $MachinePrecision] + N[(N[(1.0 / c), $MachinePrecision] * N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.15e+92], 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 := \mathsf{fma}\left(c, \frac{1}{d} \cdot \frac{a}{d}, \frac{b}{d}\right)\\
\mathbf{if}\;d \leq -3.8 \cdot 10^{+84}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -6.4 \cdot 10^{-49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-139}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \frac{b \cdot d}{c}\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -3.8000000000000001e84 or 2.1499999999999999e92 < d Initial program 42.2%
Taylor expanded in c around 0 72.8%
+-commutative72.8%
*-commutative72.8%
associate-/l*77.4%
fma-define77.4%
Simplified77.4%
*-un-lft-identity77.4%
pow277.4%
times-frac84.2%
Applied egg-rr84.2%
if -3.8000000000000001e84 < d < -6.40000000000000005e-49 or 3.80000000000000008e-139 < d < 2.1499999999999999e92Initial program 81.6%
if -6.40000000000000005e-49 < d < 3.80000000000000008e-139Initial program 73.0%
Taylor expanded in c around inf 81.5%
*-un-lft-identity81.5%
pow281.5%
times-frac91.9%
Applied egg-rr91.9%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (fma c (/ (/ a d) d) (/ b d))))
(if (<= d -4.4e+79)
t_1
(if (<= d -1.75e-48)
t_0
(if (<= d 3.7e-138)
(+ (/ a c) (* (/ 1.0 c) (/ (* b d) c)))
(if (<= d 2.12e+92) 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 = fma(c, ((a / d) / d), (b / d));
double tmp;
if (d <= -4.4e+79) {
tmp = t_1;
} else if (d <= -1.75e-48) {
tmp = t_0;
} else if (d <= 3.7e-138) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.12e+92) {
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 = fma(c, Float64(Float64(a / d) / d), Float64(b / d)) tmp = 0.0 if (d <= -4.4e+79) tmp = t_1; elseif (d <= -1.75e-48) tmp = t_0; elseif (d <= 3.7e-138) tmp = Float64(Float64(a / c) + Float64(Float64(1.0 / c) * Float64(Float64(b * d) / c))); elseif (d <= 2.12e+92) tmp = t_0; else tmp = t_1; 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]}, Block[{t$95$1 = N[(c * N[(N[(a / d), $MachinePrecision] / d), $MachinePrecision] + N[(b / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.4e+79], t$95$1, If[LessEqual[d, -1.75e-48], t$95$0, If[LessEqual[d, 3.7e-138], N[(N[(a / c), $MachinePrecision] + N[(N[(1.0 / c), $MachinePrecision] * N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.12e+92], 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 := \mathsf{fma}\left(c, \frac{\frac{a}{d}}{d}, \frac{b}{d}\right)\\
\mathbf{if}\;d \leq -4.4 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.75 \cdot 10^{-48}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 3.7 \cdot 10^{-138}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \frac{b \cdot d}{c}\\
\mathbf{elif}\;d \leq 2.12 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -4.3999999999999998e79 or 2.11999999999999999e92 < d Initial program 42.2%
Taylor expanded in c around 0 72.8%
+-commutative72.8%
*-commutative72.8%
associate-/l*77.4%
fma-define77.4%
Simplified77.4%
*-un-lft-identity77.4%
pow277.4%
times-frac84.2%
Applied egg-rr84.2%
associate-*l/84.2%
*-un-lft-identity84.2%
Applied egg-rr84.2%
if -4.3999999999999998e79 < d < -1.74999999999999996e-48 or 3.69999999999999991e-138 < d < 2.11999999999999999e92Initial program 81.6%
if -1.74999999999999996e-48 < d < 3.69999999999999991e-138Initial program 73.0%
Taylor expanded in c around inf 81.5%
*-un-lft-identity81.5%
pow281.5%
times-frac91.9%
Applied egg-rr91.9%
Final simplification86.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -1.32e+154)
(* b (/ -1.0 (hypot c d)))
(if (<= d -1.9e-48)
t_0
(if (<= d 2.6e-138)
(+ (/ a c) (* (/ 1.0 c) (/ (* b d) c)))
(if (<= d 2.45e+92) t_0 (/ b 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 (d <= -1.32e+154) {
tmp = b * (-1.0 / hypot(c, d));
} else if (d <= -1.9e-48) {
tmp = t_0;
} else if (d <= 2.6e-138) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.45e+92) {
tmp = t_0;
} else {
tmp = b / 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 (d <= -1.32e+154) {
tmp = b * (-1.0 / Math.hypot(c, d));
} else if (d <= -1.9e-48) {
tmp = t_0;
} else if (d <= 2.6e-138) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.45e+92) {
tmp = t_0;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.32e+154: tmp = b * (-1.0 / math.hypot(c, d)) elif d <= -1.9e-48: tmp = t_0 elif d <= 2.6e-138: tmp = (a / c) + ((1.0 / c) * ((b * d) / c)) elif d <= 2.45e+92: tmp = t_0 else: tmp = b / 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 (d <= -1.32e+154) tmp = Float64(b * Float64(-1.0 / hypot(c, d))); elseif (d <= -1.9e-48) tmp = t_0; elseif (d <= 2.6e-138) tmp = Float64(Float64(a / c) + Float64(Float64(1.0 / c) * Float64(Float64(b * d) / c))); elseif (d <= 2.45e+92) tmp = t_0; else tmp = Float64(b / 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 (d <= -1.32e+154) tmp = b * (-1.0 / hypot(c, d)); elseif (d <= -1.9e-48) tmp = t_0; elseif (d <= 2.6e-138) tmp = (a / c) + ((1.0 / c) * ((b * d) / c)); elseif (d <= 2.45e+92) tmp = t_0; else tmp = b / 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[d, -1.32e+154], N[(b * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.9e-48], t$95$0, If[LessEqual[d, 2.6e-138], N[(N[(a / c), $MachinePrecision] + N[(N[(1.0 / c), $MachinePrecision] * N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.45e+92], t$95$0, N[(b / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.32 \cdot 10^{+154}:\\
\;\;\;\;b \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.9 \cdot 10^{-48}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.6 \cdot 10^{-138}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \frac{b \cdot d}{c}\\
\mathbf{elif}\;d \leq 2.45 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -1.31999999999999998e154Initial program 32.0%
*-un-lft-identity32.0%
associate-*r/32.0%
fma-define32.0%
add-sqr-sqrt32.0%
times-frac32.0%
fma-define32.0%
hypot-define32.0%
fma-define32.0%
fma-define32.0%
hypot-define55.7%
Applied egg-rr55.7%
Taylor expanded in d around -inf 68.2%
mul-1-neg68.2%
Simplified68.2%
if -1.31999999999999998e154 < d < -1.90000000000000001e-48 or 2.6e-138 < d < 2.4500000000000001e92Initial program 82.7%
if -1.90000000000000001e-48 < d < 2.6e-138Initial program 73.0%
Taylor expanded in c around inf 81.5%
*-un-lft-identity81.5%
pow281.5%
times-frac91.9%
Applied egg-rr91.9%
if 2.4500000000000001e92 < d Initial program 39.5%
Taylor expanded in c around 0 78.2%
Final simplification83.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= d -2.6e+153)
(/ b d)
(if (<= d -5.7e-49)
t_0
(if (<= d 5.5e-137)
(+ (/ a c) (* (/ 1.0 c) (/ (* b d) c)))
(if (<= d 2.55e+92) t_0 (/ b 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 (d <= -2.6e+153) {
tmp = b / d;
} else if (d <= -5.7e-49) {
tmp = t_0;
} else if (d <= 5.5e-137) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.55e+92) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d))
if (d <= (-2.6d+153)) then
tmp = b / d
else if (d <= (-5.7d-49)) then
tmp = t_0
else if (d <= 5.5d-137) then
tmp = (a / c) + ((1.0d0 / c) * ((b * d) / c))
else if (d <= 2.55d+92) then
tmp = t_0
else
tmp = b / d
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 tmp;
if (d <= -2.6e+153) {
tmp = b / d;
} else if (d <= -5.7e-49) {
tmp = t_0;
} else if (d <= 5.5e-137) {
tmp = (a / c) + ((1.0 / c) * ((b * d) / c));
} else if (d <= 2.55e+92) {
tmp = t_0;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if d <= -2.6e+153: tmp = b / d elif d <= -5.7e-49: tmp = t_0 elif d <= 5.5e-137: tmp = (a / c) + ((1.0 / c) * ((b * d) / c)) elif d <= 2.55e+92: tmp = t_0 else: tmp = b / 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 (d <= -2.6e+153) tmp = Float64(b / d); elseif (d <= -5.7e-49) tmp = t_0; elseif (d <= 5.5e-137) tmp = Float64(Float64(a / c) + Float64(Float64(1.0 / c) * Float64(Float64(b * d) / c))); elseif (d <= 2.55e+92) tmp = t_0; else tmp = Float64(b / 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 (d <= -2.6e+153) tmp = b / d; elseif (d <= -5.7e-49) tmp = t_0; elseif (d <= 5.5e-137) tmp = (a / c) + ((1.0 / c) * ((b * d) / c)); elseif (d <= 2.55e+92) tmp = t_0; else tmp = b / 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[d, -2.6e+153], N[(b / d), $MachinePrecision], If[LessEqual[d, -5.7e-49], t$95$0, If[LessEqual[d, 5.5e-137], N[(N[(a / c), $MachinePrecision] + N[(N[(1.0 / c), $MachinePrecision] * N[(N[(b * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.55e+92], t$95$0, N[(b / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq -5.7 \cdot 10^{-49}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-137}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{c} \cdot \frac{b \cdot d}{c}\\
\mathbf{elif}\;d \leq 2.55 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -2.5999999999999999e153 or 2.5500000000000001e92 < d Initial program 36.6%
Taylor expanded in c around 0 73.5%
if -2.5999999999999999e153 < d < -5.7000000000000003e-49 or 5.5000000000000003e-137 < d < 2.5500000000000001e92Initial program 82.7%
if -5.7000000000000003e-49 < d < 5.5000000000000003e-137Initial program 73.0%
Taylor expanded in c around inf 81.5%
*-un-lft-identity81.5%
pow281.5%
times-frac91.9%
Applied egg-rr91.9%
Final simplification83.1%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.5e+85)
(/ b d)
(if (<= d 135.0)
(+ (/ a c) (/ (/ d (/ c b)) c))
(if (<= d 3.2e+51)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 3.1e+92) (+ (/ a c) (* (/ d c) (/ b c))) (/ b d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.5e+85) {
tmp = b / d;
} else if (d <= 135.0) {
tmp = (a / c) + ((d / (c / b)) / c);
} else if (d <= 3.2e+51) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 3.1e+92) {
tmp = (a / c) + ((d / c) * (b / 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 <= (-1.5d+85)) then
tmp = b / d
else if (d <= 135.0d0) then
tmp = (a / c) + ((d / (c / b)) / c)
else if (d <= 3.2d+51) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 3.1d+92) then
tmp = (a / c) + ((d / c) * (b / 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 <= -1.5e+85) {
tmp = b / d;
} else if (d <= 135.0) {
tmp = (a / c) + ((d / (c / b)) / c);
} else if (d <= 3.2e+51) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 3.1e+92) {
tmp = (a / c) + ((d / c) * (b / c));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.5e+85: tmp = b / d elif d <= 135.0: tmp = (a / c) + ((d / (c / b)) / c) elif d <= 3.2e+51: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 3.1e+92: tmp = (a / c) + ((d / c) * (b / c)) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.5e+85) tmp = Float64(b / d); elseif (d <= 135.0) tmp = Float64(Float64(a / c) + Float64(Float64(d / Float64(c / b)) / c)); elseif (d <= 3.2e+51) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 3.1e+92) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.5e+85) tmp = b / d; elseif (d <= 135.0) tmp = (a / c) + ((d / (c / b)) / c); elseif (d <= 3.2e+51) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 3.1e+92) tmp = (a / c) + ((d / c) * (b / c)); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.5e+85], N[(b / d), $MachinePrecision], If[LessEqual[d, 135.0], N[(N[(a / c), $MachinePrecision] + N[(N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.2e+51], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.1e+92], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.5 \cdot 10^{+85}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 135:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\mathbf{elif}\;d \leq 3.2 \cdot 10^{+51}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 3.1 \cdot 10^{+92}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -1.5e85 or 3.1000000000000002e92 < d Initial program 43.1%
Taylor expanded in c around 0 73.3%
if -1.5e85 < d < 135Initial program 75.4%
Taylor expanded in c around inf 74.7%
*-commutative74.7%
pow274.7%
times-frac81.7%
Applied egg-rr81.7%
associate-*l/82.4%
clear-num82.4%
un-div-inv82.5%
Applied egg-rr82.5%
if 135 < d < 3.2000000000000002e51Initial program 92.8%
Taylor expanded in a around 0 61.2%
if 3.2000000000000002e51 < d < 3.1000000000000002e92Initial program 35.2%
Taylor expanded in c around inf 48.8%
*-commutative48.8%
pow248.8%
times-frac81.5%
Applied egg-rr81.5%
Final simplification77.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.8e+85) (not (<= d 1350.0))) (/ b d) (+ (/ a c) (* (/ d c) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.8e+85) || !(d <= 1350.0)) {
tmp = b / d;
} else {
tmp = (a / c) + ((d / c) * (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.8d+85)) .or. (.not. (d <= 1350.0d0))) then
tmp = b / d
else
tmp = (a / c) + ((d / c) * (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.8e+85) || !(d <= 1350.0)) {
tmp = b / d;
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.8e+85) or not (d <= 1350.0): tmp = b / d else: tmp = (a / c) + ((d / c) * (b / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.8e+85) || !(d <= 1350.0)) tmp = Float64(b / d); else tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.8e+85) || ~((d <= 1350.0))) tmp = b / d; else tmp = (a / c) + ((d / c) * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.8e+85], N[Not[LessEqual[d, 1350.0]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{+85} \lor \neg \left(d \leq 1350\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if d < -4.79999999999999993e85 or 1350 < d Initial program 49.2%
Taylor expanded in c around 0 68.2%
if -4.79999999999999993e85 < d < 1350Initial program 75.4%
Taylor expanded in c around inf 74.7%
*-commutative74.7%
pow274.7%
times-frac81.7%
Applied egg-rr81.7%
Final simplification75.7%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7.5e+84) (not (<= d 65000.0))) (/ b d) (+ (/ a c) (/ (/ d (/ c b)) c))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.5e+84) || !(d <= 65000.0)) {
tmp = b / d;
} else {
tmp = (a / c) + ((d / (c / 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 <= (-7.5d+84)) .or. (.not. (d <= 65000.0d0))) then
tmp = b / d
else
tmp = (a / c) + ((d / (c / b)) / c)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7.5e+84) || !(d <= 65000.0)) {
tmp = b / d;
} else {
tmp = (a / c) + ((d / (c / b)) / c);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7.5e+84) or not (d <= 65000.0): tmp = b / d else: tmp = (a / c) + ((d / (c / b)) / c) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7.5e+84) || !(d <= 65000.0)) tmp = Float64(b / d); else tmp = Float64(Float64(a / c) + Float64(Float64(d / Float64(c / b)) / c)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7.5e+84) || ~((d <= 65000.0))) tmp = b / d; else tmp = (a / c) + ((d / (c / b)) / c); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7.5e+84], N[Not[LessEqual[d, 65000.0]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / N[(c / b), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7.5 \cdot 10^{+84} \lor \neg \left(d \leq 65000\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{\frac{d}{\frac{c}{b}}}{c}\\
\end{array}
\end{array}
if d < -7.5000000000000001e84 or 65000 < d Initial program 49.2%
Taylor expanded in c around 0 68.2%
if -7.5000000000000001e84 < d < 65000Initial program 75.4%
Taylor expanded in c around inf 74.7%
*-commutative74.7%
pow274.7%
times-frac81.7%
Applied egg-rr81.7%
associate-*l/82.4%
clear-num82.4%
un-div-inv82.5%
Applied egg-rr82.5%
Final simplification76.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8e+84) (not (<= d 0.108))) (/ b d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8e+84) || !(d <= 0.108)) {
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 <= (-8d+84)) .or. (.not. (d <= 0.108d0))) 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 <= -8e+84) || !(d <= 0.108)) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8e+84) or not (d <= 0.108): tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8e+84) || !(d <= 0.108)) 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 <= -8e+84) || ~((d <= 0.108))) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8e+84], N[Not[LessEqual[d, 0.108]], $MachinePrecision]], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8 \cdot 10^{+84} \lor \neg \left(d \leq 0.108\right):\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -8.00000000000000046e84 or 0.107999999999999999 < d Initial program 49.2%
Taylor expanded in c around 0 68.2%
if -8.00000000000000046e84 < d < 0.107999999999999999Initial program 75.4%
Taylor expanded in c around inf 68.1%
Final simplification68.1%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 63.8%
Taylor expanded in c around inf 46.0%
Final simplification46.0%
(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 2024041
(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))))