Average Error: 31.0 → 0.3
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 -9.036063513144656 \cdot 10^{-18}:\\ \;\;\;\;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 < -9.036063513144656e-18

    1. Initial program 37.4

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

      \[\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 -9.036063513144656e-18 < 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 25.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -9.036063513144656 \cdot 10^{-18}:\\ \;\;\;\;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 2019022 
(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.3s

Algorithm
intervals
Results
4.1s1022×body10240exit
96.0ms256×body80valid

simplify120.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
120.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))))

prune18.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.7b

localize56.0ms

Local error

Found 4 expressions with local error:

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

rewrite32.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
cos-sum
Counts
4 → 49
Calls
4 calls:
Slowest
17.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
7.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)
4.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
2.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series312.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
157.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
90.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im)
40.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
25.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify605.0ms

Counts
27 → 61
Calls
27 calls:
Slowest
124.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
105.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
75.0ms
(cos (- (* (atan2 x.im x.re) y.re) (* y.im (log (/ -1 x.re)))))
75.0ms
(* -1 (* y.im (log (/ 1 x.re))))
63.0ms
(* -1 (* y.im (log (/ -1 x.re))))

prune1.1s

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 12.6b

localize7.0ms

Local error

Found 4 expressions with local error:

28.2b
(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))

rewrite25.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)))

series275.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
129.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
101.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
30.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
15.0ms
(* (atan2 x.im x.re) y.im)

simplify547.0ms

Counts
23 → 62
Calls
23 calls:
Slowest
165.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
102.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
66.0ms
(* -1 (* y.re (log (/ -1 x.re))))
65.0ms
(* -1 (* y.re (log (/ 1 x.re))))
34.0ms
(sqrt (+ (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)))

prune910.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize30.0ms

Local error

Found 3 expressions with local error:

0.2b
(* (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))

rewrite21.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
9.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)

series211.0ms

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

simplify449.0ms

Counts
14 → 44
Calls
14 calls:
Slowest
121.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
94.0ms
(* -1 (* y.re (log (/ -1 x.re))))
93.0ms
(- (* y.re (log -1)) (+ (* y.im (atan2 x.im x.re)) (* y.re (log (/ 1 x.re)))))
63.0ms
(- (+ (* y.re (log -1)) (* y.re (log x.re))) (* y.im (atan2 x.im x.re)))
29.0ms
(* y.re (- (log -1) (log (/ 1 x.re))))

prune575.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize20.0ms

Local error

Found 3 expressions with local error:

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

rewrite19.0ms

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

series196.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
102.0ms
(- (* (log x.im) y.re) (* (atan2 x.im x.re) y.im))
73.0ms
(* (log x.im) y.re)
21.0ms
(* (atan2 x.im x.re) y.im)

simplify442.0ms

Counts
14 → 43
Calls
14 calls:
Slowest
225.0ms
(- (* y.re (log -1)) (+ (* y.re (log (/ -1 x.im))) (* y.im (atan2 x.im x.re))))
62.0ms
(* -1 (* y.re (log (/ 1 x.im))))
53.0ms
(* y.re (- (log -1) (log (/ -1 x.im))))
45.0ms
(- (+ (* y.re (log (/ 1 x.im))) (* y.im (atan2 x.im x.re))))
29.0ms
(/ (exp (* (log x.im) y.re)) (exp (* (atan2 x.im x.re) y.im)))

prune483.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes345.0ms

Accuracy

95.6% (0.3b remaining)

Error of 0.3b against oracle of 0.0b and baseline of 7.0b

bsearch1.8s

end0.0ms

sample2.1m

Algorithm
intervals
Results
2.0m29728×body10240exit
4.0s8000×body80valid