Average Error: 25.9 → 25.9
Time: 4.8s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
double f(double a, double b, double c, double d) {
        double r155925 = b;
        double r155926 = c;
        double r155927 = r155925 * r155926;
        double r155928 = a;
        double r155929 = d;
        double r155930 = r155928 * r155929;
        double r155931 = r155927 - r155930;
        double r155932 = r155926 * r155926;
        double r155933 = r155929 * r155929;
        double r155934 = r155932 + r155933;
        double r155935 = r155931 / r155934;
        return r155935;
}

double f(double a, double b, double c, double d) {
        double r155936 = b;
        double r155937 = c;
        double r155938 = r155936 * r155937;
        double r155939 = a;
        double r155940 = d;
        double r155941 = r155939 * r155940;
        double r155942 = r155938 - r155941;
        double r155943 = r155937 * r155937;
        double r155944 = r155940 * r155940;
        double r155945 = r155943 + r155944;
        double r155946 = r155942 / r155945;
        return r155946;
}

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

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

    \[\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.8

    \[\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.8

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

    \[\leadsto \frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\color{blue}{\sqrt{1} \cdot \sqrt{c \cdot c + d \cdot d}}}\]
  8. Applied *-un-lft-identity25.8

    \[\leadsto \frac{\frac{b \cdot c - a \cdot d}{\sqrt{\color{blue}{1 \cdot \left(c \cdot c + d \cdot d\right)}}}}{\sqrt{1} \cdot \sqrt{c \cdot c + d \cdot d}}\]
  9. Applied sqrt-prod25.8

    \[\leadsto \frac{\frac{b \cdot c - a \cdot d}{\color{blue}{\sqrt{1} \cdot \sqrt{c \cdot c + d \cdot d}}}}{\sqrt{1} \cdot \sqrt{c \cdot c + d \cdot d}}\]
  10. Applied *-un-lft-identity25.8

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

    \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}}{\sqrt{1} \cdot \sqrt{c \cdot c + d \cdot d}}\]
  12. Applied times-frac25.8

    \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{1}}}{\sqrt{1}} \cdot \frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}}\]
  13. Simplified25.8

    \[\leadsto \color{blue}{1} \cdot \frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
  14. Simplified25.9

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

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

Reproduce

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