Average Error: 25.9 → 25.9
Time: 13.2s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r6413918 = b;
        double r6413919 = c;
        double r6413920 = r6413918 * r6413919;
        double r6413921 = a;
        double r6413922 = d;
        double r6413923 = r6413921 * r6413922;
        double r6413924 = r6413920 - r6413923;
        double r6413925 = r6413919 * r6413919;
        double r6413926 = r6413922 * r6413922;
        double r6413927 = r6413925 + r6413926;
        double r6413928 = r6413924 / r6413927;
        return r6413928;
}

double f(double a, double b, double c, double d) {
        double r6413929 = b;
        double r6413930 = c;
        double r6413931 = r6413929 * r6413930;
        double r6413932 = a;
        double r6413933 = d;
        double r6413934 = r6413932 * r6413933;
        double r6413935 = r6413931 - r6413934;
        double r6413936 = r6413930 * r6413930;
        double r6413937 = r6413933 * r6413933;
        double r6413938 = r6413936 + r6413937;
        double r6413939 = sqrt(r6413938);
        double r6413940 = r6413935 / r6413939;
        double r6413941 = r6413940 / r6413939;
        return r6413941;
}

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.4
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.9

    \[\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. Final simplification25.9

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

Reproduce

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