Average Error: 25.1 → 25.1
Time: 12.6s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \left(b \cdot c - a \cdot d\right)}{\sqrt{c \cdot c + d \cdot d}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \left(b \cdot c - a \cdot d\right)}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r5296808 = b;
        double r5296809 = c;
        double r5296810 = r5296808 * r5296809;
        double r5296811 = a;
        double r5296812 = d;
        double r5296813 = r5296811 * r5296812;
        double r5296814 = r5296810 - r5296813;
        double r5296815 = r5296809 * r5296809;
        double r5296816 = r5296812 * r5296812;
        double r5296817 = r5296815 + r5296816;
        double r5296818 = r5296814 / r5296817;
        return r5296818;
}

double f(double a, double b, double c, double d) {
        double r5296819 = 1.0;
        double r5296820 = c;
        double r5296821 = r5296820 * r5296820;
        double r5296822 = d;
        double r5296823 = r5296822 * r5296822;
        double r5296824 = r5296821 + r5296823;
        double r5296825 = sqrt(r5296824);
        double r5296826 = r5296819 / r5296825;
        double r5296827 = b;
        double r5296828 = r5296827 * r5296820;
        double r5296829 = a;
        double r5296830 = r5296829 * r5296822;
        double r5296831 = r5296828 - r5296830;
        double r5296832 = r5296826 * r5296831;
        double r5296833 = r5296832 / r5296825;
        return r5296833;
}

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

    \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt25.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*25.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. Using strategy rm
  6. Applied div-inv25.1

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

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

Reproduce

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