Average Error: 31.3 → 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 -16394960.105851:\\ \;\;\;\;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 < -16394960.105851

    1. Initial program 37.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 -16394960.105851 < y.re

    1. Initial program 28.0

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

      \[\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 -16394960.105851:\\ \;\;\;\;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 2019010 
(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.4s

Algorithm
intervals

simplify488.0ms

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

prune23.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.4b

localize76.0ms

Local error

Found 4 expressions with local error:

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

rewrite22.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
9.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
4.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
3.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
2.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

series352.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
167.0ms
(cos (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))
97.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
56.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
31.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))

simplify579.0ms

Counts
27 → 61
Calls
27 calls:
Slowest
112.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
107.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
90.0ms
(cos (- (* (atan2 x.im x.re) y.re) (* y.im (log (/ -1 x.re)))))
52.0ms
(sqrt (+ (pow (* x.re x.re) 3) (pow (* x.im x.im) 3)))
52.0ms
(* -1 (* y.re (log (/ 1 x.re))))

prune1.2s

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 19.4b

localize4.0ms

Local error

Found 4 expressions with local error:

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

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

series271.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
124.0ms
(- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))
95.0ms
(* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)
29.0ms
(sqrt (+ (* x.re x.re) (* x.im x.im)))
24.0ms
(* (atan2 x.im x.re) y.im)

simplify476.0ms

Counts
23 → 62
Calls
23 calls:
Slowest
110.0ms
(sqrt (- (* (* x.re x.re) (* x.re x.re)) (* (* x.im x.im) (* x.im x.im))))
82.0ms
(* -1 (* y.re (log (/ 1 x.re))))
72.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
62.0ms
(* -1 (* y.re (log (/ -1 x.re))))
40.0ms
(/ (exp (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re)) (exp (* (atan2 x.im x.re) y.im)))

prune962.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.1b

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

rewrite24.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
13.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)

series256.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
146.0ms
(- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im))
88.0ms
(* (log (- x.re)) y.re)
22.0ms
(* (atan2 x.im x.re) y.im)

simplify450.0ms

Counts
14 → 44
Calls
14 calls:
Slowest
116.0ms
(- (+ (* y.re (log (/ -1 x.re))) (* y.im (atan2 x.im x.re))))
95.0ms
(* -1 (* y.re (log (/ -1 x.re))))
86.0ms
(- (* y.re (log -1)) (+ (* y.im (atan2 x.im x.re)) (* y.re (log (/ 1 x.re)))))
57.0ms
(- (+ (* y.re (log -1)) (* y.re (log x.re))) (* y.im (atan2 x.im x.re)))
35.0ms
(/ (exp (* (log (- x.re)) y.re)) (exp (* (atan2 x.im x.re) y.im)))

prune605.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0.1b

regimes261.0ms

Accuracy

98.1% (0.1b remaining)

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

bsearch2.1s

end0.0ms

sample2.2m

Algorithm
intervals