Average Error: 30.9 → 10.8
Time: 3.9m
Precision: 64
Internal Precision: 128
\[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
\[\begin{array}{l} \mathbf{if}\;\sin \left(y.im \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \le 3.432377918335032 \cdot 10^{-39}:\\ \;\;\;\;\sin \left(y.im \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re + y.im \cdot \log \left(-x.re\right)\right) \cdot e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \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 2 regimes
  2. if (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))) < 3.432377918335032e-39

    1. Initial program 0.1

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]

    if 3.432377918335032e-39 < (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re))))

    1. Initial program 61.0

      \[e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    2. Taylor expanded around -inf 21.5

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(-1 \cdot x.re\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    3. Simplified21.5

      \[\leadsto e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(-x.re\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    4. Taylor expanded around -inf 21.3

      \[\leadsto e^{\log \color{blue}{\left(-1 \cdot x.re\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(-x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    5. Simplified21.3

      \[\leadsto e^{\log \color{blue}{\left(-x.re\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(-x.re\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sin \left(y.im \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \le 3.432377918335032 \cdot 10^{-39}:\\ \;\;\;\;\sin \left(y.im \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right) \cdot e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\sin \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re + y.im \cdot \log \left(-x.re\right)\right) \cdot e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]

Reproduce

herbie shell --seed 2019016 
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, imaginary part"
  (* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))

Details

Time bar (total: 3.8m)Debug log

sample6.4s

Algorithm
intervals
Results
1645×(pre true 80)
1389×(body exit 10240)
256×(body real 80)

simplify97.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
96.0ms
(* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re))))

prune18.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.4b

localize65.0ms

Local error

Found 4 expressions with local error:

36.5b
(sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
27.0b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
27.0b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
0.3b
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)

rewrite29.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
sqrt-prod
associate-*l*
pow1
add-log-exp
add-exp-log
sqrt-div
add-cbrt-cube
pow1/2
flip-+
log-pow
flip3-+
rem-sqrt-square
*-commutative
sin-sum
Counts
4 → 49
Calls
4 calls:
Slowest
20.0ms
(sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
3.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)
2.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
2.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series307.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
156.0ms
(sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
88.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)
31.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
31.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify657.0ms

Counts
27 → 61
Calls
27 calls:
Slowest
147.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
106.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
89.0ms
(* -1 (* y.im (log (/ 1 x.re))))
61.0ms
(sqrt (+ (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)))
58.0ms
(* -1 (* y.im (log (/ -1 x.re))))

prune1.2s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 10.2b

localize37.0ms

Local error

Found 4 expressions with local error:

36.5b
(sin (+ (* (log (- x.re)) y.im) (* (atan2 x.im x.re) y.re)))
27.0b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
0.3b
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
0.3b
(* (log (- x.re)) y.im)

rewrite34.0ms

Algorithm
rewrite-expression-head
Rules
associate-*l*
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
pow1
add-log-exp
add-exp-log
add-cbrt-cube
sqrt-prod
log-pow
*-commutative
sqrt-div
pow1/2
flip-+
sin-sum
flip3-+
rem-sqrt-square
Counts
4 → 47
Calls
4 calls:
Slowest
17.0ms
(sin (+ (* (log (- x.re)) y.im) (* (atan2 x.im x.re) y.re)))
6.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
6.0ms
(* (log (- x.re)) y.im)
4.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series357.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
158.0ms
(sin (+ (* (log (- x.re)) y.im) (* (atan2 x.im x.re) y.re)))
93.0ms
(* (log (- x.re)) y.im)
75.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
31.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify742.0ms

Counts
23 → 59
Calls
23 calls:
Slowest
153.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
105.0ms
(sin (- (+ (* (atan2 x.im x.re) y.re) (* y.im (log -1))) (* y.im (log (/ 1 x.re)))))
93.0ms
(* -1 (* y.im (log (/ -1 x.re))))
68.0ms
(* -1 (* y.re (log (/ -1 x.re))))
62.0ms
(* -1 (* y.re (log (/ 1 x.re))))

prune1.3s

Pruning

7 alts after pruning (6 fresh and 1 done)

Merged error: 4.2b

localize25.0ms

Local error

Found 4 expressions with local error:

36.6b
(sin (+ (* (* (cbrt (log (- x.re))) (cbrt (log (- x.re)))) (* (cbrt (log (- x.re))) y.im)) (* (atan2 x.im x.re) y.re)))
27.0b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
0.5b
(* (cbrt (log (- x.re))) (cbrt (log (- x.re))))
0.5b
(cbrt (log (- x.re)))

rewrite60.0ms

Algorithm
rewrite-expression-head
Rules
12×pow1
12×cbrt-prod
11×add-sqr-sqrt
10×add-cube-cbrt
10×*-un-lft-identity
associate-*l*
associate-*r*
add-exp-log
pow1/3
add-log-exp
add-cbrt-cube
sqrt-prod
log-pow
pow-prod-up
pow-prod-down
sqrt-div
flip-+
cbrt-unprod
*-commutative
prod-exp
sin-sum
pow1/2
pow-plus
flip3-+
rem-sqrt-square
pow2
Counts
4 → 64
Calls
4 calls:
Slowest
43.0ms
(sin (+ (* (* (cbrt (log (- x.re))) (cbrt (log (- x.re)))) (* (cbrt (log (- x.re))) y.im)) (* (atan2 x.im x.re) y.re)))
10.0ms
(* (cbrt (log (- x.re))) (cbrt (log (- x.re))))
3.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
1.0ms
(cbrt (log (- x.re)))

series901.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
411.0ms
(* (cbrt (log (- x.re))) (cbrt (log (- x.re))))
333.0ms
(cbrt (log (- x.re)))
126.0ms
(sin (+ (* (* (cbrt (log (- x.re))) (cbrt (log (- x.re)))) (* (cbrt (log (- x.re))) y.im)) (* (atan2 x.im x.re) y.re)))
31.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify591.0ms

Counts
45 → 76
Calls
45 calls:
Slowest
176.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
67.0ms
(pow (pow (- (log -1) (log (/ 1 x.re))) 2) 1/3)
62.0ms
(sin (- (* (atan2 x.im x.re) y.re) (* y.im (log (/ -1 x.re)))))
58.0ms
(sin (- (+ (* (atan2 x.im x.re) y.re) (* y.im (log -1))) (* y.im (log (/ 1 x.re)))))
38.0ms
(pow (pow (+ (log -1) (log x.re)) 2) 1/3)

prune1.7s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 4.2b

localize34.0ms

Local error

Found 4 expressions with local error:

36.6b
(sin (+ (* (cbrt (* (log (- x.re)) (log (- x.re)))) (* (cbrt (log (- x.re))) y.im)) (* (atan2 x.im x.re) y.re)))
27.0b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
0.5b
(* (log (- x.re)) (log (- x.re)))
0.5b
(cbrt (* (log (- x.re)) (log (- x.re))))

rewrite57.0ms

Algorithm
rewrite-expression-head
Rules
11×pow1
10×add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
log-prod
add-exp-log
add-cbrt-cube
add-log-exp
associate-*l*
associate-*r*
distribute-lft-in
distribute-rgt-in
sqrt-prod
log-pow
sqrt-div
neg-mul-1
flip-+
cbrt-unprod
pow-prod-up
*-commutative
prod-exp
pow-prod-down
pow1/3
sin-sum
pow1/2
pow-plus
flip3-+
rem-sqrt-square
pow2
cbrt-prod
Counts
4 → 61
Calls
4 calls:
Slowest
48.0ms
(sin (+ (* (cbrt (* (log (- x.re)) (log (- x.re)))) (* (cbrt (log (- x.re))) y.im)) (* (atan2 x.im x.re) y.re)))
5.0ms
(* (log (- x.re)) (log (- x.re)))
2.0ms
(cbrt (* (log (- x.re)) (log (- x.re))))
2.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series798.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
407.0ms
(cbrt (* (log (- x.re)) (log (- x.re))))
235.0ms
(* (log (- x.re)) (log (- x.re)))
130.0ms
(sin (+ (* (cbrt (* (log (- x.re)) (log (- x.re)))) (* (cbrt (log (- x.re))) y.im)) (* (atan2 x.im x.re) y.re)))
25.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify766.0ms

Counts
40 → 73
Calls
40 calls:
Slowest
108.0ms
(pow (- (log -1) (log (/ 1 x.re))) 2)
106.0ms
(sin (- (+ (* (atan2 x.im x.re) y.re) (* y.im (log -1))) (* y.im (log (/ 1 x.re)))))
90.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
89.0ms
(sin (- (* (atan2 x.im x.re) y.re) (* y.im (log (/ -1 x.re)))))
81.0ms
(pow (pow (- (log -1) (log (/ 1 x.re))) 2) 1/3)

prune1.7s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 4.1b

regimes941.0ms

Accuracy

46% (5.7b remaining)

Error of 10.8b against oracle of 5.1b and baseline of 15.7b

bsearch14.0ms

end0.0ms

sample3.5m

Algorithm
intervals
Results
55647×(pre true 80)
47646×(body exit 10240)
8001×(body real 80)