Average Error: 30.7 → 0.2
Time: 2.4m
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 -7.152739789478762 \cdot 10^{-15}:\\ \;\;\;\;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 < -7.152739789478762e-15

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

      \[\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 -7.152739789478762e-15 < y.re

    1. Initial program 27.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \le -7.152739789478762 \cdot 10^{-15}:\\ \;\;\;\;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 2019016 
(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.4m)Debug log

sample4.3s

Algorithm
intervals
Results
1234×(pre true 80)
977×(body exit 10240)
257×(body real 80)

simplify458.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
458.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.0b

localize43.0ms

Local error

Found 4 expressions with local error:

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

rewrite47.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
29.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.re)
4.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
4.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series286.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
144.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
81.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
31.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
30.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify668.0ms

Counts
27 → 61
Calls
27 calls:
Slowest
150.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
118.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
81.0ms
(cos (- (* (atan2 x.im x.re) y.re) (* y.im (log (/ -1 x.re)))))
81.0ms
(* -1 (* y.re (log (/ 1 x.re))))
76.0ms
(* -1 (* y.re (log (/ -1 x.re))))

prune1.1s

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 15.7b

localize8.0ms

Local error

Found 4 expressions with local error:

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

rewrite28.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
12.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
6.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)))

series273.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
134.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
86.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
32.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
22.0ms
(* (atan2 x.im x.re) y.im)

simplify501.0ms

Counts
23 → 62
Calls
23 calls:
Slowest
107.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
101.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
73.0ms
(* -1 (* y.re (log (/ -1 x.re))))
63.0ms
(* -1 (* y.re (log (/ 1 x.re))))
38.0ms
(/ (exp (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)) (exp (* (atan2 x.im x.re) y.im)))

prune847.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite20.0ms

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

series322.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
117.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
102.0ms
(* (log (- x.re)) y.re)
89.0ms
(exp (- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im)))
13.0ms
(* (atan2 x.im x.re) y.im)

simplify1.1s

Counts
25 → 62
Calls
25 calls:
Slowest
226.0ms
(exp (- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re)))))
172.0ms
(exp (- (* y.re (log -1)) (+ (* y.im (atan2 x.im x.re)) (* y.re (log (/ 1 x.re))))))
159.0ms
(- (+ (* y.re (log -1)) (+ (* y.re (log x.re)) 1)) (* y.im (atan2 x.im x.re)))
129.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
96.0ms
(* -1 (* y.re (log (/ -1 x.re))))

prune846.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize15.0ms

Local error

Found 3 expressions with local error:

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

rewrite6.0ms

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

series129.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
76.0ms
(- (* y.re (log x.im)) (* (atan2 x.im x.re) y.im))
39.0ms
(* y.re (log x.im))
13.0ms
(* (atan2 x.im x.re) y.im)

simplify502.0ms

Counts
15 → 43
Calls
15 calls:
Slowest
212.0ms
(- (* y.re (log -1)) (+ (* y.re (log (/ -1 x.im))) (* y.im (atan2 x.im x.re))))
103.0ms
(* y.re (- (log -1) (log (/ -1 x.im))))
76.0ms
(* -1 (* y.re (log (/ 1 x.im))))
49.0ms
(- (+ (* y.re (log (/ 1 x.im))) (* y.im (atan2 x.im x.re))))
35.0ms
(/ (exp (* y.re (log x.im))) (exp (* (atan2 x.im x.re) y.im)))

prune463.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes339.0ms

Accuracy

97.8% (0.2b remaining)

Error of 0.2b against oracle of 0.0b and baseline of 7.6b

bsearch2.8s

end0.0ms

sample2.2m

Algorithm
intervals
Results
38786×(pre true 80)
30786×(body exit 10240)
8000×(body real 80)