Average Error: 25.8 → 12.7
Time: 43.4s
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 -1.28107214851456 \cdot 10^{+205}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 2.1659330210719858 \cdot 10^{+133}:\\ \;\;\;\;\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 < -1.28107214851456e+205

    1. Initial program 41.6

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

      \[\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-sqrt41.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-identity41.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-frac41.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. Simplified41.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. Simplified30.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/30.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. Simplified30.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 11.0

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

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

    if -1.28107214851456e+205 < y.re < 2.1659330210719858e+133

    1. Initial program 20.6

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

      \[\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-sqrt20.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-identity20.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-frac20.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. Simplified20.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. Simplified12.8

      \[\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/12.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. Simplified12.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}^*}\]

    if 2.1659330210719858e+133 < y.re

    1. Initial program 42.3

      \[\frac{x.im \cdot y.re - x.re \cdot y.im}{y.re \cdot y.re + y.im \cdot y.im}\]
    2. Simplified42.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-sqrt42.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-identity42.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-frac42.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. Simplified42.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. Simplified27.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/27.2

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

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

      \[\leadsto \frac{\color{blue}{x.im}}{\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.re \le -1.28107214851456 \cdot 10^{+205}:\\ \;\;\;\;\frac{-x.im}{\sqrt{y.im^2 + y.re^2}^*}\\ \mathbf{elif}\;y.re \le 2.1659330210719858 \cdot 10^{+133}:\\ \;\;\;\;\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 2019010 +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: 41.8s)Debug log

sample50.0ms

Algorithm
intervals

simplify35.0ms

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

prune27.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 24.4b

localize29.0ms

Local error

Found 3 expressions with local error:

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

rewrite17.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
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))
0.0ms
(fma y.im y.im (* y.re y.re))

series130.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
83.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.im y.im (* y.re y.re)))
26.0ms
(- (* x.im y.re) (* x.re y.im))
20.0ms
(fma y.im y.im (* y.re y.re))

simplify1.6s

Counts
40 → 67
Calls
40 calls:
Slowest
440.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
320.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))
267.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))))
65.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (sqrt (fma y.im y.im (* y.re y.re))))
52.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (fma y.im y.im (* y.re y.re)))

prune752.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 14.7b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite17.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
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))
1.0ms
(/ 1 (hypot y.im y.re))

series312.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
133.0ms
(* (/ 1 (hypot y.im y.re)) (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
127.0ms
(/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re))
27.0ms
(- (* x.im y.re) (* x.re y.im))
26.0ms
(/ 1 (hypot y.im y.re))

simplify3.1s

Counts
73 → 115
Calls
73 calls:
Slowest
628.0ms
(- (* (* x.im y.re) (* x.im y.re)) (* (* x.re y.im) (* x.re y.im)))
352.0ms
(* 1 (/ (- (* x.im y.re) (* x.re y.im)) (hypot y.im y.re)))
226.0ms
(- (pow (* x.im y.re) 3) (pow (* x.re y.im) 3))
183.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)))
137.0ms
(+ (log (/ 1 (hypot y.im y.re))) (- (log (- (* x.im y.re) (* x.re y.im))) (log (hypot y.im y.re))))

prune1.4s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 5.5b

localize25.0ms

Local error

Found 4 expressions with local error:

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

rewrite35.0ms

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

series242.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
91.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re)) (hypot y.im y.re))
73.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (hypot y.im y.re))
39.0ms
(hypot y.im y.re)
39.0ms
(- (* y.re x.im) (* x.re y.im))

simplify7.3s

Counts
142 → 143
Calls
142 calls:
Slowest
524.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)))
494.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)))
460.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* x.re y.im) (* x.re y.im)))
268.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)
254.0ms
(- (pow (* y.re x.im) 3) (pow (* x.re y.im) 3))

prune1.9s

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 5.5b

localize13.0ms

Local error

Found 4 expressions with local error:

8.1b
(/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re)))
6.6b
(/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))) (hypot y.im y.re))
0.3b
(/ 1 (sqrt (hypot y.im y.re)))
0.3b
(* (/ 1 (sqrt (hypot y.im y.re))) (/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))) (hypot y.im y.re)))

rewrite53.0ms

Algorithm
rewrite-expression-head
Rules
276×times-frac
159×add-cube-cbrt
159×*-un-lft-identity
159×add-sqr-sqrt
78×sqrt-prod
70×associate-*r*
30×add-exp-log
25×associate-/l*
20×add-cbrt-cube
15×associate-/r*
12×div-inv
10×div-exp
cbrt-undiv
pow1
prod-exp
add-log-exp
log1p-expm1-u
associate-*l*
rec-exp
expm1-log1p-u
associate-/l/
cbrt-unprod
div-sub
frac-2neg
clear-num
pow-flip
inv-pow
flip--
*-commutative
associate-*r/
associate-*l/
pow-prod-down
pow1/2
flip3--
frac-times
Counts
4 → 272
Calls
4 calls:
Slowest
19.0ms
(* (/ 1 (sqrt (hypot y.im y.re))) (/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))) (hypot y.im y.re)))
17.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))) (hypot y.im y.re))
7.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re)))
2.0ms
(/ 1 (sqrt (hypot y.im y.re)))

series496.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
167.0ms
(/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re)))
142.0ms
(* (/ 1 (sqrt (hypot y.im y.re))) (/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))) (hypot y.im y.re)))
131.0ms
(/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))) (hypot y.im y.re))
56.0ms
(/ 1 (sqrt (hypot y.im y.re)))

simplify18.1s

Counts
317 → 284
Calls
317 calls:
Slowest
538.0ms
(- (* (* y.re x.im) (* y.re x.im)) (* (* x.re y.im) (* x.re y.im)))
471.0ms
(/ (/ (* (cbrt (- (* y.re x.im) (* x.re y.im))) (cbrt (- (* y.re x.im) (* x.re y.im)))) 1) (sqrt (hypot y.im y.re)))
423.0ms
(+ (log (/ 1 (sqrt (hypot y.im y.re)))) (- (log (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re)))) (log (hypot y.im y.re))))
355.0ms
(* 1 (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))))
338.0ms
(* 1 (/ (/ (- (* y.re x.im) (* x.re y.im)) (sqrt (hypot y.im y.re))) (hypot y.im y.re)))

prune4.0s

Pruning

11 alts after pruning (9 fresh and 2 done)

Merged error: 5.5b

regimes445.0ms

Accuracy

34.7% (7.0b remaining)

Error of 12.7b against oracle of 5.7b and baseline of 16.4b

bsearch155.0ms

end0.0ms

sample1.6s

Algorithm
intervals