Average Error: 25.8 → 23.5
Time: 46.4s
Precision: 64
Internal Precision: 576
\[\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
\[\begin{array}{l} \mathbf{if}\;d \le -1.1259973219141482 \cdot 10^{-75} \lor \neg \left(d \le 8.790420369344199 \cdot 10^{-151}\right):\\ \;\;\;\;\frac{b \cdot c}{d \cdot d + c \cdot c} - \frac{\frac{d}{\sqrt{d \cdot d + c \cdot c}} \cdot a}{\sqrt{d \cdot d + c \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b}{\sqrt{d \cdot d + c \cdot c}} \cdot \frac{c}{\sqrt{d \cdot d + c \cdot c}} - \frac{\frac{d \cdot a}{\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.4
Herbie23.5
\[\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 < -1.1259973219141482e-75 or 8.790420369344199e-151 < d

    1. Initial program 27.1

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

      \[\leadsto \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt27.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}}}\]
    5. Applied associate-/r*27.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}}}\]
    6. Using strategy rm
    7. Applied div-sub27.1

      \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}}{\sqrt{c \cdot c + d \cdot d}}\]
    8. Applied div-sub27.1

      \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}} - \frac{\frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}}\]
    9. Simplified27.1

      \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d}} - \frac{\frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity27.1

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

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

      \[\leadsto \frac{b \cdot c}{c \cdot c + d \cdot d} - \frac{\color{blue}{\frac{a}{\sqrt{1}} \cdot \frac{d}{\sqrt{c \cdot c + d \cdot d}}}}{\sqrt{c \cdot c + d \cdot d}}\]
    14. Simplified24.9

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

    if -1.1259973219141482e-75 < d < 8.790420369344199e-151

    1. Initial program 22.4

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

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

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

      \[\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}}}\]
    6. Using strategy rm
    7. Applied div-sub22.4

      \[\leadsto \frac{\color{blue}{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}} - \frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}}{\sqrt{c \cdot c + d \cdot d}}\]
    8. Applied div-sub22.4

      \[\leadsto \color{blue}{\frac{\frac{b \cdot c}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}} - \frac{\frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}}\]
    9. Simplified22.5

      \[\leadsto \color{blue}{\frac{b \cdot c}{c \cdot c + d \cdot d}} - \frac{\frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt22.5

      \[\leadsto \frac{b \cdot c}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}} - \frac{\frac{a \cdot d}{\sqrt{c \cdot c + d \cdot d}}}{\sqrt{c \cdot c + d \cdot d}}\]
    12. Applied times-frac19.8

      \[\leadsto \color{blue}{\frac{b}{\sqrt{c \cdot c + d \cdot d}} \cdot \frac{c}{\sqrt{c \cdot c + d \cdot d}}} - \frac{\frac{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 simplification23.5

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

Runtime

Time bar (total: 46.4s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes24.323.522.12.137.3%
herbie shell --seed 2018295 
(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))))