Average Error: 30.8 → 0.1
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 -2.0145832239889755 \cdot 10^{-11}:\\ \;\;\;\;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 < -2.0145832239889755e-11

    1. Initial program 37.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 0.1

      \[\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 -2.0145832239889755e-11 < y.re

    1. Initial program 27.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -2.0145832239889755 \cdot 10^{-11}:\\ \;\;\;\;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 2018362 
(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: 15.4s)Debug log

start5.3s

Algorithm
intervals

setup140.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.7b

localize52.0ms

Local error

Found 4 expressions with local error:

29.3b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
29.3b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
24.9b
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
0.3b
(* (atan2 x.im x.re) y.im)

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
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)))
3.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
2.0ms
(* (atan2 x.im x.re) y.im)

series226.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify518.0ms

Counts
27 → 59
Calls

27 calls. Slowest were:

151.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
142.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
67.0ms
(cos (- (* (atan2 x.im x.re) y.re) (* y.im (log (/ -1 x.re)))))

prune1.0s

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 17.7b

localize4.0ms

Local error

Found 4 expressions with local error:

29.3b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
0.3b
(* (atan2 x.im x.re) y.im)
0.2b
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
0.0b
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))

rewrite20.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))
5.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
2.0ms
(* (atan2 x.im x.re) y.im)

series227.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

105.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
80.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
26.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
15.0ms
(* (atan2 x.im x.re) y.im)

simplify656.0ms

Counts
23 → 62
Calls

23 calls. Slowest were:

183.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
116.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
89.0ms
(* -1 (* y.re (log (/ 1 x.re))))

prune917.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize34.0ms

Local error

Found 3 expressions with local error:

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

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
3 → 35
Calls

3 calls. Slowest were:

10.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
6.0ms
(* (log (- x.re)) y.re)
5.0ms
(* (atan2 x.im x.re) y.im)

series242.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

151.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
78.0ms
(* (log (- x.re)) y.re)
14.0ms
(* (atan2 x.im x.re) y.im)

simplify397.0ms

Counts
14 → 44
Calls

14 calls. Slowest were:

89.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
79.0ms
(- (* y.re (log -1)) (+ (* y.im (atan2 x.im x.re)) (* y.re (log (/ 1 x.re)))))
69.0ms
(- (+ (* y.re (log -1)) (* y.re (log x.re))) (* y.im (atan2 x.im x.re)))

prune684.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.1b

localize30.0ms

Local error

Found 3 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
3 → 34
Calls

3 calls. Slowest were:

6.0ms
(- (* y.re (log x.im)) (* (atan2 x.im x.re) y.im))
5.0ms
(* (atan2 x.im x.re) y.im)
2.0ms
(* y.re (log x.im))

series162.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

99.0ms
(- (* y.re (log x.im)) (* (atan2 x.im x.re) y.im))
41.0ms
(* y.re (log x.im))
22.0ms
(* (atan2 x.im x.re) y.im)

simplify456.0ms

Counts
15 → 43
Calls

15 calls. Slowest were:

189.0ms
(- (* y.re (log -1)) (+ (* y.re (log (/ -1 x.im))) (* y.im (atan2 x.im x.re))))
106.0ms
(* y.re (- (log -1) (log (/ -1 x.im))))
62.0ms
(* -1 (* y.re (log (/ 1 x.im))))

prune494.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0.1b

regimes287.0ms

Accuracy

98.2% (0.1b remaining)

Error of 0.1b against oracle of 0.0b and baseline of 7.1b

bsearch3.4s