Average Error: 25.9 → 13.3
Time: 31.8s
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 -2.9469398602138537 \cdot 10^{+156}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 2.229079571946664 \cdot 10^{+76}:\\ \;\;\;\;\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 < -2.9469398602138537e+156

    1. Initial program 44.4

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

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

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

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

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

      \[\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. Simplified28.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/28.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. Simplified28.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 15.2

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

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

    if -2.9469398602138537e+156 < y.re < 2.229079571946664e+76

    1. Initial program 18.7

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

      \[\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-sqrt18.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-identity18.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-frac18.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. Simplified18.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. 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 2.229079571946664e+76 < y.re

    1. Initial program 37.8

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

      \[\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-sqrt37.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-identity37.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-frac37.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. Simplified37.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. Simplified24.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/24.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -2.9469398602138537 \cdot 10^{+156}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 2.229079571946664 \cdot 10^{+76}:\\ \;\;\;\;\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 2018365 +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: 27.9s)Debug log

start94.0ms

Algorithm
intervals

setup49.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.0b

localize34.0ms

Local error

Found 2 expressions with local error:

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

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
2 → 48
Calls

2 calls. Slowest were:

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

series153.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify1.9s

Counts
37 → 54
Calls

37 calls. Slowest were:

589.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
316.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))))
297.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))

prune557.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 18.0b

localize12.0ms

Local error

Found 4 expressions with local error:

17.6b
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
0.7b
(- (* x.im y.re) (* x.re y.im))
0.2b
(* (/ 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))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
4 → 103
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))
2.0ms
(- (* x.im y.re) (* x.re y.im))

series320.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

130.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
117.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
43.0ms
(/ 1 (hypot y.im y.re))
31.0ms
(- (* x.im y.re) (* x.re y.im))

simplify3.6s

Counts
73 → 115
Calls

73 calls. Slowest were:

676.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
417.0ms
(* 1 (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
303.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))

prune1.6s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 5.1b

localize12.0ms

Local error

Found 3 expressions with local error:

17.6b
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
0.7b
(- (* y.re x.im) (* x.re y.im))
0.0b
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
3 → 121
Calls

3 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))
2.0ms
(- (* y.re x.im) (* x.re y.im))

series217.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify7.6s

Counts
139 → 130
Calls

139 calls. Slowest were:

566.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* x.re y.im) (* x.re y.im)))
529.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)))
442.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.5s

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 5.0b

localize11.0ms

Local error

Found 4 expressions with local error:

17.6b
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
0.7b
(- (* 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.0b
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))

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

series374.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

148.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
107.0ms
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))
80.0ms
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
39.0ms
(- (* y.re x.im) (* x.re y.im))

simplify7.7s

Counts
99 → 131
Calls

99 calls. Slowest were:

472.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
455.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
397.0ms
(- (log (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))) (log (hypot y.im y.re)))

prune1.5s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 2.1b

regimes426.0ms

Accuracy

22.6% (10.7b remaining)

Error of 13.3b against oracle of 2.6b and baseline of 16.5b

bsearch174.0ms