Average Error: 26.1 → 26.1
Time: 11.7s
Precision: 64
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}\]
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\frac{1}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}
double f(double a, double b, double c, double d) {
        double r4281200 = b;
        double r4281201 = c;
        double r4281202 = r4281200 * r4281201;
        double r4281203 = a;
        double r4281204 = d;
        double r4281205 = r4281203 * r4281204;
        double r4281206 = r4281202 - r4281205;
        double r4281207 = r4281201 * r4281201;
        double r4281208 = r4281204 * r4281204;
        double r4281209 = r4281207 + r4281208;
        double r4281210 = r4281206 / r4281209;
        return r4281210;
}

double f(double a, double b, double c, double d) {
        double r4281211 = 1.0;
        double r4281212 = c;
        double r4281213 = r4281212 * r4281212;
        double r4281214 = d;
        double r4281215 = r4281214 * r4281214;
        double r4281216 = r4281213 + r4281215;
        double r4281217 = sqrt(r4281216);
        double r4281218 = r4281211 / r4281217;
        double r4281219 = b;
        double r4281220 = r4281219 * r4281212;
        double r4281221 = a;
        double r4281222 = r4281221 * r4281214;
        double r4281223 = r4281220 - r4281222;
        double r4281224 = r4281223 / r4281217;
        double r4281225 = r4281218 * r4281224;
        return r4281225;
}

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.5
Herbie26.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 26.1

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

    \[\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 *-un-lft-identity26.1

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

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

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

Reproduce

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