Average Error: 26.4 → 26.4
Time: 4.3s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot c - a \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot c - a \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r105230 = b;
        double r105231 = c;
        double r105232 = r105230 * r105231;
        double r105233 = a;
        double r105234 = d;
        double r105235 = r105233 * r105234;
        double r105236 = r105232 - r105235;
        double r105237 = r105231 * r105231;
        double r105238 = r105234 * r105234;
        double r105239 = r105237 + r105238;
        double r105240 = r105236 / r105239;
        return r105240;
}

double f(double a, double b, double c, double d) {
        double r105241 = 1.0;
        double r105242 = c;
        double r105243 = r105242 * r105242;
        double r105244 = d;
        double r105245 = r105244 * r105244;
        double r105246 = r105243 + r105245;
        double r105247 = sqrt(r105246);
        double r105248 = b;
        double r105249 = r105248 * r105242;
        double r105250 = a;
        double r105251 = r105250 * r105244;
        double r105252 = r105249 - r105251;
        double r105253 = r105247 / r105252;
        double r105254 = r105241 / r105253;
        double r105255 = r105254 / r105247;
        return r105255;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.4
Target0.5
Herbie26.4
\[\begin{array}{l} \mathbf{if}\;\left|d\right| \lt \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}\]

Derivation

  1. Initial program 26.4

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt26.4

    \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\]
  4. Applied associate-/r*26.3

    \[\leadsto \color{blue}{\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}}\]
  5. Using strategy rm
  6. Applied clear-num26.4

    \[\leadsto \frac{\color{blue}{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot c - a \cdot d}}}}{\sqrt{c \cdot c + d \cdot d}}\]
  7. Final simplification26.4

    \[\leadsto \frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot c - a \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]

Reproduce

herbie shell --seed 2019322 
(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))))