Average Error: 25.9 → 25.9
Time: 13.5s
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 r5939111 = b;
        double r5939112 = c;
        double r5939113 = r5939111 * r5939112;
        double r5939114 = a;
        double r5939115 = d;
        double r5939116 = r5939114 * r5939115;
        double r5939117 = r5939113 - r5939116;
        double r5939118 = r5939112 * r5939112;
        double r5939119 = r5939115 * r5939115;
        double r5939120 = r5939118 + r5939119;
        double r5939121 = r5939117 / r5939120;
        return r5939121;
}

double f(double a, double b, double c, double d) {
        double r5939122 = b;
        double r5939123 = c;
        double r5939124 = r5939122 * r5939123;
        double r5939125 = a;
        double r5939126 = d;
        double r5939127 = r5939125 * r5939126;
        double r5939128 = r5939124 - r5939127;
        double r5939129 = r5939123 * r5939123;
        double r5939130 = r5939126 * r5939126;
        double r5939131 = r5939129 + r5939130;
        double r5939132 = sqrt(r5939131);
        double r5939133 = r5939128 / r5939132;
        double r5939134 = r5939133 / r5939132;
        return r5939134;
}

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.9
Target0.4
Herbie25.9
\[\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.9

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

    \[\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.9

    \[\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.9

    \[\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 2019172 
(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))))