Average Error: 25.6 → 25.6
Time: 11.2s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r2488544 = b;
        double r2488545 = c;
        double r2488546 = r2488544 * r2488545;
        double r2488547 = a;
        double r2488548 = d;
        double r2488549 = r2488547 * r2488548;
        double r2488550 = r2488546 - r2488549;
        double r2488551 = r2488545 * r2488545;
        double r2488552 = r2488548 * r2488548;
        double r2488553 = r2488551 + r2488552;
        double r2488554 = r2488550 / r2488553;
        return r2488554;
}

double f(double a, double b, double c, double d) {
        double r2488555 = b;
        double r2488556 = c;
        double r2488557 = r2488555 * r2488556;
        double r2488558 = a;
        double r2488559 = d;
        double r2488560 = r2488558 * r2488559;
        double r2488561 = r2488557 - r2488560;
        double r2488562 = r2488556 * r2488556;
        double r2488563 = r2488559 * r2488559;
        double r2488564 = r2488562 + r2488563;
        double r2488565 = sqrt(r2488564);
        double r2488566 = r2488561 / r2488565;
        double r2488567 = r2488566 / r2488565;
        return r2488567;
}

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

Original25.6
Target0.4
Herbie25.6
\[\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 25.6

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

    \[\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*25.6

    \[\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. Final simplification25.6

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

Reproduce

herbie shell --seed 2019153 
(FPCore (a b c d)
  :name "Complex division, imag part"

  :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))))