Average Error: 33.1 → 5.4
Time: 2.8min
Precision: binary64
Cost: 39874
\[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}\;x.re \leq -9.437066424131207 \cdot 10^{+101}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;x.re \leq 8.213506235332776 \cdot 10^{-56}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log \left(\left|x.im\right|\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]
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}\;x.re \leq -9.437066424131207 \cdot 10^{+101}:\\
\;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\

\mathbf{elif}\;x.re \leq 8.213506235332776 \cdot 10^{-56}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log \left(\left|x.im\right|\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\mathbf{else}:\\
\;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\

\end{array}
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (*
  (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)))))
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (<= x.re -9.437066424131207e+101)
   (*
    (exp (- (* (log (- x.re)) y.re) (* (atan2 x.im x.re) y.im)))
    (cos (* y.re (atan2 x.im x.re))))
   (if (<= x.re 8.213506235332776e-56)
     (*
      (cos (* y.re (atan2 x.im x.re)))
      (exp (- (* y.re (log (fabs x.im))) (* (atan2 x.im x.re) y.im))))
     (*
      (cos (* y.re (atan2 x.im x.re)))
      (exp (- (* y.re (log x.re)) (* (atan2 x.im x.re) y.im)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return exp((log(sqrt((x_46_re * x_46_re) + (x_46_im * x_46_im))) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)) * cos((log(sqrt((x_46_re * x_46_re) + (x_46_im * x_46_im))) * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re));
}
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double tmp;
	if (x_46_re <= -9.437066424131207e+101) {
		tmp = exp((log(-x_46_re) * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im)) * cos(y_46_re * atan2(x_46_im, x_46_re));
	} else if (x_46_re <= 8.213506235332776e-56) {
		tmp = cos(y_46_re * atan2(x_46_im, x_46_re)) * exp((y_46_re * log(fabs(x_46_im))) - (atan2(x_46_im, x_46_re) * y_46_im));
	} else {
		tmp = cos(y_46_re * atan2(x_46_im, x_46_re)) * exp((y_46_re * log(x_46_re)) - (atan2(x_46_im, x_46_re) * y_46_im));
	}
	return tmp;
}

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

Alternatives

Alternative 1
Error4.5
Cost39553
\[\begin{array}{l} \mathbf{if}\;y.re \leq -80956213304966.22:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log \left(\left|x.re\right|\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]
Alternative 2
Error8.9
Cost33481
\[\begin{array}{l} \mathbf{if}\;x.re \leq -2.6615346232889 \cdot 10^{-310}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;x.re \leq 6.050372847421959 \cdot 10^{-137} \lor \neg \left(x.re \leq 8.213506235332776 \cdot 10^{-56}\right):\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \end{array}\]
Alternative 3
Error11.3
Cost33802
\[\begin{array}{l} \mathbf{if}\;x.re \leq -1.9239150977086479 \cdot 10^{-31}:\\ \;\;\;\;\frac{{\left(-x.re\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \mathbf{elif}\;x.re \leq 8.8604533274285 \cdot 10^{-310}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.re \leq 5.2362255579481547 \cdot 10^{-138} \lor \neg \left(x.re \leq 7.585723575808189 \cdot 10^{-56}\right):\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \end{array}\]
Alternative 4
Error13.9
Cost28429
\[\begin{array}{l} \mathbf{if}\;x.im \leq -6.236497842777764 \cdot 10^{+65}:\\ \;\;\;\;\frac{{\left(-x.im\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \mathbf{elif}\;x.im \leq -1.432227224093284 \cdot 10^{-191}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{elif}\;x.im \leq -3.337876888210069 \cdot 10^{-216}:\\ \;\;\;\;\frac{{\left(-x.im\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \mathbf{elif}\;x.im \leq -3.0103639225785356 \cdot 10^{-270}:\\ \;\;\;\;{\left(-x.re\right)}^{y.re}\\ \mathbf{elif}\;x.im \leq 2.107910171741242 \cdot 10^{-304}:\\ \;\;\;\;\frac{{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \mathbf{elif}\;x.im \leq 1.1180088059793839 \cdot 10^{-163} \lor \neg \left(x.im \leq 1.0099943610527774 \cdot 10^{-89}\right):\\ \;\;\;\;\frac{{x.im}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;e^{y.re \cdot \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]
Alternative 5
Error17.2
Cost28037
\[\begin{array}{l} \mathbf{if}\;y.im \leq -3.987264733662572 \cdot 10^{+32}:\\ \;\;\;\;0\\ \mathbf{elif}\;y.im \leq -3.250382936462931 \cdot 10^{-117}:\\ \;\;\;\;1\\ \mathbf{elif}\;y.im \leq -4.528852455716918 \cdot 10^{-270}:\\ \;\;\;\;{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}\\ \mathbf{elif}\;y.im \leq 2.2969899053499743 \cdot 10^{-151}:\\ \;\;\;\;1\\ \mathbf{elif}\;y.im \leq 0.383540112365557:\\ \;\;\;\;\frac{{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}}{e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 6
Error17.3
Cost14917
\[\begin{array}{l} \mathbf{if}\;y.im \leq -3.987264733662572 \cdot 10^{+32}:\\ \;\;\;\;0\\ \mathbf{elif}\;y.im \leq -4.159872953407092 \cdot 10^{-119}:\\ \;\;\;\;1\\ \mathbf{elif}\;y.im \leq -4.3307682141839085 \cdot 10^{-270}:\\ \;\;\;\;{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}\\ \mathbf{elif}\;y.im \leq 1.749782679206405 \cdot 10^{-150}:\\ \;\;\;\;1\\ \mathbf{elif}\;y.im \leq 0.2511710447084123:\\ \;\;\;\;{\left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)}^{y.re}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 7
Error18.6
Cost1348
\[\begin{array}{l} \mathbf{if}\;y.im \leq -3.987264733662572 \cdot 10^{+32}:\\ \;\;\;\;0\\ \mathbf{elif}\;y.im \leq 1.7459411491827386 \cdot 10^{-149}:\\ \;\;\;\;1\\ \mathbf{elif}\;y.im \leq 2.0834915756950648 \cdot 10^{-131}:\\ \;\;\;\;0\\ \mathbf{elif}\;y.im \leq 1.1269981410690433 \cdot 10^{-05}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 8
Error39.3
Cost64
\[1\]

Error

Time

Derivation

  1. Split input into 3 regimes
  2. if x.re < -9.4370664241312073e101

    1. Initial program 51.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 29.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}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\]
    3. Simplified29.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}{\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\]
    4. Taylor expanded around -inf 1.0

      \[\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 \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    5. Simplified1.0

      \[\leadsto e^{\log \color{blue}{\left(-x.re\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    6. Simplified1.0

      \[\leadsto \color{blue}{e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\]

    if -9.4370664241312073e101 < x.re < 8.2135062353327755e-56

    1. Initial program 22.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 12.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}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\]
    3. Simplified12.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}{\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt_binary6412.8

      \[\leadsto e^{\log \left(\sqrt{\color{blue}{\sqrt{x.re \cdot x.re + x.im \cdot x.im} \cdot \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(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    6. Applied rem-sqrt-square_binary6412.8

      \[\leadsto e^{\log \color{blue}{\left(\left|\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right|\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    7. Taylor expanded around 0 2.7

      \[\leadsto e^{\log \left(\left|\color{blue}{x.im}\right|\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    8. Simplified2.7

      \[\leadsto \color{blue}{e^{\log \left(\left|x.im\right|\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\]

    if 8.2135062353327755e-56 < x.re

    1. Initial program 40.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 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}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)}\]
    3. Simplified25.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}{\cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\]
    4. Taylor expanded around inf 12.2

      \[\leadsto e^{\log \color{blue}{x.re} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\]
    5. Simplified12.2

      \[\leadsto \color{blue}{e^{\log x.re \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification5.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.re \leq -9.437066424131207 \cdot 10^{+101}:\\ \;\;\;\;e^{\log \left(-x.re\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;x.re \leq 8.213506235332776 \cdot 10^{-56}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log \left(\left|x.im\right|\right) - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \cdot e^{y.re \cdot \log x.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\\ \end{array}\]

Reproduce

herbie shell --seed 2021040 
(FPCore (x.re x.im y.re y.im)
  :name "powComplex, real part"
  :precision binary64
  (* (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)))))