Average Error: 25.7 → 25.7
Time: 14.8s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r5809729 = b;
        double r5809730 = c;
        double r5809731 = r5809729 * r5809730;
        double r5809732 = a;
        double r5809733 = d;
        double r5809734 = r5809732 * r5809733;
        double r5809735 = r5809731 - r5809734;
        double r5809736 = r5809730 * r5809730;
        double r5809737 = r5809733 * r5809733;
        double r5809738 = r5809736 + r5809737;
        double r5809739 = r5809735 / r5809738;
        return r5809739;
}

double f(double a, double b, double c, double d) {
        double r5809740 = 1.0;
        double r5809741 = c;
        double r5809742 = r5809741 * r5809741;
        double r5809743 = d;
        double r5809744 = r5809743 * r5809743;
        double r5809745 = r5809742 + r5809744;
        double r5809746 = sqrt(r5809745);
        double r5809747 = r5809740 / r5809746;
        double r5809748 = b;
        double r5809749 = r5809748 * r5809741;
        double r5809750 = a;
        double r5809751 = r5809750 * r5809743;
        double r5809752 = r5809749 - r5809751;
        double r5809753 = r5809752 / r5809746;
        double r5809754 = r5809747 * r5809753;
        return r5809754;
}

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

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

    \[\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 *-un-lft-identity25.7

    \[\leadsto \frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}\]
  5. Applied times-frac25.7

    \[\leadsto \color{blue}{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}\]
  6. Final simplification25.7

    \[\leadsto \frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}\]

Reproduce

herbie shell --seed 2019162 
(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))))