Average Error: 25.5 → 25.5
Time: 24.7s
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 r25184321 = b;
        double r25184322 = c;
        double r25184323 = r25184321 * r25184322;
        double r25184324 = a;
        double r25184325 = d;
        double r25184326 = r25184324 * r25184325;
        double r25184327 = r25184323 - r25184326;
        double r25184328 = r25184322 * r25184322;
        double r25184329 = r25184325 * r25184325;
        double r25184330 = r25184328 + r25184329;
        double r25184331 = r25184327 / r25184330;
        return r25184331;
}

double f(double a, double b, double c, double d) {
        double r25184332 = 1.0;
        double r25184333 = c;
        double r25184334 = r25184333 * r25184333;
        double r25184335 = d;
        double r25184336 = r25184335 * r25184335;
        double r25184337 = r25184334 + r25184336;
        double r25184338 = sqrt(r25184337);
        double r25184339 = b;
        double r25184340 = r25184333 * r25184339;
        double r25184341 = a;
        double r25184342 = r25184335 * r25184341;
        double r25184343 = r25184340 - r25184342;
        double r25184344 = r25184338 / r25184343;
        double r25184345 = r25184332 / r25184344;
        double r25184346 = r25184345 / r25184338;
        return r25184346;
}

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