Average Error: 25.5 → 25.5
Time: 30.2s
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}}{c \cdot b - d \cdot a}}}{\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}}{c \cdot b - d \cdot a}}}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r10923654 = b;
        double r10923655 = c;
        double r10923656 = r10923654 * r10923655;
        double r10923657 = a;
        double r10923658 = d;
        double r10923659 = r10923657 * r10923658;
        double r10923660 = r10923656 - r10923659;
        double r10923661 = r10923655 * r10923655;
        double r10923662 = r10923658 * r10923658;
        double r10923663 = r10923661 + r10923662;
        double r10923664 = r10923660 / r10923663;
        return r10923664;
}

double f(double a, double b, double c, double d) {
        double r10923665 = 1.0;
        double r10923666 = c;
        double r10923667 = r10923666 * r10923666;
        double r10923668 = d;
        double r10923669 = r10923668 * r10923668;
        double r10923670 = r10923667 + r10923669;
        double r10923671 = sqrt(r10923670);
        double r10923672 = b;
        double r10923673 = r10923666 * r10923672;
        double r10923674 = a;
        double r10923675 = r10923668 * r10923674;
        double r10923676 = r10923673 - r10923675;
        double r10923677 = r10923671 / r10923676;
        double r10923678 = r10923665 / r10923677;
        double r10923679 = r10923678 / r10923671;
        return r10923679;
}

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

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

    \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(b \cdot c - a \cdot d\right)}}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
  7. Applied associate-/l*25.5

    \[\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}}\]
  8. Final simplification25.5

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

Reproduce

herbie shell --seed 2019119 +o rules:numerics
(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))))