Average Error: 26.4 → 26.4
Time: 15.1s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{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{\frac{1}{\frac{\sqrt{c \cdot c + d \cdot d}}{b \cdot c - a \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r77811 = b;
        double r77812 = c;
        double r77813 = r77811 * r77812;
        double r77814 = a;
        double r77815 = d;
        double r77816 = r77814 * r77815;
        double r77817 = r77813 - r77816;
        double r77818 = r77812 * r77812;
        double r77819 = r77815 * r77815;
        double r77820 = r77818 + r77819;
        double r77821 = r77817 / r77820;
        return r77821;
}

double f(double a, double b, double c, double d) {
        double r77822 = 1.0;
        double r77823 = c;
        double r77824 = r77823 * r77823;
        double r77825 = d;
        double r77826 = r77825 * r77825;
        double r77827 = r77824 + r77826;
        double r77828 = sqrt(r77827);
        double r77829 = b;
        double r77830 = r77829 * r77823;
        double r77831 = a;
        double r77832 = r77831 * r77825;
        double r77833 = r77830 - r77832;
        double r77834 = r77828 / r77833;
        double r77835 = r77822 / r77834;
        double r77836 = r77835 / r77828;
        return r77836;
}

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.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 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. Using strategy rm
  6. Applied clear-num26.4

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

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

Reproduce

herbie shell --seed 2019322 
(FPCore (a b c d)
  :name "Complex division, imag part"
  :precision binary64

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