Average Error: 30.2 → 0.2
Time: 2.3m
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 -24629.11920961697:\\ \;\;\;\;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 < -24629.11920961697

    1. Initial program 36.3

      \[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 -24629.11920961697 < y.re

    1. Initial program 27.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -24629.11920961697:\\ \;\;\;\;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 2019018 
(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: 2.3m)Debug log

sample4.0s

Algorithm
intervals
Results
3.7s909×body10240exit
76.0ms256×body80valid

simplify80.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
79.0ms
(* (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))))

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.5b

localize53.0ms

Local error

Found 4 expressions with local error:

28.3b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
28.3b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
23.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.re)

rewrite20.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
sqrt-prod
add-log-exp
add-exp-log
sqrt-div
add-cbrt-cube
pow1
associate-*l*
flip-+
pow1/2
flip3-+
rem-sqrt-square
*-commutative
cos-sum
Counts
4 → 47
Calls
4 calls:
Slowest
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)))
3.0ms
(* (atan2 x.im x.re) y.re)
2.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series228.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
155.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
36.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
18.0ms
(* (atan2 x.im x.re) y.re)
18.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify470.0ms

Counts
27 → 59
Calls
27 calls:
Slowest
123.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
122.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
57.0ms
(cos (- (* (atan2 x.im x.re) y.re) (* y.im (log (/ -1 x.re)))))
49.0ms
(sqrt (+ (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)))
31.0ms
(sqrt (+ (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)))

prune1.0s

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 16.5b

localize8.0ms

Local error

Found 4 expressions with local error:

28.3b
(sqrt (+ (* x.re x.re) (* x.im x.im)))
0.3b
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
0.2b
(* (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))

rewrite26.0ms

Algorithm
rewrite-expression-head
Rules
associate-*l*
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
pow1
add-exp-log
add-cbrt-cube
sqrt-prod
*-commutative
log-pow
sqrt-div
pow1/2
flip--
flip-+
diff-log
flip3--
flip3-+
sub-neg
rem-sqrt-square
Counts
4 → 50
Calls
4 calls:
Slowest
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)
5.0ms
(* (atan2 x.im x.re) y.im)
4.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series223.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
113.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
78.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
20.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
13.0ms
(* (atan2 x.im x.re) y.im)

simplify567.0ms

Counts
23 → 62
Calls
23 calls:
Slowest
115.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
94.0ms
(* -1 (* y.re (log (/ -1 x.re))))
88.0ms
(* -1 (* y.re (log (/ 1 x.re))))
88.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
53.0ms
(/ (exp (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)) (exp (* (atan2 x.im x.re) y.im)))

prune824.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize26.0ms

Local error

Found 3 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
associate-*l*
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
pow1
add-exp-log
add-cbrt-cube
*-commutative
flip--
log-pow
diff-log
flip3--
sub-neg
Counts
3 → 35
Calls
3 calls:
Slowest
4.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
3.0ms
(* (log (- x.re)) y.re)
3.0ms
(* (atan2 x.im x.re) y.im)

series208.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
128.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
64.0ms
(* (log (- x.re)) y.re)
15.0ms
(* (atan2 x.im x.re) y.im)

simplify361.0ms

Counts
14 → 44
Calls
14 calls:
Slowest
102.0ms
(- (* y.re (log -1)) (+ (* y.im (atan2 x.im x.re)) (* y.re (log (/ 1 x.re)))))
66.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
47.0ms
(- (+ (* y.re (log -1)) (* y.re (log x.re))) (* y.im (atan2 x.im x.re)))
47.0ms
(* -1 (* y.re (log (/ -1 x.re))))
40.0ms
(* y.re (- (log -1) (log (/ 1 x.re))))

prune569.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes292.0ms

Accuracy

98.4% (0.1b remaining)

Error of 0.2b against oracle of 0.1b and baseline of 7.7b

bsearch2.4s

end0.0ms

sample2.1m

Algorithm
intervals
Results
2.0m29962×body10240exit
3.3s8000×body80valid