
(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 6 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 (/ (- (* c (/ b d)) a) d)))
(if (<= d -6.5e+163)
t_0
(if (<= d -2.8e-156)
(/ (- (* b c) (* a d)) (+ (* c c) (* d d)))
(if (<= d 4.6e+48) (/ (- b (* (/ d c) a)) c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -6.5e+163) {
tmp = t_0;
} else if (d <= -2.8e-156) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 4.6e+48) {
tmp = (b - ((d / c) * a)) / 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 * (b / d)) - a) / d
if (d <= (-6.5d+163)) then
tmp = t_0
else if (d <= (-2.8d-156)) then
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d))
else if (d <= 4.6d+48) then
tmp = (b - ((d / c) * a)) / 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 * (b / d)) - a) / d;
double tmp;
if (d <= -6.5e+163) {
tmp = t_0;
} else if (d <= -2.8e-156) {
tmp = ((b * c) - (a * d)) / ((c * c) + (d * d));
} else if (d <= 4.6e+48) {
tmp = (b - ((d / c) * a)) / c;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * (b / d)) - a) / d tmp = 0 if d <= -6.5e+163: tmp = t_0 elif d <= -2.8e-156: tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)) elif d <= 4.6e+48: tmp = (b - ((d / c) * a)) / c else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -6.5e+163) tmp = t_0; elseif (d <= -2.8e-156) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 4.6e+48) tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * (b / d)) - a) / d; tmp = 0.0; if (d <= -6.5e+163) tmp = t_0; elseif (d <= -2.8e-156) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); elseif (d <= 4.6e+48) tmp = (b - ((d / c) * a)) / c; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.5e+163], t$95$0, If[LessEqual[d, -2.8e-156], 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, 4.6e+48], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{+163}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{-156}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 4.6 \cdot 10^{+48}:\\
\;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -6.4999999999999998e163 or 4.6e48 < d Initial program 39.5%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6478.0
Applied rewrites78.0%
Applied rewrites83.2%
if -6.4999999999999998e163 < d < -2.8000000000000002e-156Initial program 77.6%
if -2.8000000000000002e-156 < d < 4.6e48Initial program 70.1%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6484.7
Applied rewrites84.7%
Applied rewrites86.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -7e-29) (not (<= d 4.6e+48))) (/ (- (* c (/ b d)) a) d) (/ (- b (* (/ d c) a)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7e-29) || !(d <= 4.6e+48)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-7d-29)) .or. (.not. (d <= 4.6d+48))) then
tmp = ((c * (b / d)) - a) / d
else
tmp = (b - ((d / c) * a)) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -7e-29) || !(d <= 4.6e+48)) {
tmp = ((c * (b / d)) - a) / d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -7e-29) or not (d <= 4.6e+48): tmp = ((c * (b / d)) - a) / d else: tmp = (b - ((d / c) * a)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -7e-29) || !(d <= 4.6e+48)) tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); else tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -7e-29) || ~((d <= 4.6e+48))) tmp = ((c * (b / d)) - a) / d; else tmp = (b - ((d / c) * a)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -7e-29], N[Not[LessEqual[d, 4.6e+48]], $MachinePrecision]], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -7 \cdot 10^{-29} \lor \neg \left(d \leq 4.6 \cdot 10^{+48}\right):\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
\end{array}
\end{array}
if d < -6.9999999999999995e-29 or 4.6e48 < d Initial program 50.9%
Taylor expanded in c around 0
+-commutativeN/A
fp-cancel-sign-sub-invN/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6474.6
Applied rewrites74.6%
Applied rewrites79.1%
if -6.9999999999999995e-29 < d < 4.6e48Initial program 70.9%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6481.6
Applied rewrites81.6%
Applied rewrites83.1%
Final simplification81.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.8e-25) (not (<= d 1.95e+164))) (/ a (- d)) (/ (- b (* (/ d c) a)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.8e-25) || !(d <= 1.95e+164)) {
tmp = a / -d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-4.8d-25)) .or. (.not. (d <= 1.95d+164))) then
tmp = a / -d
else
tmp = (b - ((d / c) * a)) / 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-25) || !(d <= 1.95e+164)) {
tmp = a / -d;
} else {
tmp = (b - ((d / c) * a)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.8e-25) or not (d <= 1.95e+164): tmp = a / -d else: tmp = (b - ((d / c) * a)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.8e-25) || !(d <= 1.95e+164)) tmp = Float64(a / Float64(-d)); else tmp = Float64(Float64(b - Float64(Float64(d / c) * a)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.8e-25) || ~((d <= 1.95e+164))) tmp = a / -d; else tmp = (b - ((d / c) * a)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.8e-25], N[Not[LessEqual[d, 1.95e+164]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(N[(b - N[(N[(d / c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{-25} \lor \neg \left(d \leq 1.95 \cdot 10^{+164}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{d}{c} \cdot a}{c}\\
\end{array}
\end{array}
if d < -4.80000000000000018e-25 or 1.94999999999999993e164 < d Initial program 52.0%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.7
Applied rewrites76.7%
if -4.80000000000000018e-25 < d < 1.94999999999999993e164Initial program 67.2%
Taylor expanded in c around inf
lower-/.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6475.0
Applied rewrites75.0%
Applied rewrites77.8%
Final simplification77.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- d))))
(if (<= d -6.5e+163)
t_0
(if (<= d -9.5e-76)
(* (- a) (/ d (fma d d (* c c))))
(if (<= d 1.95e+164) (/ b c) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -6.5e+163) {
tmp = t_0;
} else if (d <= -9.5e-76) {
tmp = -a * (d / fma(d, d, (c * c)));
} else if (d <= 1.95e+164) {
tmp = b / c;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(a / Float64(-d)) tmp = 0.0 if (d <= -6.5e+163) tmp = t_0; elseif (d <= -9.5e-76) tmp = Float64(Float64(-a) * Float64(d / fma(d, d, Float64(c * c)))); elseif (d <= 1.95e+164) tmp = Float64(b / c); else tmp = t_0; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -6.5e+163], t$95$0, If[LessEqual[d, -9.5e-76], N[((-a) * N[(d / N[(d * d + N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.95e+164], N[(b / c), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{+163}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq -9.5 \cdot 10^{-76}:\\
\;\;\;\;\left(-a\right) \cdot \frac{d}{\mathsf{fma}\left(d, d, c \cdot c\right)}\\
\mathbf{elif}\;d \leq 1.95 \cdot 10^{+164}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d < -6.4999999999999998e163 or 1.94999999999999993e164 < d Initial program 38.0%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6484.6
Applied rewrites84.6%
if -6.4999999999999998e163 < d < -9.49999999999999984e-76Initial program 77.3%
Taylor expanded in a around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
+-commutativeN/A
unpow2N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6465.3
Applied rewrites65.3%
if -9.49999999999999984e-76 < d < 1.94999999999999993e164Initial program 67.3%
Taylor expanded in c around inf
lower-/.f6461.6
Applied rewrites61.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -4.8e-31) (not (<= d 1.95e+164))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -4.8e-31) || !(d <= 1.95e+164)) {
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 <= (-4.8d-31)) .or. (.not. (d <= 1.95d+164))) 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 <= -4.8e-31) || !(d <= 1.95e+164)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -4.8e-31) or not (d <= 1.95e+164): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -4.8e-31) || !(d <= 1.95e+164)) tmp = Float64(a / Float64(-d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -4.8e-31) || ~((d <= 1.95e+164))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -4.8e-31], N[Not[LessEqual[d, 1.95e+164]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -4.8 \cdot 10^{-31} \lor \neg \left(d \leq 1.95 \cdot 10^{+164}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -4.8e-31 or 1.94999999999999993e164 < d Initial program 52.0%
Taylor expanded in c around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6476.7
Applied rewrites76.7%
if -4.8e-31 < d < 1.94999999999999993e164Initial program 67.2%
Taylor expanded in c around inf
lower-/.f6459.8
Applied rewrites59.8%
Final simplification67.1%
(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 60.7%
Taylor expanded in c around inf
lower-/.f6444.9
Applied rewrites44.9%
(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 2024343
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(! :herbie-platform default (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))))