Average Error: 25.3 → 16.8
Time: 42.7s
Precision: 64
Internal Precision: 576
\[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\]
\[\begin{array}{l} \mathbf{if}\;c \le -9.621588064409836 \cdot 10^{+60} \lor \neg \left(c \le 2.7932086783743507 \cdot 10^{+72}\right):\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot d + a \cdot c}{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.3
Target0.5
Herbie16.8
\[\begin{array}{l} \mathbf{if}\;\left|d\right| \lt \left|c\right|:\\ \;\;\;\;\frac{a + b \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{b + a \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if c < -9.621588064409836e+60 or 2.7932086783743507e+72 < c

    1. Initial program 36.5

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

      \[\leadsto \frac{a \cdot c + b \cdot d}{\color{blue}{\sqrt{c \cdot c + d \cdot d} \cdot \sqrt{c \cdot c + d \cdot d}}}\]
    4. Applied *-un-lft-identity36.5

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

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

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

      \[\leadsto \color{blue}{\frac{a + \frac{d \cdot b}{c}}{\sqrt{c \cdot c + d \cdot d}}}\]
    8. Taylor expanded around inf 15.4

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

    if -9.621588064409836e+60 < c < 2.7932086783743507e+72

    1. Initial program 17.7

      \[\frac{a \cdot c + b \cdot d}{c \cdot c + d \cdot d}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify16.8

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;c \le -9.621588064409836 \cdot 10^{+60} \lor \neg \left(c \le 2.7932086783743507 \cdot 10^{+72}\right):\\ \;\;\;\;\frac{a + \frac{b \cdot d}{c}}{c}\\ \mathbf{else}:\\ \;\;\;\;\frac{b \cdot d + a \cdot c}{d \cdot d + c \cdot c}\\ \end{array}}\]

Runtime

Time bar (total: 42.7s)Debug logProfile

herbie shell --seed 2018206 
(FPCore (a b c d)
  :name "Complex division, real part"

  :herbie-target
  (if (< (fabs d) (fabs c)) (/ (+ a (* b (/ d c))) (+ c (* d (/ d c)))) (/ (+ b (* a (/ c d))) (+ d (* c (/ c d)))))

  (/ (+ (* a c) (* b d)) (+ (* c c) (* d d))))