Average Error: 26.1 → 26.1
Time: 13.6s
Precision: 64
\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d}\]
\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}
\frac{b \cdot d + a \cdot c}{c \cdot c + d \cdot d}
double f(double a, double b, double c, double d) {
        double r83783 = a;
        double r83784 = c;
        double r83785 = r83783 * r83784;
        double r83786 = b;
        double r83787 = d;
        double r83788 = r83786 * r83787;
        double r83789 = r83785 + r83788;
        double r83790 = r83784 * r83784;
        double r83791 = r83787 * r83787;
        double r83792 = r83790 + r83791;
        double r83793 = r83789 / r83792;
        return r83793;
}

double f(double a, double b, double c, double d) {
        double r83794 = b;
        double r83795 = d;
        double r83796 = r83794 * r83795;
        double r83797 = a;
        double r83798 = c;
        double r83799 = r83797 * r83798;
        double r83800 = r83796 + r83799;
        double r83801 = r83798 * r83798;
        double r83802 = r83795 * r83795;
        double r83803 = r83801 + r83802;
        double r83804 = r83800 / r83803;
        return r83804;
}

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.1
Target0.4
Herbie26.1
\[\begin{array}{l} \mathbf{if}\;\left|d\right| \lt \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array}\]

Derivation

  1. Initial program 26.1

    \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\]
  2. Using strategy rm
  3. Applied +-commutative26.1

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

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

Reproduce

herbie shell --seed 2019304 
(FPCore (a b c d)
  :name "Complex division, real part"
  :precision binary64

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))

  (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))