Average Error: 30.8 → 0.5
Time: 3.1m
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 \cos \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}\;y.re \le -1.197397631785189 \cdot 10^{+17}:\\ \;\;\;\;e^{\log \left(\sqrt{x.im \cdot x.im + x.re \cdot x.re}\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log \left(-x.re\right) - \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 y.re < -1.197397631785189e+17

    1. Initial program 36.8

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

      \[\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 \color{blue}{1}\]

    if -1.197397631785189e+17 < y.re

    1. Initial program 28.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 \cos \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 0 24.9

      \[\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 \color{blue}{1}\]
    3. Taylor expanded around -inf 0.7

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

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

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

Reproduce

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

Details

Time bar (total: 14.6s)Debug log

start5.7s

Algorithm
intervals

setup144.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 33.7b

localize59.0ms

Local error

Found 4 expressions with local error:

32.1b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
32.1b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
25.7b
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
0.3b
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
4 → 49
Calls

4 calls. Slowest were:

9.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
5.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
3.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series290.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

163.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
77.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
28.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
20.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify684.0ms

Counts
27 → 61
Calls

27 calls. Slowest were:

149.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
131.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
86.0ms
(* -1 (* y.re (log (/ -1 x.re))))

prune1.2s

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.2b

localize8.0ms

Local error

Found 4 expressions with local error:

32.1b
(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
(* (atan2 x.im x.re) y.im)
0.0b
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))

rewrite25.0ms

Algorithm
rewrite-expression-head
Counts
4 → 50
Calls

4 calls. Slowest were:

9.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
7.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
4.0ms
(* (atan2 x.im x.re) y.im)

series274.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

153.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
82.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
24.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
15.0ms
(* (atan2 x.im x.re) y.im)

simplify512.0ms

Counts
23 → 62
Calls

23 calls. Slowest were:

171.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
63.0ms
(* -1 (* y.re (log (/ 1 x.re))))
62.0ms
(sqrt (+ (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)))

prune940.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.2b

localize15.0ms

Local error

Found 3 expressions with local error:

0.3b
(* (log (- x.re)) y.re)
0.3b
(* (atan2 x.im x.re) y.im)
0.0b
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
3 → 35
Calls

3 calls. Slowest were:

9.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
3.0ms
(* (atan2 x.im x.re) y.im)
3.0ms
(* (log (- x.re)) y.re)

series240.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

132.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
87.0ms
(* (log (- x.re)) y.re)
20.0ms
(* (atan2 x.im x.re) y.im)

simplify406.0ms

Counts
14 → 44
Calls

14 calls. Slowest were:

98.0ms
(* -1 (* y.re (log (/ -1 x.re))))
92.0ms
(- (* y.re (log -1)) (+ (* y.im (atan2 x.im x.re)) (* y.re (log (/ 1 x.re)))))
68.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))

prune677.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0.2b

regimes258.0ms

Accuracy

94.5% (0.4b remaining)

Error of 0.5b against oracle of 0.1b and baseline of 7.0b

bsearch3.1s