Average Error: 25.4 → 12.1
Time: 29.6s
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 -3.888992367226674 \cdot 10^{+174}:\\ \;\;\;\;\frac{x.re}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 2.3163448447978856 \cdot 10^{+141}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{y.im^2 + y.re^2}^*}}{\frac{\sqrt{y.im^2 + y.re^2}^*}{x.im \cdot y.re - x.re \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{\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.im < -3.888992367226674e+174

    1. Initial program 44.7

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Simplified44.7

      \[\leadsto \color{blue}{\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.7

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

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

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

      \[\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.6

      \[\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.6

      \[\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.6

      \[\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. Using strategy rm
    13. Applied clear-num29.6

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

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

    if -3.888992367226674e+174 < y.im < 2.3163448447978856e+141

    1. Initial program 18.8

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Simplified18.8

      \[\leadsto \color{blue}{\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-sqrt18.8

      \[\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-identity18.8

      \[\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-frac18.8

      \[\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. Simplified18.8

      \[\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.6

      \[\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.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. Simplified11.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. Using strategy rm
    13. Applied clear-num11.6

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{\sqrt{y.im^2 + y.re^2}^*}{y.re \cdot x.im - x.re \cdot y.im}}}}{\sqrt{y.im^2 + y.re^2}^*}\]
    14. Using strategy rm
    15. Applied associate-/r/11.6

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \left(y.re \cdot x.im - x.re \cdot y.im\right)}}{\sqrt{y.im^2 + y.re^2}^*}\]
    16. Applied associate-/l*11.6

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

    if 2.3163448447978856e+141 < y.im

    1. Initial program 43.0

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

      \[\leadsto \color{blue}{\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-sqrt43.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-identity43.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-frac43.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. Simplified43.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.7

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

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

      \[\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. Using strategy rm
    13. Applied clear-num27.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \le -3.888992367226674 \cdot 10^{+174}:\\ \;\;\;\;\frac{x.re}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 2.3163448447978856 \cdot 10^{+141}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{y.im^2 + y.re^2}^*}}{\frac{\sqrt{y.im^2 + y.re^2}^*}{x.im \cdot y.re - x.re \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{\sqrt{y.im^2 + y.re^2}^*}\\ \end{array}\]

Reproduce

herbie shell --seed 2019002 +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: 28.0s)Debug log

sample40.0ms

Algorithm
intervals

simplify67.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

67.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))

prune14.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 25.6b

localize22.0ms

Local error

Found 2 expressions with local error:

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
2 → 48
Calls

2 calls. Slowest were:

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

series115.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify1.9s

Counts
37 → 54
Calls

37 calls. Slowest were:

526.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
347.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))
294.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))))

prune610.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 16.7b

localize26.0ms

Local error

Found 4 expressions with local error:

16.5b
(/ (- (* 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.3b
(- (* x.im y.re) (* x.re y.im))
0.0b
(hypot y.im y.re)

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
4 → 95
Calls

4 calls. Slowest were:

15.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
12.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
4.0ms
(- (* x.im y.re) (* x.re y.im))

series318.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

153.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
92.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
39.0ms
(hypot y.im y.re)
33.0ms
(- (* x.im y.re) (* x.re y.im))

simplify3.3s

Counts
69 → 107
Calls

69 calls. Slowest were:

604.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
386.0ms
(* 1 (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
314.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))

prune1.4s

Pruning

14 alts after pruning (14 fresh and 0 done)

Merged error: 6.3b

localize22.0ms

Local error

Found 4 expressions with local error:

16.5b
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
0.3b
(- (* y.re x.im) (* x.re y.im))
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)

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 131
Calls

4 calls. Slowest were:

12.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
8.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
2.0ms
(- (* y.re x.im) (* x.re y.im))

series246.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

94.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
92.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
36.0ms
(- (* y.re x.im) (* x.re y.im))
25.0ms
(hypot y.im y.re)

simplify7.5s

Counts
142 → 143
Calls

142 calls. Slowest were:

579.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)))
545.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* x.re y.im) (* x.re y.im)))
457.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)))

prune1.4s

Pruning

15 alts after pruning (15 fresh and 0 done)

Merged error: 6.3b

localize8.0ms

Local error

Found 4 expressions with local error:

16.5b
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
0.3b
(- (* 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))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 119
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))
3.0ms
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))

series294.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

113.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
92.0ms
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))
62.0ms
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
27.0ms
(- (* y.re x.im) (* x.re y.im))

simplify7.0s

Counts
99 → 131
Calls

99 calls. Slowest were:

839.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
423.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
334.0ms
(/ (sqrt (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))) (cbrt (hypot y.im y.re)))

prune1.6s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 1.5b

regimes399.0ms

Accuracy

28.9% (9.8b remaining)

Error of 12.1b against oracle of 2.3b and baseline of 16.1b

bsearch198.0ms

end0.0ms

sample1.4s

Algorithm
intervals