Average Error: 25.7 → 12.7
Time: 30.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 -2.5161194196285015 \cdot 10^{+141}:\\ \;\;\;\;\frac{x.re}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 1.679685344068761 \cdot 10^{+113}:\\ \;\;\;\;\frac{\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}^*}\\ \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 < -2.5161194196285015e+141

    1. Initial program 43.3

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Simplified43.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-sqrt43.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-identity43.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-frac43.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. Simplified43.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. Simplified26.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/26.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. Simplified26.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 *-un-lft-identity26.6

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(y.re \cdot x.im - x.re \cdot y.im\right)}}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}\]
    14. Applied associate-/l*26.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}^*}\]
    15. Taylor expanded around -inf 14.2

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

    if -2.5161194196285015e+141 < y.im < 1.679685344068761e+113

    1. Initial program 18.4

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

      \[\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.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-identity18.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-frac18.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. Simplified18.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. 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}^*}\]

    if 1.679685344068761e+113 < y.im

    1. Initial program 40.5

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

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

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

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

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

      \[\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. Simplified25.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/25.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. Simplified25.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 *-un-lft-identity25.6

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \left(y.re \cdot x.im - x.re \cdot y.im\right)}}{\sqrt{y.im^2 + y.re^2}^*}}{\sqrt{y.im^2 + y.re^2}^*}\]
    14. Applied associate-/l*25.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}^*}\]
    15. Taylor expanded around inf 16.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.im \le -2.5161194196285015 \cdot 10^{+141}:\\ \;\;\;\;\frac{x.re}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.im \le 1.679685344068761 \cdot 10^{+113}:\\ \;\;\;\;\frac{\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}^*}\\ \mathbf{else}:\\ \;\;\;\;\frac{-x.re}{\sqrt{y.im^2 + y.re^2}^*}\\ \end{array}\]

Reproduce

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

sample71.0ms

Algorithm
intervals
Results
274×(pre true 80)
274×(body real 80)

simplify89.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
89.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (+ (* y.re y.re) (* y.im y.im)))

prune20.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 26.5b

localize18.0ms

Local error

Found 3 expressions with local error:

26.5b
(/ (- (* 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))
0.0b
(fma y.im y.im (* y.re y.re))

rewrite14.0ms

Algorithm
rewrite-expression-head
Rules
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
times-frac
add-log-exp
add-exp-log
add-cbrt-cube
associate-/l*
log1p-expm1-u
associate-/r*
pow1
expm1-log1p-u
associate-/l/
flip--
flip3--
div-inv
fma-udef
prod-diff
div-exp
div-sub
diff-log
fma-neg
frac-2neg
sub-neg
clear-num
cbrt-undiv
Counts
3 → 58
Calls
3 calls:
Slowest
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))
0.0ms
(fma y.im y.im (* y.re y.re))

series151.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
96.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.im y.im (* y.re y.re)))
36.0ms
(- (* x.im y.re) (* x.re y.im))
19.0ms
(fma y.im y.im (* y.re y.re))

simplify1.9s

Counts
40 → 67
Calls
40 calls:
Slowest
572.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
329.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))))
216.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))
77.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (sqrt (fma y.im y.im (* y.re y.re))))
73.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.im y.im (* y.re y.re)))

prune844.0ms

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 16.8b

localize11.0ms

Local error

Found 4 expressions with local error:

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

rewrite26.0ms

Algorithm
rewrite-expression-head
Rules
21×add-cube-cbrt
21×*-un-lft-identity
21×add-sqr-sqrt
18×times-frac
17×add-exp-log
13×associate-*r*
11×add-cbrt-cube
pow1
add-log-exp
associate-/r*
div-inv
log1p-expm1-u
prod-exp
associate-*l*
expm1-log1p-u
associate-/l*
div-exp
rec-exp
associate-/l/
flip--
cbrt-unprod
flip3--
frac-2neg
clear-num
cbrt-undiv
inv-pow
pow-flip
*-commutative
associate-*r/
associate-*l/
pow-prod-down
prod-diff
div-sub
diff-log
fma-neg
sub-neg
frac-times
Counts
4 → 103
Calls
4 calls:
Slowest
11.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
9.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
2.0ms
(- (* x.im y.re) (* x.re y.im))
2.0ms
(/ 1 (hypot y.im y.re))

series687.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
410.0ms
(- (* x.im y.re) (* x.re y.im))
121.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
109.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
46.0ms
(/ 1 (hypot y.im y.re))

simplify3.2s

Counts
73 → 115
Calls
73 calls:
Slowest
508.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
395.0ms
(* 1 (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
274.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))
231.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))) (* (* (hypot y.im y.re) (hypot y.im y.re)) (hypot y.im y.re)))
158.0ms
(* (* (* (/ 1 (hypot y.im y.re)) (/ 1 (hypot y.im y.re))) (/ 1 (hypot y.im y.re))) (/ (* (* (- (* x.im y.re) (* x.re y.im)) (- (* x.im y.re) (* x.re y.im))) (- (* x.im y.re) (* x.re y.im))) (* (* (hypot y.im y.re) (hypot y.im y.re)) (hypot y.im y.re))))

prune1.4s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 6.0b

localize21.0ms

Local error

Found 3 expressions with local error:

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

rewrite35.0ms

Algorithm
rewrite-expression-head
Rules
84×times-frac
53×add-cube-cbrt
53×*-un-lft-identity
53×add-sqr-sqrt
16×associate-/l*
10×add-exp-log
10×add-cbrt-cube
div-inv
associate-/r*
add-log-exp
div-exp
cbrt-undiv
associate-/l/
log1p-expm1-u
div-sub
pow1
expm1-log1p-u
flip--
flip3--
frac-2neg
clear-num
prod-diff
diff-log
fma-neg
sub-neg
Counts
3 → 121
Calls
3 calls:
Slowest
15.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
13.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
4.0ms
(- (* y.re x.im) (* x.re y.im))

series219.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
107.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
75.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
36.0ms
(- (* y.re x.im) (* x.re y.im))

simplify7.4s

Counts
139 → 130
Calls
139 calls:
Slowest
555.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* x.re y.im) (* x.re y.im)))
476.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)))
423.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)))
291.0ms
(- (pow (* y.re x.im) 3) (pow (* x.re y.im) 3))
283.0ms
(/ (/ (* (cbrt (- (* y.re x.im) (* x.re y.im))) (cbrt (- (* y.re x.im) (* x.re y.im)))) (* (cbrt (hypot y.im y.re)) (cbrt (hypot y.im y.re)))) 1)

prune1.5s

Pruning

13 alts after pruning (12 fresh and 1 done)

Merged error: 5.9b

localize17.0ms

Local error

Found 4 expressions with local error:

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

rewrite30.0ms

Algorithm
rewrite-expression-head
Rules
33×times-frac
29×add-cube-cbrt
29×*-un-lft-identity
29×add-sqr-sqrt
21×associate-/r*
16×add-exp-log
associate-/r/
associate-/l*
div-inv
add-cbrt-cube
add-log-exp
div-exp
pow1
log1p-expm1-u
rec-exp
expm1-log1p-u
flip--
flip3--
frac-2neg
clear-num
cbrt-undiv
associate-/l/
inv-pow
pow-flip
prod-diff
diff-log
fma-neg
sub-neg
Counts
4 → 119
Calls
4 calls:
Slowest
10.0ms
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
8.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
5.0ms
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))
4.0ms
(- (* y.re x.im) (* x.re y.im))

series396.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
127.0ms
(/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))
122.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
105.0ms
(/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))
42.0ms
(- (* y.re x.im) (* x.re y.im))

simplify7.0s

Counts
99 → 131
Calls
99 calls:
Slowest
562.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
417.0ms
(/ (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im)))) (hypot y.im y.re))
333.0ms
(- (log (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))) (log (hypot y.im y.re)))
297.0ms
(/ (sqrt (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))) (cbrt (hypot y.im y.re)))
274.0ms
(/ (sqrt (/ 1 (/ (hypot y.im y.re) (- (* y.re x.im) (* x.re y.im))))) (sqrt (hypot y.im y.re)))

prune1.6s

Pruning

13 alts after pruning (11 fresh and 2 done)

Merged error: 2.3b

regimes502.0ms

Accuracy

24.3% (10.5b remaining)

Error of 12.7b against oracle of 2.2b and baseline of 16.0b

bsearch105.0ms

end0.0ms

sample1.9s

Algorithm
intervals
Results
8500×(pre true 80)
8500×(body real 80)