Average Error: 25.0 → 22.8
Time: 22.2s
Precision: 64
Internal Precision: 128
\[\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} \lor \neg \left(y.im \le 2.383322591881426 \cdot 10^{+126}\right):\\ \;\;\;\;\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}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{x.im}{\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}\\ \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 2 regimes
  2. if y.im < -5.379472257971529e+59 or 2.383322591881426e+126 < y.im

    1. Initial program 37.5

      \[\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-sub37.5

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

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

    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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification22.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \le -5.379472257971529 \cdot 10^{+59} \lor \neg \left(y.im \le 2.383322591881426 \cdot 10^{+126}\right):\\ \;\;\;\;\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}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y.re}{\sqrt{y.im \cdot y.im + y.re \cdot y.re}} \cdot \frac{x.im}{\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}\\ \end{array}\]

Runtime

Time bar (total: 22.2s)Debug logProfile

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))))