Average Error: 25.5 → 24.9
Time: 27.8s
Precision: 64
Internal Precision: 576
\[\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 8.897835528775714 \cdot 10^{+296}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{\sqrt{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.5
Target0.4
Herbie24.9
\[\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))) < 8.897835528775714e+296

    1. Initial program 13.8

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

    if 8.897835528775714e+296 < (/ (- (* b c) (* a d)) (+ (* c c) (* d d)))

    1. Initial program 62.0

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

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

      \[\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}}}\]
    5. Taylor expanded around -inf 59.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d} \le 8.897835528775714 \cdot 10^{+296}:\\ \;\;\;\;\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{\sqrt{c \cdot c + d \cdot d}}\\ \end{array}\]

Runtime

Time bar (total: 27.8s)Debug logProfile

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