Average Error: 25.8 → 12.4
Time: 29.1s
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.re \le -4.848976045625144 \cdot 10^{+158}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 1.743399391103788 \cdot 10^{+148}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re - y.im \cdot x.re}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \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.re < -4.848976045625144e+158

    1. Initial program 44.0

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification44.0

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt44.0

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    5. Applied *-un-lft-identity44.0

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    6. Applied times-frac44.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    7. Simplified44.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.im^2 + y.re^2}^*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    8. Simplified27.5

      \[\leadsto \frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}\]
    9. Using strategy rm
    10. Applied associate-*l/27.5

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}}\]
    11. Simplified27.5

      \[\leadsto \frac{\color{blue}{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}}{\sqrt{y.im^2 + y.re^2}^*}\]
    12. Taylor expanded around -inf 13.7

      \[\leadsto \frac{\color{blue}{-1 \cdot x.im}}{\sqrt{y.im^2 + y.re^2}^*}\]
    13. Simplified13.7

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

    if -4.848976045625144e+158 < y.re < 1.743399391103788e+148

    1. Initial program 19.2

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification19.2

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt19.2

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    5. Applied *-un-lft-identity19.2

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    6. Applied times-frac19.2

      \[\leadsto \color{blue}{\frac{1}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    7. Simplified19.2

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.im^2 + y.re^2}^*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    8. Simplified11.9

      \[\leadsto \frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}\]
    9. Using strategy rm
    10. Applied associate-*l/11.8

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}}\]
    11. Simplified11.8

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

    if 1.743399391103788e+148 < y.re

    1. Initial program 44.6

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Initial simplification44.6

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt44.6

      \[\leadsto \frac{x.im \cdot y.re - x.re \cdot y.im}{\color{blue}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    5. Applied *-un-lft-identity44.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x.im \cdot y.re - x.re \cdot y.im\right)}}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*} \cdot \sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    6. Applied times-frac44.6

      \[\leadsto \color{blue}{\frac{1}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}}\]
    7. Simplified44.6

      \[\leadsto \color{blue}{\frac{1}{\sqrt{y.im^2 + y.re^2}^*}} \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{(y.im \cdot y.im + \left(y.re \cdot y.re\right))_*}}\]
    8. Simplified29.2

      \[\leadsto \frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \color{blue}{\frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}\]
    9. Using strategy rm
    10. Applied associate-*l/29.1

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{x.im \cdot y.re - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}}\]
    11. Simplified29.1

      \[\leadsto \frac{\color{blue}{\frac{y.re \cdot x.im - x.re \cdot y.im}{\sqrt{y.im^2 + y.re^2}^*}}}{\sqrt{y.im^2 + y.re^2}^*}\]
    12. Taylor expanded around inf 13.9

      \[\leadsto \frac{\color{blue}{x.im}}{\sqrt{y.im^2 + y.re^2}^*}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification12.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -4.848976045625144 \cdot 10^{+158}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 1.743399391103788 \cdot 10^{+148}:\\ \;\;\;\;\frac{\frac{x.im \cdot y.re - y.im \cdot x.re}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{else}:\\ \;\;\;\;\frac{x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \end{array}\]

Reproduce

herbie shell --seed 2018360 +o rules:numerics
(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))))

Details

Time bar (total: 25.1s)Debug log

start111.0ms

Algorithm
intervals

setup109.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.7b

localize35.0ms

Local error

Found 1 expressions with local error:

27.7b
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.im y.im (* y.re y.re)))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
1 → 32
Calls

1 calls. Slowest were:

6.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.im y.im (* y.re y.re)))

series62.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

62.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.im y.im (* y.re y.re)))

simplify1.7s

Counts
31 → 35
Calls

31 calls. Slowest were:

522.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
306.0ms
(/ (* (* (- (* x.im y.re) (* x.re y.im)) (- (* x.im y.re) (* x.re y.im))) (- (* x.im y.re) (* x.re y.im))) (* (* (fma y.im y.im (* y.re y.re)) (fma y.im y.im (* y.re y.re))) (fma y.im y.im (* y.re y.re))))
305.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))

prune397.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 17.0b

localize19.0ms

Local error

Found 4 expressions with local error:

16.7b
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
0.3b
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
0.0b
(/ 1 (hypot y.im y.re))
0.0b
(hypot y.im y.re)

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
4 → 97
Calls

4 calls. Slowest were:

7.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
6.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
1.0ms
(/ 1 (hypot y.im y.re))

series301.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

142.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
84.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
39.0ms
(/ 1 (hypot y.im y.re))
35.0ms
(hypot y.im y.re)

simplify3.1s

Counts
70 → 109
Calls

70 calls. Slowest were:

541.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
454.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
270.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))

prune1.5s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 5.2b

localize10.0ms

Local error

Found 4 expressions with local error:

16.7b
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
0.1b
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
0.0b
(hypot y.im y.re)
0.0b
(hypot y.im y.re)

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 125
Calls

4 calls. Slowest were:

8.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
6.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
0.0ms
(hypot y.im y.re)

series175.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

67.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
62.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
23.0ms
(hypot y.im y.re)
23.0ms
(hypot y.im y.re)

simplify7.2s

Counts
139 → 137
Calls

139 calls. Slowest were:

714.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* x.re y.im) (* x.re y.im)))
550.0ms
(/ (* (* (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))) (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))) (* (* (hypot y.im y.re) (hypot y.im y.re)) (hypot y.im y.re)))
434.0ms
(/ (/ (* (* (- (* y.re x.im) (* x.re y.im)) (- (* y.re x.im) (* x.re y.im))) (- (* y.re x.im) (* x.re y.im))) (* (* (hypot y.im y.re) (hypot y.im y.re)) (hypot y.im y.re))) (* (* (hypot y.im y.re) (hypot y.im y.re)) (hypot y.im y.re)))

prune2.0s

Pruning

12 alts after pruning (10 fresh and 2 done)

Merged error: 5.1b

localize10.0ms

Local error

Found 4 expressions with local error:

16.7b
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
0.2b
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))
0.1b
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
0.0b
(hypot y.im y.re)

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
4 → 113
Calls

4 calls. Slowest were:

5.0ms
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
4.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
2.0ms
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))

series387.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

153.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
123.0ms
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))
71.0ms
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
40.0ms
(hypot y.im y.re)

simplify6.0s

Counts
96 → 125
Calls

96 calls. Slowest were:

346.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (cbrt (hypot y.im y.re)))
325.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (sqrt (hypot y.im y.re)))
301.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (sqrt (hypot y.im y.re)))

prune1.5s

Pruning

11 alts after pruning (8 fresh and 3 done)

Merged error: 2.8b

regimes442.0ms

Accuracy

27.5% (10.1b remaining)

Error of 12.4b against oracle of 2.2b and baseline of 16.2b

bsearch142.0ms