Average Error: 25.9 → 25.9
Time: 11.7s
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 r5590217 = b;
        double r5590218 = c;
        double r5590219 = r5590217 * r5590218;
        double r5590220 = a;
        double r5590221 = d;
        double r5590222 = r5590220 * r5590221;
        double r5590223 = r5590219 - r5590222;
        double r5590224 = r5590218 * r5590218;
        double r5590225 = r5590221 * r5590221;
        double r5590226 = r5590224 + r5590225;
        double r5590227 = r5590223 / r5590226;
        return r5590227;
}

double f(double a, double b, double c, double d) {
        double r5590228 = b;
        double r5590229 = c;
        double r5590230 = r5590228 * r5590229;
        double r5590231 = a;
        double r5590232 = d;
        double r5590233 = r5590231 * r5590232;
        double r5590234 = r5590230 - r5590233;
        double r5590235 = r5590229 * r5590229;
        double r5590236 = r5590232 * r5590232;
        double r5590237 = r5590235 + r5590236;
        double r5590238 = sqrt(r5590237);
        double r5590239 = r5590234 / r5590238;
        double r5590240 = r5590239 / r5590238;
        return r5590240;
}

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