
(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)) (+ (* c c) (* d d)))))
(if (<= t_0 (- INFINITY))
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= t_0 INFINITY)
(* (/ 1.0 (hypot c d)) (/ (fma a c (* b d)) (hypot c d)))
(* (/ d (hypot d c)) (/ b (hypot d c)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((a * c) + (b * d)) / ((c * c) + (d * d));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (t_0 <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (fma(a, c, (b * d)) / hypot(c, d));
} else {
tmp = (d / hypot(d, c)) * (b / hypot(d, c));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (t_0 <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(a, c, Float64(b * d)) / hypot(c, d))); else tmp = Float64(Float64(d / hypot(d, c)) * Float64(b / hypot(d, c))); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(a * c + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(a, c, b \cdot d\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{d}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 33.3%
Taylor expanded in c around inf 48.7%
unpow248.7%
times-frac67.4%
Simplified67.4%
if -inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 76.8%
*-un-lft-identity76.8%
add-sqr-sqrt76.8%
times-frac76.8%
hypot-def76.8%
fma-def76.9%
hypot-def97.1%
Applied egg-rr97.1%
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.5%
add-sqr-sqrt1.5%
hypot-udef1.5%
hypot-udef1.5%
times-frac57.8%
hypot-udef4.1%
+-commutative4.1%
hypot-def57.8%
hypot-udef4.1%
+-commutative4.1%
hypot-def57.8%
Applied egg-rr57.8%
Final simplification88.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* a c) (* b d))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 (- INFINITY))
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= t_1 INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(* (/ d (hypot d c)) (/ b (hypot d c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (d / hypot(d, c)) * (b / hypot(d, c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (a * c) + (b * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (d / Math.hypot(d, c)) * (b / Math.hypot(d, c));
}
return tmp;
}
def code(a, b, c, d): t_0 = (a * c) + (b * d) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= -math.inf: tmp = (a / c) + ((d / c) * (b / c)) elif t_1 <= math.inf: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (d / math.hypot(d, c)) * (b / math.hypot(d, c)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(a * c) + Float64(b * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (t_1 <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(d / hypot(d, c)) * Float64(b / hypot(d, c))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (a * c) + (b * d); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= -Inf) tmp = (a / c) + ((d / c) * (b / c)); elseif (t_1 <= Inf) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (d / hypot(d, c)) * (b / hypot(d, c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 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[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot c + b \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;t_1 \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(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 33.3%
Taylor expanded in c around inf 48.7%
unpow248.7%
times-frac67.4%
Simplified67.4%
if -inf.0 < (/.f64 (+.f64 (*.f64 a c) (*.f64 b d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 76.8%
*-un-lft-identity76.8%
add-sqr-sqrt76.8%
times-frac76.8%
hypot-def76.8%
fma-def76.9%
hypot-def97.1%
Applied egg-rr97.1%
fma-def97.1%
+-commutative97.1%
Applied egg-rr97.1%
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.5%
add-sqr-sqrt1.5%
hypot-udef1.5%
hypot-udef1.5%
times-frac57.8%
hypot-udef4.1%
+-commutative4.1%
hypot-def57.8%
hypot-udef4.1%
+-commutative4.1%
hypot-def57.8%
Applied egg-rr57.8%
Final simplification88.4%
(FPCore (a b c d)
:precision binary64
(if (<= d -8.2e+69)
(+ (/ b d) (/ c (* d (/ d a))))
(if (<= d 1.85e-93)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d 2.25e+79)
(/ (+ (* a c) (* b d)) (+ (* c c) (* d d)))
(* (/ 1.0 (hypot c d)) (+ b (/ c (/ d a))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.2e+69) {
tmp = (b / d) + (c / (d * (d / a)));
} else if (d <= 1.85e-93) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 2.25e+79) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / hypot(c, d)) * (b + (c / (d / a)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.2e+69) {
tmp = (b / d) + (c / (d * (d / a)));
} else if (d <= 1.85e-93) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 2.25e+79) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = (1.0 / Math.hypot(c, d)) * (b + (c / (d / a)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -8.2e+69: tmp = (b / d) + (c / (d * (d / a))) elif d <= 1.85e-93: tmp = (a / c) + ((d / c) * (b / c)) elif d <= 2.25e+79: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = (1.0 / math.hypot(c, d)) * (b + (c / (d / a))) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -8.2e+69) tmp = Float64(Float64(b / d) + Float64(c / Float64(d * Float64(d / a)))); elseif (d <= 1.85e-93) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= 2.25e+79) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(b + Float64(c / Float64(d / a)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -8.2e+69) tmp = (b / d) + (c / (d * (d / a))); elseif (d <= 1.85e-93) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= 2.25e+79) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = (1.0 / hypot(c, d)) * (b + (c / (d / a))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -8.2e+69], N[(N[(b / d), $MachinePrecision] + N[(c / N[(d * N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.85e-93], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.25e+79], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b + N[(c / N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.2 \cdot 10^{+69}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\mathbf{elif}\;d \leq 1.85 \cdot 10^{-93}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq 2.25 \cdot 10^{+79}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(b + \frac{c}{\frac{d}{a}}\right)\\
\end{array}
\end{array}
if d < -8.1999999999999998e69Initial program 51.0%
Taylor expanded in c around 0 86.0%
unpow286.0%
times-frac90.9%
Simplified90.9%
*-commutative90.9%
clear-num90.9%
frac-times91.2%
*-un-lft-identity91.2%
Applied egg-rr91.2%
if -8.1999999999999998e69 < d < 1.85000000000000001e-93Initial program 68.1%
Taylor expanded in c around inf 77.1%
unpow277.1%
times-frac85.5%
Simplified85.5%
if 1.85000000000000001e-93 < d < 2.24999999999999997e79Initial program 76.0%
if 2.24999999999999997e79 < d Initial program 43.1%
*-un-lft-identity43.1%
add-sqr-sqrt43.1%
times-frac43.2%
hypot-def43.2%
fma-def43.2%
hypot-def64.1%
Applied egg-rr64.1%
Taylor expanded in c around 0 80.5%
associate-/l*83.3%
Simplified83.3%
Final simplification85.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ b d) (/ c (* d (/ d a))))))
(if (<= d -7e+68)
t_0
(if (<= d 4.4e-95)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d 6.4e+62) (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = (b / d) + (c / (d * (d / a)));
double tmp;
if (d <= -7e+68) {
tmp = t_0;
} else if (d <= 4.4e-95) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 6.4e+62) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b / d) + (c / (d * (d / a)))
if (d <= (-7d+68)) then
tmp = t_0
else if (d <= 4.4d-95) then
tmp = (a / c) + ((d / c) * (b / c))
else if (d <= 6.4d+62) then
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b / d) + (c / (d * (d / a)));
double tmp;
if (d <= -7e+68) {
tmp = t_0;
} else if (d <= 4.4e-95) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 6.4e+62) {
tmp = ((a * c) + (b * d)) / ((c * c) + (d * d));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / d) + (c / (d * (d / a))) tmp = 0 if d <= -7e+68: tmp = t_0 elif d <= 4.4e-95: tmp = (a / c) + ((d / c) * (b / c)) elif d <= 6.4e+62: tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / d) + Float64(c / Float64(d * Float64(d / a)))) tmp = 0.0 if (d <= -7e+68) tmp = t_0; elseif (d <= 4.4e-95) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= 6.4e+62) tmp = Float64(Float64(Float64(a * c) + Float64(b * d)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / d) + (c / (d * (d / a))); tmp = 0.0; if (d <= -7e+68) tmp = t_0; elseif (d <= 4.4e-95) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= 6.4e+62) tmp = ((a * c) + (b * d)) / ((c * c) + (d * d)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / d), $MachinePrecision] + N[(c / N[(d * N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7e+68], t$95$0, If[LessEqual[d, 4.4e-95], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.4e+62], N[(N[(N[(a * c), $MachinePrecision] + N[(b * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\mathbf{if}\;d \leq -7 \cdot 10^{+68}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.4 \cdot 10^{-95}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq 6.4 \cdot 10^{+62}:\\
\;\;\;\;\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -6.99999999999999955e68 or 6.39999999999999968e62 < d Initial program 48.0%
Taylor expanded in c around 0 78.2%
unpow278.2%
times-frac82.6%
Simplified82.6%
*-commutative82.6%
clear-num83.5%
frac-times86.2%
*-un-lft-identity86.2%
Applied egg-rr86.2%
if -6.99999999999999955e68 < d < 4.3999999999999998e-95Initial program 68.1%
Taylor expanded in c around inf 77.1%
unpow277.1%
times-frac85.5%
Simplified85.5%
if 4.3999999999999998e-95 < d < 6.39999999999999968e62Initial program 78.4%
Final simplification85.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (/ b d) (/ c (* d (/ d a))))))
(if (<= d -1.15e+67)
t_0
(if (<= d 8.2e-74)
(+ (/ a c) (* (/ d c) (/ b c)))
(if (<= d 4.3e+33)
(/ (* b d) (+ (* c c) (* d d)))
(if (<= d 2.1e+80) (/ a (+ c (/ (* d d) c))) t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (b / d) + (c / (d * (d / a)));
double tmp;
if (d <= -1.15e+67) {
tmp = t_0;
} else if (d <= 8.2e-74) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 4.3e+33) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 2.1e+80) {
tmp = a / (c + ((d * d) / c));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (b / d) + (c / (d * (d / a)))
if (d <= (-1.15d+67)) then
tmp = t_0
else if (d <= 8.2d-74) then
tmp = (a / c) + ((d / c) * (b / c))
else if (d <= 4.3d+33) then
tmp = (b * d) / ((c * c) + (d * d))
else if (d <= 2.1d+80) then
tmp = a / (c + ((d * d) / c))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (b / d) + (c / (d * (d / a)));
double tmp;
if (d <= -1.15e+67) {
tmp = t_0;
} else if (d <= 8.2e-74) {
tmp = (a / c) + ((d / c) * (b / c));
} else if (d <= 4.3e+33) {
tmp = (b * d) / ((c * c) + (d * d));
} else if (d <= 2.1e+80) {
tmp = a / (c + ((d * d) / c));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b / d) + (c / (d * (d / a))) tmp = 0 if d <= -1.15e+67: tmp = t_0 elif d <= 8.2e-74: tmp = (a / c) + ((d / c) * (b / c)) elif d <= 4.3e+33: tmp = (b * d) / ((c * c) + (d * d)) elif d <= 2.1e+80: tmp = a / (c + ((d * d) / c)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b / d) + Float64(c / Float64(d * Float64(d / a)))) tmp = 0.0 if (d <= -1.15e+67) tmp = t_0; elseif (d <= 8.2e-74) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); elseif (d <= 4.3e+33) tmp = Float64(Float64(b * d) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.1e+80) tmp = Float64(a / Float64(c + Float64(Float64(d * d) / c))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b / d) + (c / (d * (d / a))); tmp = 0.0; if (d <= -1.15e+67) tmp = t_0; elseif (d <= 8.2e-74) tmp = (a / c) + ((d / c) * (b / c)); elseif (d <= 4.3e+33) tmp = (b * d) / ((c * c) + (d * d)); elseif (d <= 2.1e+80) tmp = a / (c + ((d * d) / c)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b / d), $MachinePrecision] + N[(c / N[(d * N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.15e+67], t$95$0, If[LessEqual[d, 8.2e-74], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 4.3e+33], N[(N[(b * d), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.1e+80], N[(a / N[(c + N[(N[(d * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\mathbf{if}\;d \leq -1.15 \cdot 10^{+67}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 8.2 \cdot 10^{-74}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{elif}\;d \leq 4.3 \cdot 10^{+33}:\\
\;\;\;\;\frac{b \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.1 \cdot 10^{+80}:\\
\;\;\;\;\frac{a}{c + \frac{d \cdot d}{c}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -1.1499999999999999e67 or 2.10000000000000001e80 < d Initial program 47.2%
Taylor expanded in c around 0 79.5%
unpow279.5%
times-frac84.2%
Simplified84.2%
*-commutative84.2%
clear-num85.1%
frac-times88.1%
*-un-lft-identity88.1%
Applied egg-rr88.1%
if -1.1499999999999999e67 < d < 8.20000000000000063e-74Initial program 68.4%
Taylor expanded in c around inf 77.3%
unpow277.3%
times-frac85.6%
Simplified85.6%
if 8.20000000000000063e-74 < d < 4.30000000000000028e33Initial program 82.2%
Taylor expanded in a around 0 76.2%
if 4.30000000000000028e33 < d < 2.10000000000000001e80Initial program 65.5%
Taylor expanded in a around inf 46.5%
*-commutative46.5%
associate-/l*58.2%
unpow258.2%
unpow258.2%
+-commutative58.2%
fma-udef58.2%
Simplified58.2%
Taylor expanded in c around 0 69.5%
unpow269.5%
Simplified69.5%
Final simplification84.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -4.8e-16) (not (<= c 2.1e-7))) (/ a (+ c (* d (/ d c)))) (* (/ 1.0 d) (+ b (/ (* a c) d)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4.8e-16) || !(c <= 2.1e-7)) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = (1.0 / d) * (b + ((a * 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 ((c <= (-4.8d-16)) .or. (.not. (c <= 2.1d-7))) then
tmp = a / (c + (d * (d / c)))
else
tmp = (1.0d0 / d) * (b + ((a * c) / d))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -4.8e-16) || !(c <= 2.1e-7)) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = (1.0 / d) * (b + ((a * c) / d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -4.8e-16) or not (c <= 2.1e-7): tmp = a / (c + (d * (d / c))) else: tmp = (1.0 / d) * (b + ((a * c) / d)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -4.8e-16) || !(c <= 2.1e-7)) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(Float64(a * c) / d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -4.8e-16) || ~((c <= 2.1e-7))) tmp = a / (c + (d * (d / c))); else tmp = (1.0 / d) * (b + ((a * c) / d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -4.8e-16], N[Not[LessEqual[c, 2.1e-7]], $MachinePrecision]], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.8 \cdot 10^{-16} \lor \neg \left(c \leq 2.1 \cdot 10^{-7}\right):\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a \cdot c}{d}\right)\\
\end{array}
\end{array}
if c < -4.8000000000000001e-16 or 2.1e-7 < c Initial program 52.3%
Taylor expanded in a around inf 45.1%
*-commutative45.1%
associate-/l*54.0%
unpow254.0%
unpow254.0%
+-commutative54.0%
fma-udef54.0%
Simplified54.0%
Taylor expanded in c around 0 75.5%
unpow275.5%
Simplified75.5%
Taylor expanded in d around 0 75.5%
unpow275.5%
associate-*r/77.7%
Simplified77.7%
if -4.8000000000000001e-16 < c < 2.1e-7Initial program 69.2%
*-un-lft-identity69.2%
add-sqr-sqrt69.2%
times-frac69.2%
hypot-def69.2%
fma-def69.2%
hypot-def84.4%
Applied egg-rr84.4%
Taylor expanded in c around 0 46.8%
Taylor expanded in c around 0 81.4%
Final simplification79.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -8.2e+69) (not (<= d 9.2e-17))) (* (/ 1.0 d) (+ b (/ (* a c) d))) (+ (/ a c) (* (/ d c) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.2e+69) || !(d <= 9.2e-17)) {
tmp = (1.0 / d) * (b + ((a * c) / 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 <= (-8.2d+69)) .or. (.not. (d <= 9.2d-17))) then
tmp = (1.0d0 / d) * (b + ((a * c) / 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 <= -8.2e+69) || !(d <= 9.2e-17)) {
tmp = (1.0 / d) * (b + ((a * c) / d));
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.2e+69) or not (d <= 9.2e-17): tmp = (1.0 / d) * (b + ((a * c) / d)) else: tmp = (a / c) + ((d / c) * (b / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.2e+69) || !(d <= 9.2e-17)) tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(Float64(a * c) / 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 <= -8.2e+69) || ~((d <= 9.2e-17))) tmp = (1.0 / d) * (b + ((a * c) / d)); else tmp = (a / c) + ((d / c) * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.2e+69], N[Not[LessEqual[d, 9.2e-17]], $MachinePrecision]], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $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 -8.2 \cdot 10^{+69} \lor \neg \left(d \leq 9.2 \cdot 10^{-17}\right):\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a \cdot c}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if d < -8.1999999999999998e69 or 9.20000000000000035e-17 < d Initial program 52.2%
*-un-lft-identity52.2%
add-sqr-sqrt52.2%
times-frac52.2%
hypot-def52.2%
fma-def52.2%
hypot-def68.4%
Applied egg-rr68.4%
Taylor expanded in c around 0 54.8%
Taylor expanded in c around 0 79.1%
if -8.1999999999999998e69 < d < 9.20000000000000035e-17Initial program 68.8%
Taylor expanded in c around inf 75.5%
unpow275.5%
times-frac83.2%
Simplified83.2%
Final simplification81.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.15e+67) (not (<= d 3.7e-19))) (+ (/ b d) (/ c (* d (/ d a)))) (+ (/ a c) (* (/ d c) (/ b c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.15e+67) || !(d <= 3.7e-19)) {
tmp = (b / d) + (c / (d * (d / a)));
} 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 <= (-1.15d+67)) .or. (.not. (d <= 3.7d-19))) then
tmp = (b / d) + (c / (d * (d / a)))
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 <= -1.15e+67) || !(d <= 3.7e-19)) {
tmp = (b / d) + (c / (d * (d / a)));
} else {
tmp = (a / c) + ((d / c) * (b / c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.15e+67) or not (d <= 3.7e-19): tmp = (b / d) + (c / (d * (d / a))) else: tmp = (a / c) + ((d / c) * (b / c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.15e+67) || !(d <= 3.7e-19)) tmp = Float64(Float64(b / d) + Float64(c / Float64(d * Float64(d / a)))); 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 <= -1.15e+67) || ~((d <= 3.7e-19))) tmp = (b / d) + (c / (d * (d / a))); else tmp = (a / c) + ((d / c) * (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.15e+67], N[Not[LessEqual[d, 3.7e-19]], $MachinePrecision]], N[(N[(b / d), $MachinePrecision] + N[(c / N[(d * N[(d / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -1.15 \cdot 10^{+67} \lor \neg \left(d \leq 3.7 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{b}{d} + \frac{c}{d \cdot \frac{d}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\end{array}
\end{array}
if d < -1.1499999999999999e67 or 3.70000000000000005e-19 < d Initial program 52.2%
Taylor expanded in c around 0 75.6%
unpow275.6%
times-frac79.4%
Simplified79.4%
*-commutative79.4%
clear-num80.2%
frac-times82.6%
*-un-lft-identity82.6%
Applied egg-rr82.6%
if -1.1499999999999999e67 < d < 3.70000000000000005e-19Initial program 68.8%
Taylor expanded in c around inf 75.5%
unpow275.5%
times-frac83.2%
Simplified83.2%
Final simplification82.9%
(FPCore (a b c d)
:precision binary64
(if (<= d -1.15e+67)
(+ (/ b d) (* (/ c d) (/ a d)))
(if (<= d 1.7e-17)
(+ (/ a c) (* (/ d c) (/ b c)))
(* (/ 1.0 d) (+ b (/ (* a c) d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.15e+67) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= 1.7e-17) {
tmp = (a / c) + ((d / c) * (b / c));
} else {
tmp = (1.0 / d) * (b + ((a * c) / d));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-1.15d+67)) then
tmp = (b / d) + ((c / d) * (a / d))
else if (d <= 1.7d-17) then
tmp = (a / c) + ((d / c) * (b / c))
else
tmp = (1.0d0 / d) * (b + ((a * c) / d))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.15e+67) {
tmp = (b / d) + ((c / d) * (a / d));
} else if (d <= 1.7e-17) {
tmp = (a / c) + ((d / c) * (b / c));
} else {
tmp = (1.0 / d) * (b + ((a * c) / d));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.15e+67: tmp = (b / d) + ((c / d) * (a / d)) elif d <= 1.7e-17: tmp = (a / c) + ((d / c) * (b / c)) else: tmp = (1.0 / d) * (b + ((a * c) / d)) return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.15e+67) tmp = Float64(Float64(b / d) + Float64(Float64(c / d) * Float64(a / d))); elseif (d <= 1.7e-17) tmp = Float64(Float64(a / c) + Float64(Float64(d / c) * Float64(b / c))); else tmp = Float64(Float64(1.0 / d) * Float64(b + Float64(Float64(a * c) / d))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.15e+67) tmp = (b / d) + ((c / d) * (a / d)); elseif (d <= 1.7e-17) tmp = (a / c) + ((d / c) * (b / c)); else tmp = (1.0 / d) * (b + ((a * c) / d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.15e+67], N[(N[(b / d), $MachinePrecision] + N[(N[(c / d), $MachinePrecision] * N[(a / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.7e-17], N[(N[(a / c), $MachinePrecision] + N[(N[(d / c), $MachinePrecision] * N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(b + N[(N[(a * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.15 \cdot 10^{+67}:\\
\;\;\;\;\frac{b}{d} + \frac{c}{d} \cdot \frac{a}{d}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{-17}:\\
\;\;\;\;\frac{a}{c} + \frac{d}{c} \cdot \frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(b + \frac{a \cdot c}{d}\right)\\
\end{array}
\end{array}
if d < -1.1499999999999999e67Initial program 51.0%
Taylor expanded in c around 0 86.0%
unpow286.0%
times-frac90.9%
Simplified90.9%
if -1.1499999999999999e67 < d < 1.6999999999999999e-17Initial program 68.8%
Taylor expanded in c around inf 75.5%
unpow275.5%
times-frac83.2%
Simplified83.2%
if 1.6999999999999999e-17 < d Initial program 53.1%
*-un-lft-identity53.1%
add-sqr-sqrt53.1%
times-frac53.1%
hypot-def53.1%
fma-def53.1%
hypot-def67.9%
Applied egg-rr67.9%
Taylor expanded in c around 0 74.1%
Taylor expanded in c around 0 72.7%
Final simplification82.0%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.2e-37) (not (<= c 1.12e-25))) (/ a (+ c (* d (/ d c)))) (/ b d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.2e-37) || !(c <= 1.12e-25)) {
tmp = a / (c + (d * (d / 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 <= (-5.2d-37)) .or. (.not. (c <= 1.12d-25))) then
tmp = a / (c + (d * (d / 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 <= -5.2e-37) || !(c <= 1.12e-25)) {
tmp = a / (c + (d * (d / c)));
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.2e-37) or not (c <= 1.12e-25): tmp = a / (c + (d * (d / c))) else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.2e-37) || !(c <= 1.12e-25)) tmp = Float64(a / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.2e-37) || ~((c <= 1.12e-25))) tmp = a / (c + (d * (d / c))); else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.2e-37], N[Not[LessEqual[c, 1.12e-25]], $MachinePrecision]], N[(a / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.2 \cdot 10^{-37} \lor \neg \left(c \leq 1.12 \cdot 10^{-25}\right):\\
\;\;\;\;\frac{a}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if c < -5.19999999999999959e-37 or 1.12e-25 < c Initial program 53.2%
Taylor expanded in a around inf 44.6%
*-commutative44.6%
associate-/l*52.8%
unpow252.8%
unpow252.8%
+-commutative52.8%
fma-udef52.8%
Simplified52.8%
Taylor expanded in c around 0 72.7%
unpow272.7%
Simplified72.7%
Taylor expanded in d around 0 72.7%
unpow272.7%
associate-*r/74.7%
Simplified74.7%
if -5.19999999999999959e-37 < c < 1.12e-25Initial program 69.7%
Taylor expanded in c around 0 66.4%
Final simplification70.9%
(FPCore (a b c d) :precision binary64 (if (<= d -8.5e+170) (/ a d) (if (<= d 2.7e+218) (/ a c) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.5e+170) {
tmp = a / d;
} else if (d <= 2.7e+218) {
tmp = a / c;
} else {
tmp = a / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-8.5d+170)) then
tmp = a / d
else if (d <= 2.7d+218) then
tmp = a / c
else
tmp = a / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -8.5e+170) {
tmp = a / d;
} else if (d <= 2.7e+218) {
tmp = a / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -8.5e+170: tmp = a / d elif d <= 2.7e+218: tmp = a / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -8.5e+170) tmp = Float64(a / d); elseif (d <= 2.7e+218) tmp = Float64(a / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -8.5e+170) tmp = a / d; elseif (d <= 2.7e+218) tmp = a / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -8.5e+170], N[(a / d), $MachinePrecision], If[LessEqual[d, 2.7e+218], N[(a / c), $MachinePrecision], N[(a / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -8.5 \cdot 10^{+170}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+218}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < -8.5000000000000004e170 or 2.70000000000000013e218 < d Initial program 41.4%
*-un-lft-identity41.4%
add-sqr-sqrt41.4%
times-frac41.4%
hypot-def41.4%
fma-def41.4%
hypot-def63.2%
Applied egg-rr63.2%
Taylor expanded in d around -inf 80.5%
neg-mul-180.5%
+-commutative80.5%
unsub-neg80.5%
mul-1-neg80.5%
*-lft-identity80.5%
times-frac80.5%
/-rgt-identity80.5%
Simplified80.5%
Taylor expanded in c around -inf 31.2%
if -8.5000000000000004e170 < d < 2.70000000000000013e218Initial program 65.2%
Taylor expanded in c around inf 50.7%
Final simplification47.1%
(FPCore (a b c d) :precision binary64 (if (<= d -1e+57) (/ b d) (if (<= d 9e-79) (/ a c) (/ b d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1e+57) {
tmp = b / d;
} else if (d <= 9e-79) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (d <= (-1d+57)) then
tmp = b / d
else if (d <= 9d-79) then
tmp = a / c
else
tmp = b / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1e+57) {
tmp = b / d;
} else if (d <= 9e-79) {
tmp = a / c;
} else {
tmp = b / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1e+57: tmp = b / d elif d <= 9e-79: tmp = a / c else: tmp = b / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1e+57) tmp = Float64(b / d); elseif (d <= 9e-79) tmp = Float64(a / c); else tmp = Float64(b / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1e+57) tmp = b / d; elseif (d <= 9e-79) tmp = a / c; else tmp = b / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1e+57], N[(b / d), $MachinePrecision], If[LessEqual[d, 9e-79], N[(a / c), $MachinePrecision], N[(b / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1 \cdot 10^{+57}:\\
\;\;\;\;\frac{b}{d}\\
\mathbf{elif}\;d \leq 9 \cdot 10^{-79}:\\
\;\;\;\;\frac{a}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d}\\
\end{array}
\end{array}
if d < -1.00000000000000005e57 or 9.0000000000000006e-79 < d Initial program 53.5%
Taylor expanded in c around 0 67.4%
if -1.00000000000000005e57 < d < 9.0000000000000006e-79Initial program 69.5%
Taylor expanded in c around inf 68.3%
Final simplification67.8%
(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 60.7%
Taylor expanded in c around inf 43.4%
Final simplification43.4%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (a + (b * (d / c))) / (c + (d * (d / c)))
else
tmp = (b + (a * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (a + (b * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (b + (a * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (a + (b * (d / c))) / (c + (d * (d / c))) else: tmp = (b + (a * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(a + Float64(b * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(b + Float64(a * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (a + (b * (d / c))) / (c + (d * (d / c))); else tmp = (b + (a * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(a + N[(b * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b + N[(a * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023187
(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))))