Average Error: 25.0 → 22.8
Time: 15.1s
Precision: 64
Internal Precision: 576
\[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
\[\begin{array}{l} \mathbf{if}\;y.im \le -5.379472257971529 \cdot 10^{+59}:\\ \;\;\;\;\frac{x.im \cdot y.re}{y.im \cdot y.im + y.re \cdot y.re} - \frac{y.im}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{x.re}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}}\\ \mathbf{elif}\;y.im \le 2.383322591881426 \cdot 10^{+126}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{y.re}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} - \frac{y.im \cdot x.re}{y.im \cdot y.im + y.re \cdot y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im \cdot y.re}{y.im \cdot y.im + y.re \cdot y.re} - \frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}\\ \end{array}\]

Error

Bits error versus x.re

Bits error versus x.im

Bits error versus y.re

Bits error versus y.im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if y.im < -5.379472257971529e+59

    1. Initial program 35.7

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied div-sub35.7

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt35.7

      \[\leadsto \frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]
    6. Applied times-frac32.4

      \[\leadsto \frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \color{blue}{\frac{x.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{y.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}}\]

    if -5.379472257971529e+59 < y.im < 2.383322591881426e+126

    1. Initial program 18.0

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied div-sub18.1

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt18.1

      \[\leadsto \frac{x.im \cdot y.re}{\color{blue}{\sqrt{y.re \cdot y.re + y.im \cdot y.im} \cdot \sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    6. Applied times-frac15.9

      \[\leadsto \color{blue}{\frac{x.im}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}} \cdot \frac{y.re}{\sqrt{y.re \cdot y.re + y.im \cdot y.im}}} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]

    if 2.383322591881426e+126 < y.im

    1. Initial program 39.8

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Using strategy rm
    3. Applied div-sub39.8

      \[\leadsto \color{blue}{\frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \frac{x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}}\]
    4. Using strategy rm
    5. Applied associate-/l*38.4

      \[\leadsto \frac{x.im \cdot y.re}{y.re \cdot y.re + y.im \cdot y.im} - \color{blue}{\frac{x.re}{\frac{y.re \cdot y.re + y.im \cdot y.im}{y.im}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification22.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \le -5.379472257971529 \cdot 10^{+59}:\\ \;\;\;\;\frac{x.im \cdot y.re}{y.im \cdot y.im + y.re \cdot y.re} - \frac{y.im}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{x.re}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}}\\ \mathbf{elif}\;y.im \le 2.383322591881426 \cdot 10^{+126}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{y.re}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} - \frac{y.im \cdot x.re}{y.im \cdot y.im + y.re \cdot y.re}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im \cdot y.re}{y.im \cdot y.im + y.re \cdot y.re} - \frac{x.re}{\frac{y.im \cdot y.im + y.re \cdot y.re}{y.im}}\\ \end{array}\]

Runtime

Time bar (total: 15.1s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes23.822.821.22.639.9%
herbie shell --seed 2018296 
(FPCore (x.re x.im y.re y.im)
  :name "_divideComplex, imaginary part"
  (/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im))))