Average Error: 25.5 → 25.4
Time: 12.9s
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 r3558939 = b;
        double r3558940 = c;
        double r3558941 = r3558939 * r3558940;
        double r3558942 = a;
        double r3558943 = d;
        double r3558944 = r3558942 * r3558943;
        double r3558945 = r3558941 - r3558944;
        double r3558946 = r3558940 * r3558940;
        double r3558947 = r3558943 * r3558943;
        double r3558948 = r3558946 + r3558947;
        double r3558949 = r3558945 / r3558948;
        return r3558949;
}

double f(double a, double b, double c, double d) {
        double r3558950 = b;
        double r3558951 = c;
        double r3558952 = r3558950 * r3558951;
        double r3558953 = a;
        double r3558954 = d;
        double r3558955 = r3558953 * r3558954;
        double r3558956 = r3558952 - r3558955;
        double r3558957 = r3558951 * r3558951;
        double r3558958 = r3558954 * r3558954;
        double r3558959 = r3558957 + r3558958;
        double r3558960 = sqrt(r3558959);
        double r3558961 = r3558956 / r3558960;
        double r3558962 = r3558961 / r3558960;
        return r3558962;
}

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.5
Target0.5
Herbie25.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 25.5

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

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

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

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