Average Error: 26.4 → 26.4
Time: 3.7s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{\frac{1}{\frac{1}{\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{1}{\frac{1}{\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 r171198 = b;
        double r171199 = c;
        double r171200 = r171198 * r171199;
        double r171201 = a;
        double r171202 = d;
        double r171203 = r171201 * r171202;
        double r171204 = r171200 - r171203;
        double r171205 = r171199 * r171199;
        double r171206 = r171202 * r171202;
        double r171207 = r171205 + r171206;
        double r171208 = r171204 / r171207;
        return r171208;
}

double f(double a, double b, double c, double d) {
        double r171209 = 1.0;
        double r171210 = b;
        double r171211 = c;
        double r171212 = r171210 * r171211;
        double r171213 = a;
        double r171214 = d;
        double r171215 = r171213 * r171214;
        double r171216 = r171212 - r171215;
        double r171217 = r171211 * r171211;
        double r171218 = r171214 * r171214;
        double r171219 = r171217 + r171218;
        double r171220 = sqrt(r171219);
        double r171221 = r171216 / r171220;
        double r171222 = r171209 / r171221;
        double r171223 = r171209 / r171222;
        double r171224 = r171223 / r171220;
        return r171224;
}

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

Original26.4
Target0.4
Herbie26.4
\[\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 26.4

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

    \[\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*26.4

    \[\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 clear-num26.4

    \[\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}}\]
  7. Using strategy rm
  8. Applied clear-num26.4

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

    \[\leadsto \frac{\frac{1}{\frac{1}{\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 2020081 
(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))))