Average Error: 26.1 → 13.0
Time: 25.5s
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 -3.8940386072016875 \cdot 10^{+153}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 1.092948697378428 \cdot 10^{+205}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \left(x.im \cdot y.re - y.im \cdot x.re\right)}{\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 < -3.8940386072016875e+153

    1. Initial program 44.3

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

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

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

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

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

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

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

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

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

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

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

    if -3.8940386072016875e+153 < y.re < 1.092948697378428e+205

    1. Initial program 21.2

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

      \[\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-sqrt21.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-identity21.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-frac21.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. Simplified21.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. Simplified13.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. Taylor expanded around -inf 13.2

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

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

    if 1.092948697378428e+205 < y.re

    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. Simplified31.3

      \[\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/31.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -3.8940386072016875 \cdot 10^{+153}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 1.092948697378428 \cdot 10^{+205}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{y.im^2 + y.re^2}^*} \cdot \left(x.im \cdot y.re - y.im \cdot x.re\right)}{\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 2019007 +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: 24.1s)Debug log

sample64.0ms

Algorithm
intervals

simplify43.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.6b

localize24.0ms

Local error

Found 2 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
2 → 48
Calls

2 calls. Slowest were:

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

series91.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify1.8s

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

prune669.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 17.3b

localize24.0ms

Local error

Found 4 expressions with local error:

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

rewrite36.0ms

Algorithm
rewrite-expression-head
Counts
4 → 103
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)))
13.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:

132.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
110.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
42.0ms
(- (* x.im y.re) (* x.re y.im))
34.0ms
(/ 1 (hypot y.im y.re))

simplify3.1s

Counts
73 → 115
Calls

73 calls. Slowest were:

563.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
348.0ms
(* 1 (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
265.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))

prune1.4s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 6.4b

localize21.0ms

Local error

Found 3 expressions with local error:

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

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
3 → 121
Calls

3 calls. Slowest were:

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

series207.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

105.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
75.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
27.0ms
(- (* y.re x.im) (* x.re y.im))

simplify7.8s

Counts
139 → 130
Calls

139 calls. Slowest were:

558.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* x.re y.im) (* x.re y.im)))
478.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)))
469.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (sqrt (hypot y.im y.re)))

prune1.5s

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 6.4b

localize23.0ms

Local error

Found 4 expressions with local error:

17.0b
(/ (- (* y.re x.im) (* y.im x.re)) (hypot y.im y.re))
1.2b
(- (* y.re x.im) (* y.im x.re))
0.2b
(* (/ 1 (hypot y.im y.re)) (/ (- (* y.re x.im) (* y.im x.re)) (hypot y.im y.re)))
0.0b
(/ 1 (hypot y.im y.re))

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 103
Calls

4 calls. Slowest were:

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

series312.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

163.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* y.re x.im) (* y.im x.re)) (hypot y.im y.re)))
86.0ms
(/ (- (* y.re x.im) (* y.im x.re)) (hypot y.im y.re))
35.0ms
(/ 1 (hypot y.im y.re))
28.0ms
(- (* y.re x.im) (* y.im x.re))

simplify3.1s

Counts
73 → 115
Calls

73 calls. Slowest were:

539.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* y.im x.re) (* y.im x.re)))
309.0ms
(* 1 (/ (- (* y.re x.im) (* y.im x.re)) (hypot y.im y.re)))
304.0ms
(- (pow (* y.re x.im) 3) (pow (* y.im x.re) 3))

prune1.4s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 6.4b

regimes417.0ms

Accuracy

36.5% (6.7b remaining)

Error of 13.0b against oracle of 6.2b and baseline of 16.8b

bsearch115.0ms

end0.0ms

sample1.6s

Algorithm
intervals