Average Error: 26.4 → 26.3
Time: 17.1s
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 r7232982 = b;
        double r7232983 = c;
        double r7232984 = r7232982 * r7232983;
        double r7232985 = a;
        double r7232986 = d;
        double r7232987 = r7232985 * r7232986;
        double r7232988 = r7232984 - r7232987;
        double r7232989 = r7232983 * r7232983;
        double r7232990 = r7232986 * r7232986;
        double r7232991 = r7232989 + r7232990;
        double r7232992 = r7232988 / r7232991;
        return r7232992;
}

double f(double a, double b, double c, double d) {
        double r7232993 = b;
        double r7232994 = c;
        double r7232995 = r7232993 * r7232994;
        double r7232996 = a;
        double r7232997 = d;
        double r7232998 = r7232996 * r7232997;
        double r7232999 = r7232995 - r7232998;
        double r7233000 = r7232994 * r7232994;
        double r7233001 = r7232997 * r7232997;
        double r7233002 = r7233000 + r7233001;
        double r7233003 = sqrt(r7233002);
        double r7233004 = r7232999 / r7233003;
        double r7233005 = r7233004 / r7233003;
        return r7233005;
}

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.3
\[\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. Final simplification26.3

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