Average Error: 26.1 → 26.0
Time: 15.4s
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 r4277156 = b;
        double r4277157 = c;
        double r4277158 = r4277156 * r4277157;
        double r4277159 = a;
        double r4277160 = d;
        double r4277161 = r4277159 * r4277160;
        double r4277162 = r4277158 - r4277161;
        double r4277163 = r4277157 * r4277157;
        double r4277164 = r4277160 * r4277160;
        double r4277165 = r4277163 + r4277164;
        double r4277166 = r4277162 / r4277165;
        return r4277166;
}

double f(double a, double b, double c, double d) {
        double r4277167 = b;
        double r4277168 = c;
        double r4277169 = r4277167 * r4277168;
        double r4277170 = a;
        double r4277171 = d;
        double r4277172 = r4277170 * r4277171;
        double r4277173 = r4277169 - r4277172;
        double r4277174 = r4277168 * r4277168;
        double r4277175 = r4277171 * r4277171;
        double r4277176 = r4277174 + r4277175;
        double r4277177 = sqrt(r4277176);
        double r4277178 = r4277173 / r4277177;
        double r4277179 = r4277178 / r4277177;
        return r4277179;
}

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.1
Target0.4
Herbie26.0
\[\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.1

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

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

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

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