Average Error: 25.0 → 22.8
Time: 23.1s
Precision: 64
Internal Precision: 128
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\begin{array}{l} \mathbf{if}\;d \le -5.379472257971529 \cdot 10^{+59} \lor \neg \left(d \le 2.383322591881426 \cdot 10^{+126}\right):\\ \;\;\;\;\frac{b \cdot c}{d \cdot d + c \cdot c} - \frac{a}{\frac{d \cdot d + c \cdot c}{d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\sqrt{d \cdot d + c \cdot c}} \cdot \frac{b}{\sqrt{d \cdot d + c \cdot c}} - \frac{d \cdot a}{d \cdot d + c \cdot c}\\ \end{array}\]

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.0
Target0.4
Herbie22.8
\[\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. Split input into 2 regimes
  2. if d < -5.379472257971529e+59 or 2.383322591881426e+126 < d

    1. Initial program 37.5

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
    2. Initial simplification37.5

      \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
    3. Using strategy rm
    4. Applied div-sub37.5

      \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}}\]
    5. Using strategy rm
    6. Applied associate-/l*35.0

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

    if -5.379472257971529e+59 < d < 2.383322591881426e+126

    1. Initial program 18.0

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
    2. Initial simplification18.0

      \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
    3. Using strategy rm
    4. Applied div-sub18.1

      \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{a \cdot d}{c \cdot c + d \cdot d}}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt18.1

      \[\leadsto \frac{b \cdot c}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d}\]
    7. Applied times-frac15.9

      \[\leadsto \color{blue}{\frac{b}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{a \cdot d}{c \cdot c + d \cdot d}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification22.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;d \le -5.379472257971529 \cdot 10^{+59} \lor \neg \left(d \le 2.383322591881426 \cdot 10^{+126}\right):\\ \;\;\;\;\frac{b \cdot c}{d \cdot d + c \cdot c} - \frac{a}{\frac{d \cdot d + c \cdot c}{d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\sqrt{d \cdot d + c \cdot c}} \cdot \frac{b}{\sqrt{d \cdot d + c \cdot c}} - \frac{d \cdot a}{d \cdot d + c \cdot c}\\ \end{array}\]

Runtime

Time bar (total: 23.1s)Debug logProfile

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