
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * 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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * 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 = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d)))
(t_1 (* t_0 (/ b (/ (hypot c d) c))))
(t_2 (- (* b c) (* a d)))
(t_3 (/ t_2 (+ (* c c) (* d d)))))
(if (<= t_3 -1e+281)
(- t_1 (* d (/ a (pow (hypot c d) 2.0))))
(if (<= t_3 2e+285) (* t_0 (/ t_2 (hypot c d))) (- t_1 (/ a d))))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = t_0 * (b / (hypot(c, d) / c));
double t_2 = (b * c) - (a * d);
double t_3 = t_2 / ((c * c) + (d * d));
double tmp;
if (t_3 <= -1e+281) {
tmp = t_1 - (d * (a / pow(hypot(c, d), 2.0)));
} else if (t_3 <= 2e+285) {
tmp = t_0 * (t_2 / hypot(c, d));
} else {
tmp = t_1 - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = 1.0 / Math.hypot(c, d);
double t_1 = t_0 * (b / (Math.hypot(c, d) / c));
double t_2 = (b * c) - (a * d);
double t_3 = t_2 / ((c * c) + (d * d));
double tmp;
if (t_3 <= -1e+281) {
tmp = t_1 - (d * (a / Math.pow(Math.hypot(c, d), 2.0)));
} else if (t_3 <= 2e+285) {
tmp = t_0 * (t_2 / Math.hypot(c, d));
} else {
tmp = t_1 - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = 1.0 / math.hypot(c, d) t_1 = t_0 * (b / (math.hypot(c, d) / c)) t_2 = (b * c) - (a * d) t_3 = t_2 / ((c * c) + (d * d)) tmp = 0 if t_3 <= -1e+281: tmp = t_1 - (d * (a / math.pow(math.hypot(c, d), 2.0))) elif t_3 <= 2e+285: tmp = t_0 * (t_2 / math.hypot(c, d)) else: tmp = t_1 - (a / d) return tmp
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(t_0 * Float64(b / Float64(hypot(c, d) / c))) t_2 = Float64(Float64(b * c) - Float64(a * d)) t_3 = Float64(t_2 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_3 <= -1e+281) tmp = Float64(t_1 - Float64(d * Float64(a / (hypot(c, d) ^ 2.0)))); elseif (t_3 <= 2e+285) tmp = Float64(t_0 * Float64(t_2 / hypot(c, d))); else tmp = Float64(t_1 - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = 1.0 / hypot(c, d); t_1 = t_0 * (b / (hypot(c, d) / c)); t_2 = (b * c) - (a * d); t_3 = t_2 / ((c * c) + (d * d)); tmp = 0.0; if (t_3 <= -1e+281) tmp = t_1 - (d * (a / (hypot(c, d) ^ 2.0))); elseif (t_3 <= 2e+285) tmp = t_0 * (t_2 / hypot(c, d)); else tmp = t_1 - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+281], N[(t$95$1 - N[(d * N[(a / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+285], N[(t$95$0 * N[(t$95$2 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := t_0 \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}\\
t_2 := b \cdot c - a \cdot d\\
t_3 := \frac{t_2}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;t_1 - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;t_0 \cdot \frac{t_2}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1 - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -1e281Initial program 54.6%
div-sub44.0%
*-un-lft-identity44.0%
add-sqr-sqrt44.0%
times-frac44.0%
fma-neg44.0%
hypot-def44.0%
hypot-def49.3%
associate-/l*64.3%
add-sqr-sqrt64.3%
pow264.3%
hypot-def64.3%
Applied egg-rr64.3%
fma-neg64.3%
associate-/l*94.5%
associate-/r/94.4%
*-commutative94.4%
Simplified94.4%
if -1e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e285Initial program 79.0%
*-un-lft-identity79.0%
add-sqr-sqrt79.0%
times-frac79.0%
hypot-def79.0%
hypot-def99.7%
Applied egg-rr99.7%
if 2e285 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 8.3%
div-sub6.5%
*-un-lft-identity6.5%
add-sqr-sqrt6.5%
times-frac6.5%
fma-neg6.5%
hypot-def6.5%
hypot-def9.2%
associate-/l*22.6%
add-sqr-sqrt22.6%
pow222.6%
hypot-def22.6%
Applied egg-rr22.6%
fma-neg22.6%
associate-/l*60.5%
associate-/r/60.5%
*-commutative60.5%
Simplified60.5%
Taylor expanded in d around inf 70.7%
Final simplification93.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 -1e+281)
(/ (- b (/ a (/ c d))) c)
(if (<= t_1 2e+285)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(- (* (/ c d) (/ b d)) (/ a d))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= -1e+281) {
tmp = (b - (a / (c / d))) / c;
} else if (t_1 <= 2e+285) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if (t_1 <= -1e+281) {
tmp = (b - (a / (c / d))) / c;
} else if (t_1 <= 2e+285) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (a * d) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if t_1 <= -1e+281: tmp = (b - (a / (c / d))) / c elif t_1 <= 2e+285: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = ((c / d) * (b / d)) - (a / d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_1 <= -1e+281) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (t_1 <= 2e+285) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) - (a * d); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if (t_1 <= -1e+281) tmp = (b - (a / (c / d))) / c; elseif (t_1 <= 2e+285) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = ((c / d) * (b / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * 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+281], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, 2e+285], 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[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -1e281Initial program 54.6%
Taylor expanded in c around inf 74.5%
+-commutative74.5%
mul-1-neg74.5%
unsub-neg74.5%
unpow274.5%
times-frac79.8%
Simplified79.8%
associate-*r/79.8%
Applied egg-rr79.8%
Taylor expanded in b around 0 74.5%
+-commutative74.5%
mul-1-neg74.5%
associate-/l*74.5%
unpow274.5%
associate-*r/79.8%
*-commutative79.8%
associate-/l/79.8%
sub-neg79.8%
associate-/r/74.5%
*-commutative74.5%
associate-*r/79.8%
div-sub80.0%
associate-*r/80.0%
*-commutative80.0%
associate-/l*80.0%
Simplified80.0%
if -1e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e285Initial program 79.0%
*-un-lft-identity79.0%
add-sqr-sqrt79.0%
times-frac79.0%
hypot-def79.0%
hypot-def99.7%
Applied egg-rr99.7%
if 2e285 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 8.3%
Taylor expanded in c around 0 45.3%
+-commutative45.3%
mul-1-neg45.3%
unsub-neg45.3%
unpow245.3%
times-frac58.2%
Simplified58.2%
Final simplification89.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d)))
(t_1 (/ t_0 (+ (* c c) (* d d))))
(t_2 (/ 1.0 (hypot c d))))
(if (<= t_1 -1e+281)
(/ (- b (/ a (/ c d))) c)
(if (<= t_1 2e+285)
(* t_2 (/ t_0 (hypot c d)))
(- (* t_2 (/ b (/ (hypot c d) c))) (/ a d))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = t_0 / ((c * c) + (d * d));
double t_2 = 1.0 / hypot(c, d);
double tmp;
if (t_1 <= -1e+281) {
tmp = (b - (a / (c / d))) / c;
} else if (t_1 <= 2e+285) {
tmp = t_2 * (t_0 / hypot(c, d));
} else {
tmp = (t_2 * (b / (hypot(c, d) / c))) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = t_0 / ((c * c) + (d * d));
double t_2 = 1.0 / Math.hypot(c, d);
double tmp;
if (t_1 <= -1e+281) {
tmp = (b - (a / (c / d))) / c;
} else if (t_1 <= 2e+285) {
tmp = t_2 * (t_0 / Math.hypot(c, d));
} else {
tmp = (t_2 * (b / (Math.hypot(c, d) / c))) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (a * d) t_1 = t_0 / ((c * c) + (d * d)) t_2 = 1.0 / math.hypot(c, d) tmp = 0 if t_1 <= -1e+281: tmp = (b - (a / (c / d))) / c elif t_1 <= 2e+285: tmp = t_2 * (t_0 / math.hypot(c, d)) else: tmp = (t_2 * (b / (math.hypot(c, d) / c))) - (a / d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) t_2 = Float64(1.0 / hypot(c, d)) tmp = 0.0 if (t_1 <= -1e+281) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); elseif (t_1 <= 2e+285) tmp = Float64(t_2 * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(t_2 * Float64(b / Float64(hypot(c, d) / c))) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) - (a * d); t_1 = t_0 / ((c * c) + (d * d)); t_2 = 1.0 / hypot(c, d); tmp = 0.0; if (t_1 <= -1e+281) tmp = (b - (a / (c / d))) / c; elseif (t_1 <= 2e+285) tmp = t_2 * (t_0 / hypot(c, d)); else tmp = (t_2 * (b / (hypot(c, d) / c))) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+281], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[t$95$1, 2e+285], N[(t$95$2 * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
t_2 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+281}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+285}:\\
\;\;\;\;t_2 \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_2 \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -1e281Initial program 54.6%
Taylor expanded in c around inf 74.5%
+-commutative74.5%
mul-1-neg74.5%
unsub-neg74.5%
unpow274.5%
times-frac79.8%
Simplified79.8%
associate-*r/79.8%
Applied egg-rr79.8%
Taylor expanded in b around 0 74.5%
+-commutative74.5%
mul-1-neg74.5%
associate-/l*74.5%
unpow274.5%
associate-*r/79.8%
*-commutative79.8%
associate-/l/79.8%
sub-neg79.8%
associate-/r/74.5%
*-commutative74.5%
associate-*r/79.8%
div-sub80.0%
associate-*r/80.0%
*-commutative80.0%
associate-/l*80.0%
Simplified80.0%
if -1e281 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2e285Initial program 79.0%
*-un-lft-identity79.0%
add-sqr-sqrt79.0%
times-frac79.0%
hypot-def79.0%
hypot-def99.7%
Applied egg-rr99.7%
if 2e285 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 8.3%
div-sub6.5%
*-un-lft-identity6.5%
add-sqr-sqrt6.5%
times-frac6.5%
fma-neg6.5%
hypot-def6.5%
hypot-def9.2%
associate-/l*22.6%
add-sqr-sqrt22.6%
pow222.6%
hypot-def22.6%
Applied egg-rr22.6%
fma-neg22.6%
associate-/l*60.5%
associate-/r/60.5%
*-commutative60.5%
Simplified60.5%
Taylor expanded in d around inf 70.7%
Final simplification92.0%
(FPCore (a b c d)
:precision binary64
(if (<= d -4.35e+99)
(- (* (/ c d) (/ b d)) (/ a d))
(if (<= d -1e-104)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= d 2.7e+22)
(/ (- b (/ a (/ c d))) c)
(fma -1.0 (/ a d) (/ 1.0 (/ d (* c (/ b d)))))))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -4.35e+99) {
tmp = ((c / d) * (b / d)) - (a / d);
} else if (d <= -1e-104) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 2.7e+22) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = fma(-1.0, (a / d), (1.0 / (d / (c * (b / d)))));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (d <= -4.35e+99) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); elseif (d <= -1e-104) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 2.7e+22) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); else tmp = fma(-1.0, Float64(a / d), Float64(1.0 / Float64(d / Float64(c * Float64(b / d))))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[d, -4.35e+99], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1e-104], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.7e+22], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(-1.0 * N[(a / d), $MachinePrecision] + N[(1.0 / N[(d / N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.35 \cdot 10^{+99}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-104}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{+22}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \frac{a}{d}, \frac{1}{\frac{d}{c \cdot \frac{b}{d}}}\right)\\
\end{array}
\end{array}
if d < -4.3499999999999998e99Initial program 40.4%
Taylor expanded in c around 0 72.4%
+-commutative72.4%
mul-1-neg72.4%
unsub-neg72.4%
unpow272.4%
times-frac79.9%
Simplified79.9%
if -4.3499999999999998e99 < d < -9.99999999999999927e-105Initial program 77.7%
if -9.99999999999999927e-105 < d < 2.7000000000000002e22Initial program 70.7%
Taylor expanded in c around inf 84.5%
+-commutative84.5%
mul-1-neg84.5%
unsub-neg84.5%
unpow284.5%
times-frac83.0%
Simplified83.0%
associate-*r/83.9%
Applied egg-rr83.9%
Taylor expanded in b around 0 84.5%
+-commutative84.5%
mul-1-neg84.5%
associate-/l*83.7%
unpow283.7%
associate-*r/86.4%
*-commutative86.4%
associate-/l/83.0%
sub-neg83.0%
associate-/r/82.1%
*-commutative82.1%
associate-*r/83.9%
div-sub84.9%
associate-*r/89.1%
*-commutative89.1%
associate-/l*88.2%
Simplified88.2%
if 2.7000000000000002e22 < d Initial program 51.1%
Taylor expanded in c around 0 83.5%
fma-def83.5%
unpow283.5%
associate-/l*85.5%
Simplified85.5%
clear-num85.5%
inv-pow85.5%
associate-/l*87.1%
Applied egg-rr87.1%
unpow-187.1%
associate-/l/89.9%
Simplified89.9%
Final simplification85.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* (/ c d) (/ b d)) (/ a d))))
(if (<= d -2e+98)
t_0
(if (<= d -9.8e-105)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= d 5.8e+22) (/ (- b (/ a (/ c d))) c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (d <= -2e+98) {
tmp = t_0;
} else if (d <= -9.8e-105) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 5.8e+22) {
tmp = (b - (a / (c / 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 = ((c / d) * (b / d)) - (a / d)
if (d <= (-2d+98)) then
tmp = t_0
else if (d <= (-9.8d-105)) then
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d))
else if (d <= 5.8d+22) then
tmp = (b - (a / (c / 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 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (d <= -2e+98) {
tmp = t_0;
} else if (d <= -9.8e-105) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 5.8e+22) {
tmp = (b - (a / (c / d))) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c / d) * (b / d)) - (a / d) tmp = 0 if d <= -2e+98: tmp = t_0 elif d <= -9.8e-105: tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)) elif d <= 5.8e+22: tmp = (b - (a / (c / d))) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)) tmp = 0.0 if (d <= -2e+98) tmp = t_0; elseif (d <= -9.8e-105) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 5.8e+22) tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c / d) * (b / d)) - (a / d); tmp = 0.0; if (d <= -2e+98) tmp = t_0; elseif (d <= -9.8e-105) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); elseif (d <= 5.8e+22) tmp = (b - (a / (c / d))) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2e+98], t$95$0, If[LessEqual[d, -9.8e-105], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.8e+22], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -2 \cdot 10^{+98}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -9.8 \cdot 10^{-105}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{+22}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -2e98 or 5.8e22 < d Initial program 46.3%
Taylor expanded in c around 0 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
unpow278.5%
times-frac84.4%
Simplified84.4%
if -2e98 < d < -9.7999999999999999e-105Initial program 77.7%
if -9.7999999999999999e-105 < d < 5.8e22Initial program 70.7%
Taylor expanded in c around inf 84.5%
+-commutative84.5%
mul-1-neg84.5%
unsub-neg84.5%
unpow284.5%
times-frac83.0%
Simplified83.0%
associate-*r/83.9%
Applied egg-rr83.9%
Taylor expanded in b around 0 84.5%
+-commutative84.5%
mul-1-neg84.5%
associate-/l*83.7%
unpow283.7%
associate-*r/86.4%
*-commutative86.4%
associate-/l/83.0%
sub-neg83.0%
associate-/r/82.1%
*-commutative82.1%
associate-*r/83.9%
div-sub84.9%
associate-*r/89.1%
*-commutative89.1%
associate-/l*88.2%
Simplified88.2%
Final simplification85.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.8e-13) (not (<= d 9.5e+21))) (- (* (/ c d) (/ b d)) (/ a d)) (/ (- b (/ a (/ c d))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.8e-13) || !(d <= 9.5e+21)) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-4.8d-13)) .or. (.not. (d <= 9.5d+21))) then
tmp = ((c / d) * (b / d)) - (a / d)
else
tmp = (b - (a / (c / d))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.8e-13) || !(d <= 9.5e+21)) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.8e-13) or not (d <= 9.5e+21): tmp = ((c / d) * (b / d)) - (a / d) else: tmp = (b - (a / (c / d))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.8e-13) || !(d <= 9.5e+21)) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); else tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.8e-13) || ~((d <= 9.5e+21))) tmp = ((c / d) * (b / d)) - (a / d); else tmp = (b - (a / (c / d))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.8e-13], N[Not[LessEqual[d, 9.5e+21]], $MachinePrecision]], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{-13} \lor \neg \left(d \leq 9.5 \cdot 10^{+21}\right):\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if d < -4.7999999999999997e-13 or 9.500000000000001e21 < d Initial program 50.8%
Taylor expanded in c around 0 75.4%
+-commutative75.4%
mul-1-neg75.4%
unsub-neg75.4%
unpow275.4%
times-frac80.2%
Simplified80.2%
if -4.7999999999999997e-13 < d < 9.500000000000001e21Initial program 72.7%
Taylor expanded in c around inf 81.5%
+-commutative81.5%
mul-1-neg81.5%
unsub-neg81.5%
unpow281.5%
times-frac80.1%
Simplified80.1%
associate-*r/80.9%
Applied egg-rr80.9%
Taylor expanded in b around 0 81.5%
+-commutative81.5%
mul-1-neg81.5%
associate-/l*80.8%
unpow280.8%
associate-*r/83.1%
*-commutative83.1%
associate-/l/80.2%
sub-neg80.2%
associate-/r/79.4%
*-commutative79.4%
associate-*r/80.9%
div-sub81.8%
associate-*r/85.4%
*-commutative85.4%
associate-/l*84.6%
Simplified84.6%
Final simplification82.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.8e+86) (not (<= d 2e+22))) (/ (- a) d) (/ (- b (/ a (/ c d))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.8e+86) || !(d <= 2e+22)) {
tmp = -a / d;
} else {
tmp = (b - (a / (c / d))) / 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 <= (-3.8d+86)) .or. (.not. (d <= 2d+22))) then
tmp = -a / d
else
tmp = (b - (a / (c / d))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.8e+86) || !(d <= 2e+22)) {
tmp = -a / d;
} else {
tmp = (b - (a / (c / d))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.8e+86) or not (d <= 2e+22): tmp = -a / d else: tmp = (b - (a / (c / d))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.8e+86) || !(d <= 2e+22)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(b - Float64(a / Float64(c / d))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.8e+86) || ~((d <= 2e+22))) tmp = -a / d; else tmp = (b - (a / (c / d))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.8e+86], N[Not[LessEqual[d, 2e+22]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.8 \cdot 10^{+86} \lor \neg \left(d \leq 2 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a}{\frac{c}{d}}}{c}\\
\end{array}
\end{array}
if d < -3.79999999999999978e86 or 2e22 < d Initial program 47.3%
Taylor expanded in c around 0 72.9%
associate-*r/72.9%
neg-mul-172.9%
Simplified72.9%
if -3.79999999999999978e86 < d < 2e22Initial program 72.2%
Taylor expanded in c around inf 75.7%
+-commutative75.7%
mul-1-neg75.7%
unsub-neg75.7%
unpow275.7%
times-frac75.8%
Simplified75.8%
associate-*r/76.5%
Applied egg-rr76.5%
Taylor expanded in b around 0 75.7%
+-commutative75.7%
mul-1-neg75.7%
associate-/l*75.1%
unpow275.1%
associate-*r/77.7%
*-commutative77.7%
associate-/l/75.8%
sub-neg75.8%
associate-/r/75.2%
*-commutative75.2%
associate-*r/76.5%
div-sub77.2%
associate-*r/80.4%
*-commutative80.4%
associate-/l*79.7%
Simplified79.7%
Final simplification76.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.15e-12) (not (<= d 1.55e+22))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.15e-12) || !(d <= 1.55e+22)) {
tmp = -a / d;
} else {
tmp = 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-12)) .or. (.not. (d <= 1.55d+22))) then
tmp = -a / d
else
tmp = 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-12) || !(d <= 1.55e+22)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.15e-12) or not (d <= 1.55e+22): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.15e-12) || !(d <= 1.55e+22)) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.15e-12) || ~((d <= 1.55e+22))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.15e-12], N[Not[LessEqual[d, 1.55e+22]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.15 \cdot 10^{-12} \lor \neg \left(d \leq 1.55 \cdot 10^{+22}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.14999999999999995e-12 or 1.5500000000000001e22 < d Initial program 50.8%
Taylor expanded in c around 0 68.2%
associate-*r/68.2%
neg-mul-168.2%
Simplified68.2%
if -1.14999999999999995e-12 < d < 1.5500000000000001e22Initial program 72.7%
Taylor expanded in c around inf 68.6%
Final simplification68.4%
(FPCore (a b c d) :precision binary64 (if (<= d -1.15e+146) (/ a d) (if (<= d 1.45e+133) (/ b c) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if (d <= -1.15e+146) {
tmp = a / d;
} else if (d <= 1.45e+133) {
tmp = b / 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 <= (-1.15d+146)) then
tmp = a / d
else if (d <= 1.45d+133) then
tmp = b / 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 <= -1.15e+146) {
tmp = a / d;
} else if (d <= 1.45e+133) {
tmp = b / c;
} else {
tmp = a / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if d <= -1.15e+146: tmp = a / d elif d <= 1.45e+133: tmp = b / c else: tmp = a / d return tmp
function code(a, b, c, d) tmp = 0.0 if (d <= -1.15e+146) tmp = Float64(a / d); elseif (d <= 1.45e+133) tmp = Float64(b / c); else tmp = Float64(a / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (d <= -1.15e+146) tmp = a / d; elseif (d <= 1.45e+133) tmp = b / c; else tmp = a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[d, -1.15e+146], N[(a / d), $MachinePrecision], If[LessEqual[d, 1.45e+133], N[(b / c), $MachinePrecision], N[(a / d), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.15 \cdot 10^{+146}:\\
\;\;\;\;\frac{a}{d}\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{+133}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{d}\\
\end{array}
\end{array}
if d < -1.15e146 or 1.4500000000000001e133 < d Initial program 37.7%
Taylor expanded in b around 0 36.5%
mul-1-neg36.5%
distribute-rgt-neg-out36.5%
Simplified36.5%
Taylor expanded in c around 0 36.5%
unpow236.5%
Simplified36.5%
associate-/l*39.0%
frac-2neg39.0%
neg-sub039.0%
metadata-eval39.0%
add-sqr-sqrt18.9%
sqrt-unprod7.7%
sqr-neg7.7%
sqrt-prod17.1%
add-sqr-sqrt31.7%
neg-sub031.7%
sub-neg31.7%
add-sqr-sqrt14.6%
sqrt-unprod6.3%
sqr-neg6.3%
sqrt-prod20.0%
add-sqr-sqrt39.0%
flip--83.1%
neg-sub083.1%
add-sqr-sqrt37.4%
sqrt-unprod36.0%
sqr-neg36.0%
sqrt-prod16.6%
add-sqr-sqrt30.9%
expm1-log1p-u30.8%
Applied egg-rr31.6%
expm1-def30.8%
expm1-log1p30.9%
Simplified30.9%
if -1.15e146 < d < 1.4500000000000001e133Initial program 70.6%
Taylor expanded in c around inf 56.0%
Final simplification49.4%
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
return a / 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 / d
end function
public static double code(double a, double b, double c, double d) {
return a / d;
}
def code(a, b, c, d): return a / d
function code(a, b, c, d) return Float64(a / d) end
function tmp = code(a, b, c, d) tmp = a / d; end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{d}
\end{array}
Initial program 62.0%
Taylor expanded in b around 0 41.6%
mul-1-neg41.6%
distribute-rgt-neg-out41.6%
Simplified41.6%
Taylor expanded in c around 0 27.9%
unpow227.9%
Simplified27.9%
associate-/l*31.7%
frac-2neg31.7%
neg-sub029.8%
metadata-eval29.8%
add-sqr-sqrt15.3%
sqrt-unprod12.8%
sqr-neg12.8%
sqrt-prod7.2%
add-sqr-sqrt13.4%
neg-sub013.4%
sub-neg13.4%
add-sqr-sqrt6.2%
sqrt-unprod12.0%
sqr-neg12.0%
sqrt-prod14.4%
add-sqr-sqrt29.8%
flip--43.0%
neg-sub043.0%
add-sqr-sqrt20.7%
sqrt-unprod21.5%
sqr-neg21.5%
sqrt-prod5.6%
add-sqr-sqrt11.0%
expm1-log1p-u10.6%
Applied egg-rr14.8%
expm1-def10.6%
expm1-log1p11.0%
Simplified11.0%
Final simplification11.0%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (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 = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (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 = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (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(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * 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 = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (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[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * 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{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023224
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))