
(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))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 1e+251)
(/ (* (/ 1.0 (hypot c d)) t_0) (hypot c d))
(if (<= t_1 INFINITY)
(+ (/ b d) (/ a (* d (/ d c))))
(+ (/ a c) (/ 1.0 (* (/ c d) (/ c b))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 1e+251) {
tmp = ((1.0 / hypot(c, d)) * t_0) / hypot(c, d);
} else if (t_1 <= ((double) INFINITY)) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (a / c) + (1.0 / ((c / d) * (c / b)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 1e+251) {
tmp = ((1.0 / Math.hypot(c, d)) * t_0) / Math.hypot(c, d);
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (a / c) + (1.0 / ((c / d) * (c / b)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= 1e+251: tmp = ((1.0 / math.hypot(c, d)) * t_0) / math.hypot(c, d) elif t_1 <= math.inf: tmp = (b / d) + (a / (d * (d / c))) else: tmp = (a / c) + (1.0 / ((c / d) * (c / b))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_1 <= 1e+251) tmp = Float64(Float64(Float64(1.0 / hypot(c, d)) * t_0) / hypot(c, d)); elseif (t_1 <= Inf) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); else tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(Float64(c / d) * Float64(c / b)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= 1e+251) tmp = ((1.0 / hypot(c, d)) * t_0) / hypot(c, d); elseif (t_1 <= Inf) tmp = (b / d) + (a / (d * (d / c))); else tmp = (a / c) + (1.0 / ((c / d) * (c / b))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+251], N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(N[(c / d), $MachinePrecision] * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq 10^{+251}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{d} \cdot \frac{c}{b}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1e251Initial program 75.7%
*-un-lft-identity75.7%
add-sqr-sqrt75.7%
times-frac75.7%
hypot-def75.7%
fma-def75.7%
hypot-def94.1%
Applied egg-rr94.1%
associate-*r/94.2%
Applied egg-rr94.2%
fma-def94.2%
+-commutative94.2%
Applied egg-rr94.2%
if 1e251 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 33.2%
*-un-lft-identity33.2%
add-sqr-sqrt33.2%
times-frac33.2%
hypot-def33.2%
fma-def33.2%
hypot-def43.9%
Applied egg-rr43.9%
associate-*r/43.9%
Applied egg-rr43.9%
Taylor expanded in c around 0 54.4%
associate-/l*71.4%
unpow271.4%
*-lft-identity71.4%
times-frac83.5%
/-rgt-identity83.5%
Simplified83.5%
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 c around inf 50.0%
unpow250.0%
Simplified50.0%
clear-num50.0%
inv-pow50.0%
Applied egg-rr50.0%
unpow-150.0%
*-commutative50.0%
times-frac66.3%
Simplified66.3%
Final simplification88.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 1e+251)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(if (<= t_1 INFINITY)
(+ (/ b d) (/ a (* d (/ d c))))
(+ (/ a c) (/ 1.0 (* (/ c d) (/ c b))))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 1e+251) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (a / c) + (1.0 / ((c / d) * (c / b)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= 1e+251) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (b / d) + (a / (d * (d / c)));
} else {
tmp = (a / c) + (1.0 / ((c / d) * (c / b)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= 1e+251: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) elif t_1 <= math.inf: tmp = (b / d) + (a / (d * (d / c))) else: tmp = (a / c) + (1.0 / ((c / d) * (c / b))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_1 <= 1e+251) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); elseif (t_1 <= Inf) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); else tmp = Float64(Float64(a / c) + Float64(1.0 / Float64(Float64(c / d) * Float64(c / b)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= 1e+251) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); elseif (t_1 <= Inf) tmp = (b / d) + (a / (d * (d / c))); else tmp = (a / c) + (1.0 / ((c / d) * (c / b))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+251], 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], If[LessEqual[t$95$1, Infinity], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(1.0 / N[(N[(c / d), $MachinePrecision] * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq 10^{+251}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;t_1 \leq \infty:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{1}{\frac{c}{d} \cdot \frac{c}{b}}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1e251Initial program 75.7%
*-un-lft-identity75.7%
add-sqr-sqrt75.7%
times-frac75.7%
hypot-def75.7%
fma-def75.7%
hypot-def94.1%
Applied egg-rr94.1%
fma-def94.2%
+-commutative94.2%
Applied egg-rr94.1%
if 1e251 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 33.2%
*-un-lft-identity33.2%
add-sqr-sqrt33.2%
times-frac33.2%
hypot-def33.2%
fma-def33.2%
hypot-def43.9%
Applied egg-rr43.9%
associate-*r/43.9%
Applied egg-rr43.9%
Taylor expanded in c around 0 54.4%
associate-/l*71.4%
unpow271.4%
*-lft-identity71.4%
times-frac83.5%
/-rgt-identity83.5%
Simplified83.5%
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 c around inf 50.0%
unpow250.0%
Simplified50.0%
clear-num50.0%
inv-pow50.0%
Applied egg-rr50.0%
unpow-150.0%
*-commutative50.0%
times-frac66.3%
Simplified66.3%
Final simplification88.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -3.5e+131)
(/ (- (* b (- (/ d c))) a) (hypot c d))
(if (<= c -2e-167)
t_0
(if (<= c 3.2e-175)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 5.8e+26)
t_0
(if (<= c 2.3e+91)
(* (/ d (hypot c d)) (/ b (hypot c d)))
(+ (/ a c) (* (/ d c) (/ (/ 1.0 c) (/ 1.0 b)))))))))))
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 <= -3.5e+131) {
tmp = ((b * -(d / c)) - a) / hypot(c, d);
} else if (c <= -2e-167) {
tmp = t_0;
} else if (c <= 3.2e-175) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 5.8e+26) {
tmp = t_0;
} else if (c <= 2.3e+91) {
tmp = (d / hypot(c, d)) * (b / hypot(c, d));
} else {
tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
}
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 <= -3.5e+131) {
tmp = ((b * -(d / c)) - a) / Math.hypot(c, d);
} else if (c <= -2e-167) {
tmp = t_0;
} else if (c <= 3.2e-175) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 5.8e+26) {
tmp = t_0;
} else if (c <= 2.3e+91) {
tmp = (d / Math.hypot(c, d)) * (b / Math.hypot(c, d));
} else {
tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -3.5e+131: tmp = ((b * -(d / c)) - a) / math.hypot(c, d) elif c <= -2e-167: tmp = t_0 elif c <= 3.2e-175: tmp = (b / d) + (a / (d * (d / c))) elif c <= 5.8e+26: tmp = t_0 elif c <= 2.3e+91: tmp = (d / math.hypot(c, d)) * (b / math.hypot(c, d)) else: tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))) 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 <= -3.5e+131) tmp = Float64(Float64(Float64(b * Float64(-Float64(d / c))) - a) / hypot(c, d)); elseif (c <= -2e-167) tmp = t_0; elseif (c <= 3.2e-175) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 5.8e+26) tmp = t_0; elseif (c <= 2.3e+91) tmp = Float64(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d))); else tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(Float64(1.0 / c) / Float64(1.0 / b)))); 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 <= -3.5e+131) tmp = ((b * -(d / c)) - a) / hypot(c, d); elseif (c <= -2e-167) tmp = t_0; elseif (c <= 3.2e-175) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 5.8e+26) tmp = t_0; elseif (c <= 2.3e+91) tmp = (d / hypot(c, d)) * (b / hypot(c, d)); else tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))); 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, -3.5e+131], N[(N[(N[(b * (-N[(d / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2e-167], t$95$0, If[LessEqual[c, 3.2e-175], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.8e+26], t$95$0, If[LessEqual[c, 2.3e+91], N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(1.0 / b), $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 -3.5 \cdot 10^{+131}:\\
\;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 3.2 \cdot 10^{-175}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{+91}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\
\end{array}
\end{array}
if c < -3.4999999999999999e131Initial program 30.9%
*-un-lft-identity30.9%
add-sqr-sqrt30.9%
times-frac30.9%
hypot-def30.9%
fma-def30.9%
hypot-def60.9%
Applied egg-rr60.9%
associate-*r/61.0%
Applied egg-rr61.0%
fma-def61.0%
+-commutative61.0%
Applied egg-rr61.0%
Taylor expanded in c around -inf 89.2%
neg-mul-189.2%
+-commutative89.2%
unsub-neg89.2%
mul-1-neg89.2%
*-commutative89.2%
distribute-neg-frac89.2%
*-commutative89.2%
distribute-lft-neg-in89.2%
associate-*r/94.8%
neg-mul-194.8%
*-commutative94.8%
associate-*l*94.8%
neg-mul-194.8%
distribute-neg-frac94.8%
Simplified94.8%
if -3.4999999999999999e131 < c < -2e-167 or 3.2e-175 < c < 5.8e26Initial program 79.7%
if -2e-167 < c < 3.2e-175Initial program 71.0%
*-un-lft-identity71.0%
add-sqr-sqrt71.0%
times-frac71.2%
hypot-def71.2%
fma-def71.2%
hypot-def89.5%
Applied egg-rr89.5%
associate-*r/89.4%
Applied egg-rr89.4%
Taylor expanded in c around 0 84.6%
associate-/l*86.2%
unpow286.2%
*-lft-identity86.2%
times-frac92.1%
/-rgt-identity92.1%
Simplified92.1%
if 5.8e26 < c < 2.29999999999999991e91Initial program 33.4%
Taylor expanded in a around 0 24.9%
*-commutative24.9%
add-sqr-sqrt24.9%
hypot-udef24.9%
hypot-udef24.9%
times-frac91.5%
Applied egg-rr91.5%
if 2.29999999999999991e91 < c Initial program 37.6%
Taylor expanded in c around inf 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in b around 0 66.6%
unpow266.6%
times-frac79.9%
associate-*l/79.9%
Simplified79.9%
clear-num79.9%
*-un-lft-identity79.9%
*-commutative79.9%
frac-times79.9%
clear-num79.9%
associate-/r*79.9%
clear-num80.0%
div-inv80.0%
div-inv80.0%
times-frac80.0%
Applied egg-rr80.0%
Final simplification85.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.1e+131)
(/ (- (* b (- (/ d c))) a) (hypot c d))
(if (<= c -2e-167)
(/ (fma a c (* b d)) (fma c c (* d d)))
(if (<= c 1e-174)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 1.8e+26)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(if (<= c 1.35e+90)
(* (/ d (hypot c d)) (/ b (hypot c d)))
(+ (/ a c) (* (/ d c) (/ (/ 1.0 c) (/ 1.0 b))))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.1e+131) {
tmp = ((b * -(d / c)) - a) / hypot(c, d);
} else if (c <= -2e-167) {
tmp = fma(a, c, (b * d)) / fma(c, c, (d * d));
} else if (c <= 1e-174) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 1.8e+26) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else if (c <= 1.35e+90) {
tmp = (d / hypot(c, d)) * (b / hypot(c, d));
} else {
tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (c <= -4.1e+131) tmp = Float64(Float64(Float64(b * Float64(-Float64(d / c))) - a) / hypot(c, d)); elseif (c <= -2e-167) tmp = Float64(fma(a, c, Float64(b * d)) / fma(c, c, Float64(d * d))); elseif (c <= 1e-174) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 1.8e+26) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.35e+90) tmp = Float64(Float64(d / hypot(c, d)) * Float64(b / hypot(c, d))); else tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(Float64(1.0 / c) / Float64(1.0 / b)))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.1e+131], N[(N[(N[(b * (-N[(d / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2e-167], N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1e-174], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.8e+26], 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, 1.35e+90], N[(N[(d / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.1 \cdot 10^{+131}:\\
\;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\
\;\;\;\;\frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 10^{-174}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{+26}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\
\end{array}
\end{array}
if c < -4.10000000000000007e131Initial program 30.9%
*-un-lft-identity30.9%
add-sqr-sqrt30.9%
times-frac30.9%
hypot-def30.9%
fma-def30.9%
hypot-def60.9%
Applied egg-rr60.9%
associate-*r/61.0%
Applied egg-rr61.0%
fma-def61.0%
+-commutative61.0%
Applied egg-rr61.0%
Taylor expanded in c around -inf 89.2%
neg-mul-189.2%
+-commutative89.2%
unsub-neg89.2%
mul-1-neg89.2%
*-commutative89.2%
distribute-neg-frac89.2%
*-commutative89.2%
distribute-lft-neg-in89.2%
associate-*r/94.8%
neg-mul-194.8%
*-commutative94.8%
associate-*l*94.8%
neg-mul-194.8%
distribute-neg-frac94.8%
Simplified94.8%
if -4.10000000000000007e131 < c < -2e-167Initial program 81.5%
fma-def81.5%
fma-def81.5%
Simplified81.5%
if -2e-167 < c < 1e-174Initial program 71.0%
*-un-lft-identity71.0%
add-sqr-sqrt71.0%
times-frac71.2%
hypot-def71.2%
fma-def71.2%
hypot-def89.5%
Applied egg-rr89.5%
associate-*r/89.4%
Applied egg-rr89.4%
Taylor expanded in c around 0 84.6%
associate-/l*86.2%
unpow286.2%
*-lft-identity86.2%
times-frac92.1%
/-rgt-identity92.1%
Simplified92.1%
if 1e-174 < c < 1.80000000000000012e26Initial program 76.7%
if 1.80000000000000012e26 < c < 1.35e90Initial program 33.4%
Taylor expanded in a around 0 24.9%
*-commutative24.9%
add-sqr-sqrt24.9%
hypot-udef24.9%
hypot-udef24.9%
times-frac91.5%
Applied egg-rr91.5%
if 1.35e90 < c Initial program 37.6%
Taylor expanded in c around inf 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in b around 0 66.6%
unpow266.6%
times-frac79.9%
associate-*l/79.9%
Simplified79.9%
clear-num79.9%
*-un-lft-identity79.9%
*-commutative79.9%
frac-times79.9%
clear-num79.9%
associate-/r*79.9%
clear-num80.0%
div-inv80.0%
div-inv80.0%
times-frac80.0%
Applied egg-rr80.0%
Final simplification85.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))))
(if (<= c -3.8e+131)
(/ (- (* b (- (/ d c))) a) (hypot c d))
(if (<= c -2e-167)
t_0
(if (<= c 1e-174)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 1.8e+26)
t_0
(if (<= c 4.5e+92)
(+ (/ b d) (* c (/ a (* d d))))
(+ (/ a c) (* (/ d c) (/ (/ 1.0 c) (/ 1.0 b)))))))))))
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 <= -3.8e+131) {
tmp = ((b * -(d / c)) - a) / hypot(c, d);
} else if (c <= -2e-167) {
tmp = t_0;
} else if (c <= 1e-174) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 1.8e+26) {
tmp = t_0;
} else if (c <= 4.5e+92) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
}
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 <= -3.8e+131) {
tmp = ((b * -(d / c)) - a) / Math.hypot(c, d);
} else if (c <= -2e-167) {
tmp = t_0;
} else if (c <= 1e-174) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 1.8e+26) {
tmp = t_0;
} else if (c <= 4.5e+92) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) tmp = 0 if c <= -3.8e+131: tmp = ((b * -(d / c)) - a) / math.hypot(c, d) elif c <= -2e-167: tmp = t_0 elif c <= 1e-174: tmp = (b / d) + (a / (d * (d / c))) elif c <= 1.8e+26: tmp = t_0 elif c <= 4.5e+92: tmp = (b / d) + (c * (a / (d * d))) else: tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))) 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 <= -3.8e+131) tmp = Float64(Float64(Float64(b * Float64(-Float64(d / c))) - a) / hypot(c, d)); elseif (c <= -2e-167) tmp = t_0; elseif (c <= 1e-174) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 1.8e+26) tmp = t_0; elseif (c <= 4.5e+92) tmp = Float64(Float64(b / d) + Float64(c * Float64(a / Float64(d * d)))); else tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(Float64(1.0 / c) / Float64(1.0 / b)))); 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 <= -3.8e+131) tmp = ((b * -(d / c)) - a) / hypot(c, d); elseif (c <= -2e-167) tmp = t_0; elseif (c <= 1e-174) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 1.8e+26) tmp = t_0; elseif (c <= 4.5e+92) tmp = (b / d) + (c * (a / (d * d))); else tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))); 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, -3.8e+131], N[(N[(N[(b * (-N[(d / c), $MachinePrecision])), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, -2e-167], t$95$0, If[LessEqual[c, 1e-174], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.8e+26], t$95$0, If[LessEqual[c, 4.5e+92], N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(1.0 / b), $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 -3.8 \cdot 10^{+131}:\\
\;\;\;\;\frac{b \cdot \left(-\frac{d}{c}\right) - a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 10^{-174}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 4.5 \cdot 10^{+92}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\
\end{array}
\end{array}
if c < -3.8000000000000004e131Initial program 30.9%
*-un-lft-identity30.9%
add-sqr-sqrt30.9%
times-frac30.9%
hypot-def30.9%
fma-def30.9%
hypot-def60.9%
Applied egg-rr60.9%
associate-*r/61.0%
Applied egg-rr61.0%
fma-def61.0%
+-commutative61.0%
Applied egg-rr61.0%
Taylor expanded in c around -inf 89.2%
neg-mul-189.2%
+-commutative89.2%
unsub-neg89.2%
mul-1-neg89.2%
*-commutative89.2%
distribute-neg-frac89.2%
*-commutative89.2%
distribute-lft-neg-in89.2%
associate-*r/94.8%
neg-mul-194.8%
*-commutative94.8%
associate-*l*94.8%
neg-mul-194.8%
distribute-neg-frac94.8%
Simplified94.8%
if -3.8000000000000004e131 < c < -2e-167 or 1e-174 < c < 1.80000000000000012e26Initial program 79.7%
if -2e-167 < c < 1e-174Initial program 71.0%
*-un-lft-identity71.0%
add-sqr-sqrt71.0%
times-frac71.2%
hypot-def71.2%
fma-def71.2%
hypot-def89.5%
Applied egg-rr89.5%
associate-*r/89.4%
Applied egg-rr89.4%
Taylor expanded in c around 0 84.6%
associate-/l*86.2%
unpow286.2%
*-lft-identity86.2%
times-frac92.1%
/-rgt-identity92.1%
Simplified92.1%
if 1.80000000000000012e26 < c < 4.4999999999999999e92Initial program 33.4%
*-un-lft-identity33.4%
add-sqr-sqrt33.3%
times-frac33.4%
hypot-def33.4%
fma-def33.4%
hypot-def51.8%
Applied egg-rr51.8%
Taylor expanded in c around 0 77.0%
*-commutative77.0%
unpow277.0%
associate-*r/77.0%
Simplified77.0%
if 4.4999999999999999e92 < c Initial program 37.6%
Taylor expanded in c around inf 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in b around 0 66.6%
unpow266.6%
times-frac79.9%
associate-*l/79.9%
Simplified79.9%
clear-num79.9%
*-un-lft-identity79.9%
*-commutative79.9%
frac-times79.9%
clear-num79.9%
associate-/r*79.9%
clear-num80.0%
div-inv80.0%
div-inv80.0%
times-frac80.0%
Applied egg-rr80.0%
Final simplification85.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))
(t_1 (+ (/ a c) (* (/ d c) (/ (/ 1.0 c) (/ 1.0 b))))))
(if (<= c -3.5e+131)
t_1
(if (<= c -2e-167)
t_0
(if (<= c 1e-175)
(+ (/ b d) (/ a (* d (/ d c))))
(if (<= c 5.8e+26)
t_0
(if (<= c 1.35e+90) (+ (/ b d) (* c (/ a (* d 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 = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
double tmp;
if (c <= -3.5e+131) {
tmp = t_1;
} else if (c <= -2e-167) {
tmp = t_0;
} else if (c <= 1e-175) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 5.8e+26) {
tmp = t_0;
} else if (c <= 1.35e+90) {
tmp = (b / d) + (c * (a / (d * d)));
} 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 = (a / c) + ((d / c) * ((1.0d0 / c) / (1.0d0 / b)))
if (c <= (-3.5d+131)) then
tmp = t_1
else if (c <= (-2d-167)) then
tmp = t_0
else if (c <= 1d-175) then
tmp = (b / d) + (a / (d * (d / c)))
else if (c <= 5.8d+26) then
tmp = t_0
else if (c <= 1.35d+90) then
tmp = (b / d) + (c * (a / (d * d)))
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 = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
double tmp;
if (c <= -3.5e+131) {
tmp = t_1;
} else if (c <= -2e-167) {
tmp = t_0;
} else if (c <= 1e-175) {
tmp = (b / d) + (a / (d * (d / c)));
} else if (c <= 5.8e+26) {
tmp = t_0;
} else if (c <= 1.35e+90) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d)) t_1 = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))) tmp = 0 if c <= -3.5e+131: tmp = t_1 elif c <= -2e-167: tmp = t_0 elif c <= 1e-175: tmp = (b / d) + (a / (d * (d / c))) elif c <= 5.8e+26: tmp = t_0 elif c <= 1.35e+90: tmp = (b / d) + (c * (a / (d * d))) 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(a / c) + Float64(Float64(d / c) * Float64(Float64(1.0 / c) / Float64(1.0 / b)))) tmp = 0.0 if (c <= -3.5e+131) tmp = t_1; elseif (c <= -2e-167) tmp = t_0; elseif (c <= 1e-175) tmp = Float64(Float64(b / d) + Float64(a / Float64(d * Float64(d / c)))); elseif (c <= 5.8e+26) tmp = t_0; elseif (c <= 1.35e+90) tmp = Float64(Float64(b / d) + Float64(c * Float64(a / Float64(d * d)))); 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 = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))); tmp = 0.0; if (c <= -3.5e+131) tmp = t_1; elseif (c <= -2e-167) tmp = t_0; elseif (c <= 1e-175) tmp = (b / d) + (a / (d * (d / c))); elseif (c <= 5.8e+26) tmp = t_0; elseif (c <= 1.35e+90) tmp = (b / d) + (c * (a / (d * d))); 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[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -3.5e+131], t$95$1, If[LessEqual[c, -2e-167], t$95$0, If[LessEqual[c, 1e-175], N[(N[(b / d), $MachinePrecision] + N[(a / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 5.8e+26], t$95$0, If[LessEqual[c, 1.35e+90], N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\
\mathbf{if}\;c \leq -3.5 \cdot 10^{+131}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -2 \cdot 10^{-167}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 10^{-175}:\\
\;\;\;\;\frac{b}{d} + \frac{a}{d \cdot \frac{d}{c}}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -3.4999999999999999e131 or 1.35e90 < c Initial program 34.4%
Taylor expanded in c around inf 75.3%
unpow275.3%
Simplified75.3%
Taylor expanded in b around 0 75.3%
unpow275.3%
times-frac87.0%
associate-*l/87.0%
Simplified87.0%
clear-num87.0%
*-un-lft-identity87.0%
*-commutative87.0%
frac-times87.0%
clear-num87.0%
associate-/r*86.9%
clear-num87.0%
div-inv87.0%
div-inv87.0%
times-frac87.0%
Applied egg-rr87.0%
if -3.4999999999999999e131 < c < -2e-167 or 1e-175 < c < 5.8e26Initial program 79.7%
if -2e-167 < c < 1e-175Initial program 71.0%
*-un-lft-identity71.0%
add-sqr-sqrt71.0%
times-frac71.2%
hypot-def71.2%
fma-def71.2%
hypot-def89.5%
Applied egg-rr89.5%
associate-*r/89.4%
Applied egg-rr89.4%
Taylor expanded in c around 0 84.6%
associate-/l*86.2%
unpow286.2%
*-lft-identity86.2%
times-frac92.1%
/-rgt-identity92.1%
Simplified92.1%
if 5.8e26 < c < 1.35e90Initial program 33.4%
*-un-lft-identity33.4%
add-sqr-sqrt33.3%
times-frac33.4%
hypot-def33.4%
fma-def33.4%
hypot-def51.8%
Applied egg-rr51.8%
Taylor expanded in c around 0 77.0%
*-commutative77.0%
unpow277.0%
associate-*r/77.0%
Simplified77.0%
Final simplification85.0%
(FPCore (a b c d)
:precision binary64
(if (<= c -6.5e+53)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= c 13000000000.0)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= c 3e+24)
(+ (/ a c) (/ (* b d) (* c c)))
(if (<= c 2.1e+91)
(+ (/ b d) (* c (/ a (* d d))))
(+ (/ a c) (* (/ d c) (/ (/ 1.0 c) (/ 1.0 b)))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.5e+53) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (c <= 13000000000.0) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (c <= 3e+24) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 2.1e+91) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
}
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 <= (-6.5d+53)) then
tmp = (a / c) + ((d / c) * (b / c))
else if (c <= 13000000000.0d0) then
tmp = (b / d) + ((c / d) * (a / d))
else if (c <= 3d+24) then
tmp = (a / c) + ((b * d) / (c * c))
else if (c <= 2.1d+91) then
tmp = (b / d) + (c * (a / (d * d)))
else
tmp = (a / c) + ((d / c) * ((1.0d0 / c) / (1.0d0 / b)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6.5e+53) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (c <= 13000000000.0) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (c <= 3e+24) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 2.1e+91) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -6.5e+53: tmp = (a / c) + ((d / c) * (b / c)) elif c <= 13000000000.0: tmp = (b / d) + ((c / d) * (a / d)) elif c <= 3e+24: tmp = (a / c) + ((b * d) / (c * c)) elif c <= 2.1e+91: tmp = (b / d) + (c * (a / (d * d))) else: tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -6.5e+53) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (c <= 13000000000.0) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (c <= 3e+24) tmp = Float64(Float64(a / c) + Float64(Float64(b * d) / Float64(c * c))); elseif (c <= 2.1e+91) tmp = Float64(Float64(b / d) + Float64(c * Float64(a / Float64(d * d)))); else tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(Float64(1.0 / c) / Float64(1.0 / b)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -6.5e+53) tmp = (a / c) + ((d / c) * (b / c)); elseif (c <= 13000000000.0) tmp = (b / d) + ((c / d) * (a / d)); elseif (c <= 3e+24) tmp = (a / c) + ((b * d) / (c * c)); elseif (c <= 2.1e+91) tmp = (b / d) + (c * (a / (d * d))); else tmp = (a / c) + ((d / c) * ((1.0 / c) / (1.0 / b))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -6.5e+53], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 13000000000.0], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 3e+24], N[(N[(a / c), $MachinePrecision] + N[(N[(b * d), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+91], N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.5 \cdot 10^{+53}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;c \leq 13000000000:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 3 \cdot 10^{+24}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{\frac{1}{c}}{\frac{1}{b}}\\
\end{array}
\end{array}
if c < -6.50000000000000017e53Initial program 45.9%
Taylor expanded in c around inf 82.8%
*-commutative82.8%
unpow282.8%
times-frac88.5%
Simplified88.5%
if -6.50000000000000017e53 < c < 1.3e10Initial program 74.9%
Taylor expanded in c around 0 77.1%
*-commutative77.1%
unpow277.1%
times-frac81.2%
Simplified81.2%
if 1.3e10 < c < 2.99999999999999995e24Initial program 81.8%
Taylor expanded in c around inf 95.5%
unpow295.5%
Simplified95.5%
if 2.99999999999999995e24 < c < 2.10000000000000008e91Initial program 33.4%
*-un-lft-identity33.4%
add-sqr-sqrt33.3%
times-frac33.4%
hypot-def33.4%
fma-def33.4%
hypot-def51.8%
Applied egg-rr51.8%
Taylor expanded in c around 0 77.0%
*-commutative77.0%
unpow277.0%
associate-*r/77.0%
Simplified77.0%
if 2.10000000000000008e91 < c Initial program 37.6%
Taylor expanded in c around inf 66.6%
unpow266.6%
Simplified66.6%
Taylor expanded in b around 0 66.6%
unpow266.6%
times-frac79.9%
associate-*l/79.9%
Simplified79.9%
clear-num79.9%
*-un-lft-identity79.9%
*-commutative79.9%
frac-times79.9%
clear-num79.9%
associate-/r*79.9%
clear-num80.0%
div-inv80.0%
div-inv80.0%
times-frac80.0%
Applied egg-rr80.0%
Final simplification82.8%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -4.4e+52)
(not
(or (<= c 500000000.0) (and (not (<= c 6.2e+21)) (<= c 3.2e+92)))))
(+ (/ a c) (* (/ d c) (/ b c)))
(/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4.4e+52) || !((c <= 500000000.0) || (!(c <= 6.2e+21) && (c <= 3.2e+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 ((c <= (-4.4d+52)) .or. (.not. (c <= 500000000.0d0) .or. (.not. (c <= 6.2d+21)) .and. (c <= 3.2d+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 ((c <= -4.4e+52) || !((c <= 500000000.0) || (!(c <= 6.2e+21) && (c <= 3.2e+92)))) {
tmp = (a / c) + ((d / c) * (b / c));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -4.4e+52) or not ((c <= 500000000.0) or (not (c <= 6.2e+21) and (c <= 3.2e+92))): tmp = (a / c) + ((d / c) * (b / c)) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -4.4e+52) || !((c <= 500000000.0) || (!(c <= 6.2e+21) && (c <= 3.2e+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 ((c <= -4.4e+52) || ~(((c <= 500000000.0) || (~((c <= 6.2e+21)) && (c <= 3.2e+92))))) tmp = (a / c) + ((d / c) * (b / c)); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -4.4e+52], N[Not[Or[LessEqual[c, 500000000.0], And[N[Not[LessEqual[c, 6.2e+21]], $MachinePrecision], LessEqual[c, 3.2e+92]]]], $MachinePrecision]], 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}\;c \leq -4.4 \cdot 10^{+52} \lor \neg \left(c \leq 500000000 \lor \neg \left(c \leq 6.2 \cdot 10^{+21}\right) \land c \leq 3.2 \cdot 10^{+92}\right):\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -4.4e52 or 5e8 < c < 6.2e21 or 3.20000000000000025e92 < c Initial program 44.0%
Taylor expanded in c around inf 76.5%
*-commutative76.5%
unpow276.5%
times-frac85.2%
Simplified85.2%
if -4.4e52 < c < 5e8 or 6.2e21 < c < 3.20000000000000025e92Initial program 71.4%
Taylor expanded in c around 0 67.0%
Final simplification75.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ a c) (* (/ d c) (/ b c)))))
(if (<= c -4.4e+52)
t_0
(if (<= c 18000000000.0)
(/ b d)
(if (<= c 5.8e+26)
(+ (/ a c) (/ (* b d) (* c c)))
(if (<= c 1.35e+90) (/ b d) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -4.4e+52) {
tmp = t_0;
} else if (c <= 18000000000.0) {
tmp = b / d;
} else if (c <= 5.8e+26) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 1.35e+90) {
tmp = b / d;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (a / c) + ((d / c) * (b / c))
if (c <= (-4.4d+52)) then
tmp = t_0
else if (c <= 18000000000.0d0) then
tmp = b / d
else if (c <= 5.8d+26) then
tmp = (a / c) + ((b * d) / (c * c))
else if (c <= 1.35d+90) then
tmp = b / d
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -4.4e+52) {
tmp = t_0;
} else if (c <= 18000000000.0) {
tmp = b / d;
} else if (c <= 5.8e+26) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 1.35e+90) {
tmp = b / d;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a / c) + ((d / c) * (b / c)) tmp = 0 if c <= -4.4e+52: tmp = t_0 elif c <= 18000000000.0: tmp = b / d elif c <= 5.8e+26: tmp = (a / c) + ((b * d) / (c * c)) elif c <= 1.35e+90: tmp = b / d else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))) tmp = 0.0 if (c <= -4.4e+52) tmp = t_0; elseif (c <= 18000000000.0) tmp = Float64(b / d); elseif (c <= 5.8e+26) tmp = Float64(Float64(a / c) + Float64(Float64(b * d) / Float64(c * c))); elseif (c <= 1.35e+90) tmp = Float64(b / d); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a / c) + ((d / c) * (b / c)); tmp = 0.0; if (c <= -4.4e+52) tmp = t_0; elseif (c <= 18000000000.0) tmp = b / d; elseif (c <= 5.8e+26) tmp = (a / c) + ((b * d) / (c * c)); elseif (c <= 1.35e+90) tmp = b / d; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -4.4e+52], t$95$0, If[LessEqual[c, 18000000000.0], N[(b / d), $MachinePrecision], If[LessEqual[c, 5.8e+26], N[(N[(a / c), $MachinePrecision] + N[(N[(b * d), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.35e+90], N[(b / d), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -4.4 \cdot 10^{+52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 18000000000:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+26}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{+90}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -4.4e52 or 1.35e90 < c Initial program 42.3%
Taylor expanded in c around inf 75.7%
*-commutative75.7%
unpow275.7%
times-frac84.7%
Simplified84.7%
if -4.4e52 < c < 1.8e10 or 5.8e26 < c < 1.35e90Initial program 71.4%
Taylor expanded in c around 0 67.0%
if 1.8e10 < c < 5.8e26Initial program 81.8%
Taylor expanded in c around inf 95.5%
unpow295.5%
Simplified95.5%
Final simplification75.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ b d) (* c (/ a (* d d)))))
(t_1 (+ (/ a c) (* (/ d c) (/ b c)))))
(if (<= c -9.2e+52)
t_1
(if (<= c 550000000.0)
t_0
(if (<= c 1.5e+22)
(+ (/ a c) (/ (* b d) (* c c)))
(if (<= c 2.1e+91) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (b / d) + (c * (a / (d * d)));
double t_1 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -9.2e+52) {
tmp = t_1;
} else if (c <= 550000000.0) {
tmp = t_0;
} else if (c <= 1.5e+22) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 2.1e+91) {
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 = (b / d) + (c * (a / (d * d)))
t_1 = (a / c) + ((d / c) * (b / c))
if (c <= (-9.2d+52)) then
tmp = t_1
else if (c <= 550000000.0d0) then
tmp = t_0
else if (c <= 1.5d+22) then
tmp = (a / c) + ((b * d) / (c * c))
else if (c <= 2.1d+91) 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 = (b / d) + (c * (a / (d * d)));
double t_1 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -9.2e+52) {
tmp = t_1;
} else if (c <= 550000000.0) {
tmp = t_0;
} else if (c <= 1.5e+22) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 2.1e+91) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / d) + (c * (a / (d * d))) t_1 = (a / c) + ((d / c) * (b / c)) tmp = 0 if c <= -9.2e+52: tmp = t_1 elif c <= 550000000.0: tmp = t_0 elif c <= 1.5e+22: tmp = (a / c) + ((b * d) / (c * c)) elif c <= 2.1e+91: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / d) + Float64(c * Float64(a / Float64(d * d)))) t_1 = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))) tmp = 0.0 if (c <= -9.2e+52) tmp = t_1; elseif (c <= 550000000.0) tmp = t_0; elseif (c <= 1.5e+22) tmp = Float64(Float64(a / c) + Float64(Float64(b * d) / Float64(c * c))); elseif (c <= 2.1e+91) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / d) + (c * (a / (d * d))); t_1 = (a / c) + ((d / c) * (b / c)); tmp = 0.0; if (c <= -9.2e+52) tmp = t_1; elseif (c <= 550000000.0) tmp = t_0; elseif (c <= 1.5e+22) tmp = (a / c) + ((b * d) / (c * c)); elseif (c <= 2.1e+91) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.2e+52], t$95$1, If[LessEqual[c, 550000000.0], t$95$0, If[LessEqual[c, 1.5e+22], N[(N[(a / c), $MachinePrecision] + N[(N[(b * d), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.1e+91], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\
t_1 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -9.2 \cdot 10^{+52}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 550000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.5 \cdot 10^{+22}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -9.1999999999999999e52 or 2.10000000000000008e91 < c Initial program 42.3%
Taylor expanded in c around inf 75.7%
*-commutative75.7%
unpow275.7%
times-frac84.7%
Simplified84.7%
if -9.1999999999999999e52 < c < 5.5e8 or 1.5e22 < c < 2.10000000000000008e91Initial program 71.4%
*-un-lft-identity71.4%
add-sqr-sqrt71.4%
times-frac71.5%
hypot-def71.5%
fma-def71.5%
hypot-def83.9%
Applied egg-rr83.9%
Taylor expanded in c around 0 77.1%
*-commutative77.1%
unpow277.1%
associate-*r/73.6%
Simplified73.6%
if 5.5e8 < c < 1.5e22Initial program 81.8%
Taylor expanded in c around inf 95.5%
unpow295.5%
Simplified95.5%
Final simplification78.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ a c) (* (/ d c) (/ b c)))))
(if (<= c -1.1e+53)
t_0
(if (<= c 1020000.0)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= c 2.3e+20)
(+ (/ a c) (/ (* b d) (* c c)))
(if (<= c 1.4e+90) (+ (/ b d) (* c (/ a (* d d)))) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -1.1e+53) {
tmp = t_0;
} else if (c <= 1020000.0) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (c <= 2.3e+20) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 1.4e+90) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (a / c) + ((d / c) * (b / c))
if (c <= (-1.1d+53)) then
tmp = t_0
else if (c <= 1020000.0d0) then
tmp = (b / d) + ((c / d) * (a / d))
else if (c <= 2.3d+20) then
tmp = (a / c) + ((b * d) / (c * c))
else if (c <= 1.4d+90) then
tmp = (b / d) + (c * (a / (d * d)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (a / c) + ((d / c) * (b / c));
double tmp;
if (c <= -1.1e+53) {
tmp = t_0;
} else if (c <= 1020000.0) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (c <= 2.3e+20) {
tmp = (a / c) + ((b * d) / (c * c));
} else if (c <= 1.4e+90) {
tmp = (b / d) + (c * (a / (d * d)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (a / c) + ((d / c) * (b / c)) tmp = 0 if c <= -1.1e+53: tmp = t_0 elif c <= 1020000.0: tmp = (b / d) + ((c / d) * (a / d)) elif c <= 2.3e+20: tmp = (a / c) + ((b * d) / (c * c)) elif c <= 1.4e+90: tmp = (b / d) + (c * (a / (d * d))) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))) tmp = 0.0 if (c <= -1.1e+53) tmp = t_0; elseif (c <= 1020000.0) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (c <= 2.3e+20) tmp = Float64(Float64(a / c) + Float64(Float64(b * d) / Float64(c * c))); elseif (c <= 1.4e+90) tmp = Float64(Float64(b / d) + Float64(c * Float64(a / Float64(d * d)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a / c) + ((d / c) * (b / c)); tmp = 0.0; if (c <= -1.1e+53) tmp = t_0; elseif (c <= 1020000.0) tmp = (b / d) + ((c / d) * (a / d)); elseif (c <= 2.3e+20) tmp = (a / c) + ((b * d) / (c * c)); elseif (c <= 1.4e+90) tmp = (b / d) + (c * (a / (d * d))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.1e+53], t$95$0, If[LessEqual[c, 1020000.0], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.3e+20], N[(N[(a / c), $MachinePrecision] + N[(N[(b * d), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.4e+90], N[(N[(b / d), $MachinePrecision] + N[(c * N[(a / N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{if}\;c \leq -1.1 \cdot 10^{+53}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1020000:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;c \leq 2.3 \cdot 10^{+20}:\\
\;\;\;\;\frac{a}{c} + \frac{b \cdot d}{c \cdot c}\\
\mathbf{elif}\;c \leq 1.4 \cdot 10^{+90}:\\
\;\;\;\;\frac{b}{d} + c \cdot \frac{a}{d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if c < -1.09999999999999999e53 or 1.4e90 < c Initial program 42.3%
Taylor expanded in c around inf 75.7%
*-commutative75.7%
unpow275.7%
times-frac84.7%
Simplified84.7%
if -1.09999999999999999e53 < c < 1.02e6Initial program 74.9%
Taylor expanded in c around 0 77.1%
*-commutative77.1%
unpow277.1%
times-frac81.2%
Simplified81.2%
if 1.02e6 < c < 2.3e20Initial program 81.8%
Taylor expanded in c around inf 95.5%
unpow295.5%
Simplified95.5%
if 2.3e20 < c < 1.4e90Initial program 33.4%
*-un-lft-identity33.4%
add-sqr-sqrt33.3%
times-frac33.4%
hypot-def33.4%
fma-def33.4%
hypot-def51.8%
Applied egg-rr51.8%
Taylor expanded in c around 0 77.0%
*-commutative77.0%
unpow277.0%
associate-*r/77.0%
Simplified77.0%
Final simplification82.8%
(FPCore (a b c d) :precision binary64 (if (<= c -1.6e+53) (/ a c) (if (<= c 2.1e+91) (/ b d) (/ a c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -1.6e+53) {
tmp = a / c;
} else if (c <= 2.1e+91) {
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 (c <= (-1.6d+53)) then
tmp = a / c
else if (c <= 2.1d+91) 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 (c <= -1.6e+53) {
tmp = a / c;
} else if (c <= 2.1e+91) {
tmp = b / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -1.6e+53: tmp = a / c elif c <= 2.1e+91: tmp = b / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -1.6e+53) tmp = Float64(a / c); elseif (c <= 2.1e+91) 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 (c <= -1.6e+53) tmp = a / c; elseif (c <= 2.1e+91) tmp = b / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -1.6e+53], N[(a / c), $MachinePrecision], If[LessEqual[c, 2.1e+91], N[(b / d), $MachinePrecision], N[(a / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.6 \cdot 10^{+53}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{elif}\;c \leq 2.1 \cdot 10^{+91}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if c < -1.6e53 or 2.10000000000000008e91 < c Initial program 42.3%
Taylor expanded in c around inf 73.5%
if -1.6e53 < c < 2.10000000000000008e91Initial program 71.7%
Taylor expanded in c around 0 64.8%
Final simplification68.6%
(FPCore (a b c d) :precision binary64 (if (<= d -2.4e+195) (/ a d) (/ a c)))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.4e+195) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-2.4d+195)) then
tmp = a / d
else
tmp = a / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -2.4e+195) {
tmp = a / d;
} else {
tmp = a / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -2.4e+195: tmp = a / d else: tmp = a / c return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -2.4e+195) tmp = Float64(a / d); else tmp = Float64(a / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -2.4e+195) tmp = a / d; else tmp = a / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -2.4e+195], N[(a / d), $MachinePrecision], N[(a / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.4 \cdot 10^{+195}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c}\\
\end{array}
\end{array}
if d < -2.4000000000000003e195Initial program 33.9%
*-un-lft-identity33.9%
add-sqr-sqrt33.9%
times-frac33.9%
hypot-def33.9%
fma-def33.9%
hypot-def53.1%
Applied egg-rr53.1%
associate-*r/53.2%
Applied egg-rr53.2%
Taylor expanded in c around 0 34.5%
Taylor expanded in c around inf 27.7%
if -2.4000000000000003e195 < d Initial program 61.7%
Taylor expanded in c around inf 46.5%
Final simplification44.7%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 59.0%
Taylor expanded in c around inf 42.8%
Final simplification42.8%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
else
tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (a + (b * (d / c))) / (c + (d * (d / c))) else: tmp = (b + (a * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (a + (b * (d / c))) / (c + (d * (d / c))); else tmp = (b + (a * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023293
(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))))