Average Error: 25.8 → 25.2
Time: 20.4s
Precision: 64
Internal Precision: 128
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\begin{array}{l} \mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 7.197557528519582 \cdot 10^{+288}:\\ \;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(b \cdot c\right) \cdot \sqrt[3]{\frac{1}{{d}^{4}}} - a \cdot \sqrt[3]{\frac{1}{d}}}{\sqrt[3]{c \cdot c + d \cdot d}}\\ \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.4
Herbie25.2
\[\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 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))) < 7.197557528519582e+288

    1. Initial program 14.2

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

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

      \[\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}}}\]
    5. Applied associate-/r*14.1

      \[\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}}}\]

    if 7.197557528519582e+288 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))

    1. Initial program 61.4

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
    3. Taylor expanded around -inf 61.4

      \[\leadsto \frac{\color{blue}{b \cdot c - a \cdot d}}{c \cdot c + d \cdot d}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt61.4

      \[\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}}}\]
    6. Applied associate-/r*61.4

      \[\leadsto \color{blue}{\frac{\frac{b \cdot c - a \cdot d}{\sqrt[3]{c \cdot c + d \cdot d} \cdot \sqrt[3]{c \cdot c + d \cdot d}}}{\sqrt[3]{c \cdot c + d \cdot d}}}\]
    7. Taylor expanded around 0 60.8

      \[\leadsto \frac{\color{blue}{\left(b \cdot c\right) \cdot {\left(\frac{1}{{d}^{4}}\right)}^{\frac{1}{3}} - a \cdot {\left(\frac{1}{d}\right)}^{\frac{1}{3}}}}{\sqrt[3]{c \cdot c + d \cdot d}}\]
    8. Simplified59.3

      \[\leadsto \frac{\color{blue}{\left(b \cdot c\right) \cdot \sqrt[3]{\frac{1}{{d}^{4}}} - a \cdot \sqrt[3]{\frac{1}{d}}}}{\sqrt[3]{c \cdot c + d \cdot d}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification25.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 7.197557528519582 \cdot 10^{+288}:\\ \;\;\;\;\frac{\frac{b \cdot c - a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(b \cdot c\right) \cdot \sqrt[3]{\frac{1}{{d}^{4}}} - a \cdot \sqrt[3]{\frac{1}{d}}}{\sqrt[3]{c \cdot c + d \cdot d}}\\ \end{array}\]

Runtime

Time bar (total: 20.4s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes25.725.222.43.315.6%
herbie shell --seed 2018352 
(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))))