
(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 9 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 (- (* b c) (* a d))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (<= t_1 (- INFINITY))
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(/ (- a) (/ (pow (hypot c d) 2.0) d)))
(if (<= t_1 INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (- (* b (/ c 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 <= -((double) INFINITY)) {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / (pow(hypot(c, d), 2.0) / d)));
} else if (t_1 <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = ((b * (c / 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 <= Float64(-Inf)) tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / Float64((hypot(c, d) ^ 2.0) / d))); elseif (t_1 <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return 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, (-Infinity)], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / d), $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[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $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 -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
\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{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 19.5%
div-sub10.4%
*-commutative10.4%
add-sqr-sqrt10.4%
times-frac47.6%
fma-neg47.6%
hypot-def47.6%
hypot-def56.0%
associate-/l*78.1%
add-sqr-sqrt78.1%
pow278.1%
hypot-def78.1%
Applied egg-rr78.1%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 82.1%
*-un-lft-identity82.1%
add-sqr-sqrt82.1%
times-frac82.0%
hypot-def82.0%
hypot-def97.1%
Applied egg-rr97.1%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
*-commutative0.0%
add-sqr-sqrt0.0%
times-frac1.3%
fma-neg1.3%
hypot-def1.3%
hypot-def33.3%
associate-/l*38.3%
add-sqr-sqrt38.3%
pow238.3%
hypot-def38.3%
Applied egg-rr38.3%
Taylor expanded in c around 0 56.5%
neg-mul-156.5%
unpow256.5%
associate-*l/59.2%
+-commutative59.2%
sub-neg59.2%
*-commutative59.2%
associate-/r*63.0%
Simplified63.0%
associate-*r/63.5%
sub-div63.5%
Applied egg-rr63.5%
Final simplification90.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d)))
(t_1 (- (* b c) (* a d)))
(t_2 (/ t_1 (+ (* c c) (* d d)))))
(if (<= t_2 (- INFINITY))
(- (* t_0 (/ b (/ (hypot c d) c))) (/ d (/ (pow (hypot c d) 2.0) a)))
(if (<= t_2 INFINITY)
(* t_0 (/ t_1 (hypot c d)))
(/ (- (* b (/ c d)) a) d)))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = (b * c) - (a * d);
double t_2 = t_1 / ((c * c) + (d * d));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (t_0 * (b / (hypot(c, d) / c))) - (d / (pow(hypot(c, d), 2.0) / a));
} else if (t_2 <= ((double) INFINITY)) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = ((b * (c / d)) - 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 = (b * c) - (a * d);
double t_2 = t_1 / ((c * c) + (d * d));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = (t_0 * (b / (Math.hypot(c, d) / c))) - (d / (Math.pow(Math.hypot(c, d), 2.0) / a));
} else if (t_2 <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (t_1 / Math.hypot(c, d));
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = 1.0 / math.hypot(c, d) t_1 = (b * c) - (a * d) t_2 = t_1 / ((c * c) + (d * d)) tmp = 0 if t_2 <= -math.inf: tmp = (t_0 * (b / (math.hypot(c, d) / c))) - (d / (math.pow(math.hypot(c, d), 2.0) / a)) elif t_2 <= math.inf: tmp = t_0 * (t_1 / math.hypot(c, d)) else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(Float64(b * c) - Float64(a * d)) t_2 = Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(t_0 * Float64(b / Float64(hypot(c, d) / c))) - Float64(d / Float64((hypot(c, d) ^ 2.0) / a))); elseif (t_2 <= Inf) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = 1.0 / hypot(c, d); t_1 = (b * c) - (a * d); t_2 = t_1 / ((c * c) + (d * d)); tmp = 0.0; if (t_2 <= -Inf) tmp = (t_0 * (b / (hypot(c, d) / c))) - (d / ((hypot(c, d) ^ 2.0) / a)); elseif (t_2 <= Inf) tmp = t_0 * (t_1 / hypot(c, d)); else tmp = ((b * (c / d)) - 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[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(t$95$0 * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, Infinity], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := b \cdot c - a \cdot d\\
t_2 := \frac{t_1}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_0 \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{d}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{a}}\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 19.5%
div-sub10.4%
*-un-lft-identity10.4%
add-sqr-sqrt10.4%
times-frac10.4%
fma-neg10.4%
hypot-def10.4%
hypot-def19.3%
associate-/l*41.3%
add-sqr-sqrt41.3%
pow241.3%
hypot-def41.3%
Applied egg-rr41.3%
fma-neg41.3%
associate-/l*77.7%
associate-/l*55.7%
*-commutative55.7%
associate-/l*77.5%
Simplified77.5%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 82.1%
*-un-lft-identity82.1%
add-sqr-sqrt82.1%
times-frac82.0%
hypot-def82.0%
hypot-def97.1%
Applied egg-rr97.1%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
*-commutative0.0%
add-sqr-sqrt0.0%
times-frac1.3%
fma-neg1.3%
hypot-def1.3%
hypot-def33.3%
associate-/l*38.3%
add-sqr-sqrt38.3%
pow238.3%
hypot-def38.3%
Applied egg-rr38.3%
Taylor expanded in c around 0 56.5%
neg-mul-156.5%
unpow256.5%
associate-*l/59.2%
+-commutative59.2%
sub-neg59.2%
*-commutative59.2%
associate-/r*63.0%
Simplified63.0%
associate-*r/63.5%
sub-div63.5%
Applied egg-rr63.5%
Final simplification90.2%
(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 (- INFINITY))
(- (/ b c) (* (/ a c) (/ d c)))
(if (<= t_1 -1e-245)
t_1
(if (<= t_1 INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (- (* b (/ c 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 <= -((double) INFINITY)) {
tmp = (b / c) - ((a / c) * (d / c));
} else if (t_1 <= -1e-245) {
tmp = t_1;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = ((b * (c / 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 <= -Double.POSITIVE_INFINITY) {
tmp = (b / c) - ((a / c) * (d / c));
} else if (t_1 <= -1e-245) {
tmp = t_1;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = ((b * (c / 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 <= -math.inf: tmp = (b / c) - ((a / c) * (d / c)) elif t_1 <= -1e-245: tmp = t_1 elif t_1 <= math.inf: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = ((b * (c / 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 <= Float64(-Inf)) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))); elseif (t_1 <= -1e-245) tmp = t_1; elseif (t_1 <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - 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 <= -Inf) tmp = (b / c) - ((a / c) * (d / c)); elseif (t_1 <= -1e-245) tmp = t_1; elseif (t_1 <= Inf) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = ((b * (c / 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, (-Infinity)], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-245], t$95$1, 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[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $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 -\infty:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-245}:\\
\;\;\;\;t_1\\
\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{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 19.5%
Taylor expanded in c around inf 56.0%
+-commutative56.0%
mul-1-neg56.0%
unsub-neg56.0%
unpow256.0%
times-frac71.0%
Simplified71.0%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -9.9999999999999993e-246Initial program 99.6%
if -9.9999999999999993e-246 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 77.6%
*-un-lft-identity77.6%
add-sqr-sqrt77.6%
times-frac77.7%
hypot-def77.7%
hypot-def96.6%
Applied egg-rr96.6%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
*-commutative0.0%
add-sqr-sqrt0.0%
times-frac1.3%
fma-neg1.3%
hypot-def1.3%
hypot-def33.3%
associate-/l*38.3%
add-sqr-sqrt38.3%
pow238.3%
hypot-def38.3%
Applied egg-rr38.3%
Taylor expanded in c around 0 56.5%
neg-mul-156.5%
unpow256.5%
associate-*l/59.2%
+-commutative59.2%
sub-neg59.2%
*-commutative59.2%
associate-/r*63.0%
Simplified63.0%
associate-*r/63.5%
sub-div63.5%
Applied egg-rr63.5%
Final simplification90.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d)))
(t_1 (- (/ b c) (* (/ a c) (/ d c))))
(t_2 (/ (- (* b (/ c d)) a) d)))
(if (<= c -2.4e+73)
t_1
(if (<= c -1.45e-114)
(/ t_0 (fma c c (* d d)))
(if (<= c 6.8e-29)
t_2
(if (<= c 4.3e+24)
(/ t_0 (+ (* c c) (* d d)))
(if (<= c 2.25e+52) t_2 t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double t_1 = (b / c) - ((a / c) * (d / c));
double t_2 = ((b * (c / d)) - a) / d;
double tmp;
if (c <= -2.4e+73) {
tmp = t_1;
} else if (c <= -1.45e-114) {
tmp = t_0 / fma(c, c, (d * d));
} else if (c <= 6.8e-29) {
tmp = t_2;
} else if (c <= 4.3e+24) {
tmp = t_0 / ((c * c) + (d * d));
} else if (c <= 2.25e+52) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) t_1 = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))) t_2 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (c <= -2.4e+73) tmp = t_1; elseif (c <= -1.45e-114) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); elseif (c <= 6.8e-29) tmp = t_2; elseif (c <= 4.3e+24) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 2.25e+52) tmp = t_2; else tmp = t_1; end return 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[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[c, -2.4e+73], t$95$1, If[LessEqual[c, -1.45e-114], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 6.8e-29], t$95$2, If[LessEqual[c, 4.3e+24], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.25e+52], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
t_1 := \frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
t_2 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{+73}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.45 \cdot 10^{-114}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{elif}\;c \leq 6.8 \cdot 10^{-29}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq 4.3 \cdot 10^{+24}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 2.25 \cdot 10^{+52}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -2.40000000000000002e73 or 2.25e52 < c Initial program 53.2%
Taylor expanded in c around inf 78.4%
+-commutative78.4%
mul-1-neg78.4%
unsub-neg78.4%
unpow278.4%
times-frac86.6%
Simplified86.6%
if -2.40000000000000002e73 < c < -1.44999999999999998e-114Initial program 83.6%
fma-def83.6%
Simplified83.6%
if -1.44999999999999998e-114 < c < 6.79999999999999945e-29 or 4.29999999999999987e24 < c < 2.25e52Initial program 63.9%
div-sub58.6%
*-commutative58.6%
add-sqr-sqrt58.6%
times-frac57.9%
fma-neg57.9%
hypot-def57.9%
hypot-def61.7%
associate-/l*67.3%
add-sqr-sqrt67.3%
pow267.3%
hypot-def67.3%
Applied egg-rr67.3%
Taylor expanded in c around 0 82.4%
neg-mul-182.4%
unpow282.4%
associate-*l/83.5%
+-commutative83.5%
sub-neg83.5%
*-commutative83.5%
associate-/r*87.3%
Simplified87.3%
associate-*r/90.1%
sub-div90.2%
Applied egg-rr90.2%
if 6.79999999999999945e-29 < c < 4.29999999999999987e24Initial program 99.9%
Final simplification88.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (* (/ a c) (/ d c))))
(t_2 (/ (- (* b (/ c d)) a) d)))
(if (<= c -2.4e+80)
t_1
(if (<= c -1.5e-115)
t_0
(if (<= c 8.4e-35)
t_2
(if (<= c 4.3e+24) t_0 (if (<= c 2.25e+52) t_2 t_1)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - ((a / c) * (d / c));
double t_2 = ((b * (c / d)) - a) / d;
double tmp;
if (c <= -2.4e+80) {
tmp = t_1;
} else if (c <= -1.5e-115) {
tmp = t_0;
} else if (c <= 8.4e-35) {
tmp = t_2;
} else if (c <= 4.3e+24) {
tmp = t_0;
} else if (c <= 2.25e+52) {
tmp = t_2;
} 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) :: t_2
real(8) :: tmp
t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d))
t_1 = (b / c) - ((a / c) * (d / c))
t_2 = ((b * (c / d)) - a) / d
if (c <= (-2.4d+80)) then
tmp = t_1
else if (c <= (-1.5d-115)) then
tmp = t_0
else if (c <= 8.4d-35) then
tmp = t_2
else if (c <= 4.3d+24) then
tmp = t_0
else if (c <= 2.25d+52) then
tmp = t_2
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 * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = (b / c) - ((a / c) * (d / c));
double t_2 = ((b * (c / d)) - a) / d;
double tmp;
if (c <= -2.4e+80) {
tmp = t_1;
} else if (c <= -1.5e-115) {
tmp = t_0;
} else if (c <= 8.4e-35) {
tmp = t_2;
} else if (c <= 4.3e+24) {
tmp = t_0;
} else if (c <= 2.25e+52) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) t_1 = (b / c) - ((a / c) * (d / c)) t_2 = ((b * (c / d)) - a) / d tmp = 0 if c <= -2.4e+80: tmp = t_1 elif c <= -1.5e-115: tmp = t_0 elif c <= 8.4e-35: tmp = t_2 elif c <= 4.3e+24: tmp = t_0 elif c <= 2.25e+52: tmp = t_2 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))) t_2 = Float64(Float64(Float64(b * Float64(c / d)) - a) / d) tmp = 0.0 if (c <= -2.4e+80) tmp = t_1; elseif (c <= -1.5e-115) tmp = t_0; elseif (c <= 8.4e-35) tmp = t_2; elseif (c <= 4.3e+24) tmp = t_0; elseif (c <= 2.25e+52) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); t_1 = (b / c) - ((a / c) * (d / c)); t_2 = ((b * (c / d)) - a) / d; tmp = 0.0; if (c <= -2.4e+80) tmp = t_1; elseif (c <= -1.5e-115) tmp = t_0; elseif (c <= 8.4e-35) tmp = t_2; elseif (c <= 4.3e+24) tmp = t_0; elseif (c <= 2.25e+52) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[c, -2.4e+80], t$95$1, If[LessEqual[c, -1.5e-115], t$95$0, If[LessEqual[c, 8.4e-35], t$95$2, If[LessEqual[c, 4.3e+24], t$95$0, If[LessEqual[c, 2.25e+52], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
t_2 := \frac{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;c \leq -2.4 \cdot 10^{+80}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -1.5 \cdot 10^{-115}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 8.4 \cdot 10^{-35}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq 4.3 \cdot 10^{+24}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 2.25 \cdot 10^{+52}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -2.39999999999999979e80 or 2.25e52 < c Initial program 53.2%
Taylor expanded in c around inf 78.4%
+-commutative78.4%
mul-1-neg78.4%
unsub-neg78.4%
unpow278.4%
times-frac86.6%
Simplified86.6%
if -2.39999999999999979e80 < c < -1.5000000000000001e-115 or 8.3999999999999999e-35 < c < 4.29999999999999987e24Initial program 87.0%
if -1.5000000000000001e-115 < c < 8.3999999999999999e-35 or 4.29999999999999987e24 < c < 2.25e52Initial program 63.9%
div-sub58.6%
*-commutative58.6%
add-sqr-sqrt58.6%
times-frac57.9%
fma-neg57.9%
hypot-def57.9%
hypot-def61.7%
associate-/l*67.3%
add-sqr-sqrt67.3%
pow267.3%
hypot-def67.3%
Applied egg-rr67.3%
Taylor expanded in c around 0 82.4%
neg-mul-182.4%
unpow282.4%
associate-*l/83.5%
+-commutative83.5%
sub-neg83.5%
*-commutative83.5%
associate-/r*87.3%
Simplified87.3%
associate-*r/90.1%
sub-div90.2%
Applied egg-rr90.2%
Final simplification88.1%
(FPCore (a b c d)
:precision binary64
(if (or (<= c -0.96)
(not (or (<= c 1.4e-23) (and (not (<= c 2.05e+24)) (<= c 2.2e+52)))))
(- (/ b c) (* (/ a c) (/ d c)))
(/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -0.96) || !((c <= 1.4e-23) || (!(c <= 2.05e+24) && (c <= 2.2e+52)))) {
tmp = (b / c) - ((a / c) * (d / c));
} else {
tmp = ((b * (c / d)) - 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 ((c <= (-0.96d0)) .or. (.not. (c <= 1.4d-23) .or. (.not. (c <= 2.05d+24)) .and. (c <= 2.2d+52))) then
tmp = (b / c) - ((a / c) * (d / c))
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -0.96) || !((c <= 1.4e-23) || (!(c <= 2.05e+24) && (c <= 2.2e+52)))) {
tmp = (b / c) - ((a / c) * (d / c));
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -0.96) or not ((c <= 1.4e-23) or (not (c <= 2.05e+24) and (c <= 2.2e+52))): tmp = (b / c) - ((a / c) * (d / c)) else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -0.96) || !((c <= 1.4e-23) || (!(c <= 2.05e+24) && (c <= 2.2e+52)))) tmp = Float64(Float64(b / c) - Float64(Float64(a / c) * Float64(d / c))); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -0.96) || ~(((c <= 1.4e-23) || (~((c <= 2.05e+24)) && (c <= 2.2e+52))))) tmp = (b / c) - ((a / c) * (d / c)); else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -0.96], N[Not[Or[LessEqual[c, 1.4e-23], And[N[Not[LessEqual[c, 2.05e+24]], $MachinePrecision], LessEqual[c, 2.2e+52]]]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(a / c), $MachinePrecision] * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -0.96 \lor \neg \left(c \leq 1.4 \cdot 10^{-23} \lor \neg \left(c \leq 2.05 \cdot 10^{+24}\right) \land c \leq 2.2 \cdot 10^{+52}\right):\\
\;\;\;\;\frac{b}{c} - \frac{a}{c} \cdot \frac{d}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -0.95999999999999996 or 1.3999999999999999e-23 < c < 2.05e24 or 2.2e52 < c Initial program 60.3%
Taylor expanded in c around inf 75.1%
+-commutative75.1%
mul-1-neg75.1%
unsub-neg75.1%
unpow275.1%
times-frac81.5%
Simplified81.5%
if -0.95999999999999996 < c < 1.3999999999999999e-23 or 2.05e24 < c < 2.2e52Initial program 68.6%
div-sub64.4%
*-commutative64.4%
add-sqr-sqrt64.4%
times-frac63.9%
fma-neg63.9%
hypot-def63.9%
hypot-def67.6%
associate-/l*72.2%
add-sqr-sqrt72.2%
pow272.2%
hypot-def72.2%
Applied egg-rr72.2%
Taylor expanded in c around 0 79.9%
neg-mul-179.9%
unpow279.9%
associate-*l/80.9%
+-commutative80.9%
sub-neg80.9%
*-commutative80.9%
associate-/r*83.9%
Simplified83.9%
associate-*r/86.9%
sub-div86.9%
Applied egg-rr86.9%
Final simplification84.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -6.2e+65) (not (<= c 6.2e+47))) (/ b c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -6.2e+65) || !(c <= 6.2e+47)) {
tmp = b / c;
} else {
tmp = ((b * (c / d)) - 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 ((c <= (-6.2d+65)) .or. (.not. (c <= 6.2d+47))) then
tmp = b / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -6.2e+65) || !(c <= 6.2e+47)) {
tmp = b / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -6.2e+65) or not (c <= 6.2e+47): tmp = b / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -6.2e+65) || !(c <= 6.2e+47)) tmp = Float64(b / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -6.2e+65) || ~((c <= 6.2e+47))) tmp = b / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -6.2e+65], N[Not[LessEqual[c, 6.2e+47]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6.2 \cdot 10^{+65} \lor \neg \left(c \leq 6.2 \cdot 10^{+47}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -6.19999999999999981e65 or 6.2000000000000001e47 < c Initial program 53.5%
Taylor expanded in c around inf 75.0%
if -6.19999999999999981e65 < c < 6.2000000000000001e47Initial program 71.8%
div-sub68.3%
*-commutative68.3%
add-sqr-sqrt68.3%
times-frac67.9%
fma-neg67.9%
hypot-def67.9%
hypot-def71.7%
associate-/l*76.1%
add-sqr-sqrt76.1%
pow276.1%
hypot-def76.1%
Applied egg-rr76.1%
Taylor expanded in c around 0 72.6%
neg-mul-172.6%
unpow272.6%
associate-*l/73.4%
+-commutative73.4%
sub-neg73.4%
*-commutative73.4%
associate-/r*76.1%
Simplified76.1%
associate-*r/79.1%
sub-div79.1%
Applied egg-rr79.1%
Final simplification77.5%
(FPCore (a b c d) :precision binary64 (if (<= c -2e+32) (/ b c) (if (<= c 55000.0) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -2e+32) {
tmp = b / c;
} else if (c <= 55000.0) {
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 (c <= (-2d+32)) then
tmp = b / c
else if (c <= 55000.0d0) 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 (c <= -2e+32) {
tmp = b / c;
} else if (c <= 55000.0) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -2e+32: tmp = b / c elif c <= 55000.0: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -2e+32) tmp = Float64(b / c); elseif (c <= 55000.0) 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 (c <= -2e+32) tmp = b / c; elseif (c <= 55000.0) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -2e+32], N[(b / c), $MachinePrecision], If[LessEqual[c, 55000.0], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2 \cdot 10^{+32}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 55000:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.00000000000000011e32 or 55000 < c Initial program 55.9%
Taylor expanded in c around inf 70.0%
if -2.00000000000000011e32 < c < 55000Initial program 72.5%
Taylor expanded in c around 0 68.9%
associate-*r/68.9%
neg-mul-168.9%
Simplified68.9%
Final simplification69.4%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / 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 = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 64.5%
Taylor expanded in c around inf 42.4%
Final simplification42.4%
(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 2023274
(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))))