Average Error: 26.4 → 17.6
Time: 18.4s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt[3]{b \cdot c - a \cdot d}}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt[3]{b \cdot c - a \cdot d}}}
double f(double a, double b, double c, double d) {
        double r8532772 = b;
        double r8532773 = c;
        double r8532774 = r8532772 * r8532773;
        double r8532775 = a;
        double r8532776 = d;
        double r8532777 = r8532775 * r8532776;
        double r8532778 = r8532774 - r8532777;
        double r8532779 = r8532773 * r8532773;
        double r8532780 = r8532776 * r8532776;
        double r8532781 = r8532779 + r8532780;
        double r8532782 = r8532778 / r8532781;
        return r8532782;
}

double f(double a, double b, double c, double d) {
        double r8532783 = b;
        double r8532784 = c;
        double r8532785 = r8532783 * r8532784;
        double r8532786 = a;
        double r8532787 = d;
        double r8532788 = r8532786 * r8532787;
        double r8532789 = r8532785 - r8532788;
        double r8532790 = cbrt(r8532789);
        double r8532791 = r8532790 * r8532790;
        double r8532792 = hypot(r8532784, r8532787);
        double r8532793 = r8532791 / r8532792;
        double r8532794 = r8532792 / r8532790;
        double r8532795 = r8532793 / r8532794;
        return r8532795;
}

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.5
Herbie17.6
\[\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. Simplified26.4

    \[\leadsto \color{blue}{\frac{b \cdot c - a \cdot d}{\mathsf{fma}\left(c, c, d \cdot d\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt26.4

    \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)} \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\]
  5. Applied associate-/r*26.3

    \[\leadsto \color{blue}{\frac{\frac{b \cdot c - a \cdot d}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity26.3

    \[\leadsto \frac{\frac{b \cdot c - a \cdot d}{\color{blue}{1 \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}\]
  8. Applied add-cube-cbrt26.8

    \[\leadsto \frac{\frac{\color{blue}{\left(\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}\right) \cdot \sqrt[3]{b \cdot c - a \cdot d}}}{1 \cdot \sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}\]
  9. Applied times-frac26.8

    \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{1} \cdot \frac{\sqrt[3]{b \cdot c - a \cdot d}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}\]
  10. Applied associate-/l*26.9

    \[\leadsto \color{blue}{\frac{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{1}}{\frac{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}{\frac{\sqrt[3]{b \cdot c - a \cdot d}}{\sqrt{\mathsf{fma}\left(c, c, d \cdot d\right)}}}}}\]
  11. Simplified23.7

    \[\leadsto \frac{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{1}}{\color{blue}{\mathsf{hypot}\left(c, d\right) \cdot \frac{\mathsf{hypot}\left(c, d\right)}{\sqrt[3]{b \cdot c - a \cdot d}}}}\]
  12. Using strategy rm
  13. Applied associate-/r*17.6

    \[\leadsto \color{blue}{\frac{\frac{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{1}}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt[3]{b \cdot c - a \cdot d}}}}\]
  14. Simplified17.6

    \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{\mathsf{hypot}\left(c, d\right)}}}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt[3]{b \cdot c - a \cdot d}}}\]
  15. Final simplification17.6

    \[\leadsto \frac{\frac{\sqrt[3]{b \cdot c - a \cdot d} \cdot \sqrt[3]{b \cdot c - a \cdot d}}{\mathsf{hypot}\left(c, d\right)}}{\frac{\mathsf{hypot}\left(c, d\right)}{\sqrt[3]{b \cdot c - a \cdot d}}}\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(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))))