Average Error: 25.8 → 17.6
Time: 57.4s
Precision: 64
Internal Precision: 576
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\begin{array}{l} \mathbf{if}\;c \le -1.4163023509313036 \cdot 10^{+122} \lor \neg \left(c \le 1.0023458808847882 \cdot 10^{+115}\right):\\ \;\;\;\;\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{d \cdot d + c \cdot c}}}{\sqrt{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.8
Target0.6
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. Split input into 2 regimes
  2. if c < -1.4163023509313036e+122 or 1.0023458808847882e+115 < c

    1. Initial program 40.6

      \[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt40.7

      \[\leadsto \frac{b \cdot c - a \cdot d}{\color{blue}{\left(\sqrt[3]{c \cdot c + d \cdot d} \cdot \sqrt[3]{c \cdot c + d \cdot d}\right) \cdot \sqrt[3]{c \cdot c + d \cdot d}}}\]
    4. Applied *-un-lft-identity40.7

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{c \cdot c + d \cdot d} \cdot \sqrt[3]{c \cdot c + d \cdot d}} \cdot \frac{b \cdot c - a \cdot d}{\sqrt[3]{c \cdot c + d \cdot d}}}\]
    6. Taylor expanded around inf 15.6

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

    if -1.4163023509313036e+122 < c < 1.0023458808847882e+115

    1. Initial program 18.7

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

      \[\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*18.6

      \[\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}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \le -1.4163023509313036 \cdot 10^{+122} \lor \neg \left(c \le 1.0023458808847882 \cdot 10^{+115}\right):\\ \;\;\;\;\frac{b}{c} - \frac{a \cdot d}{{c}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{d \cdot d + c \cdot c}}}{\sqrt{d \cdot d + c \cdot c}}\\ \end{array}\]

Runtime

Time bar (total: 57.4s)Debug logProfile

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