Average Error: 25.9 → 22.1
Time: 3.3s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{b \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a}{\frac{\sqrt{c \cdot c + d \cdot d}}{d}}}{\sqrt{c \cdot c + d \cdot d}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{b \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a}{\frac{\sqrt{c \cdot c + d \cdot d}}{d}}}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r121342 = b;
        double r121343 = c;
        double r121344 = r121342 * r121343;
        double r121345 = a;
        double r121346 = d;
        double r121347 = r121345 * r121346;
        double r121348 = r121344 - r121347;
        double r121349 = r121343 * r121343;
        double r121350 = r121346 * r121346;
        double r121351 = r121349 + r121350;
        double r121352 = r121348 / r121351;
        return r121352;
}

double f(double a, double b, double c, double d) {
        double r121353 = b;
        double r121354 = c;
        double r121355 = r121354 * r121354;
        double r121356 = d;
        double r121357 = r121356 * r121356;
        double r121358 = r121355 + r121357;
        double r121359 = sqrt(r121358);
        double r121360 = r121354 / r121359;
        double r121361 = r121353 * r121360;
        double r121362 = a;
        double r121363 = r121359 / r121356;
        double r121364 = r121362 / r121363;
        double r121365 = r121361 - r121364;
        double r121366 = r121365 / r121359;
        return r121366;
}

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
Herbie22.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.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 div-sub25.8

    \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}}{\sqrt{c \cdot c + d \cdot d}}\]
  7. Using strategy rm
  8. Applied associate-/l*24.0

    \[\leadsto \frac{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}} - \color{blue}{\frac{a}{\frac{\sqrt{c \cdot c + d \cdot d}}{d}}}}{\sqrt{c \cdot c + d \cdot d}}\]
  9. Using strategy rm
  10. Applied *-un-lft-identity24.0

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

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

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

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

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

Reproduce

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