?

Average Error: 33.6 → 6.9
Time: 11.6s
Precision: binary64
Cost: 39748

?

\[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} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_0}\\ \mathbf{if}\;y.re \leq -3.4 \cdot 10^{-10}:\\ \;\;\;\;t_1 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{-37}:\\ \;\;\;\;e^{-t_0} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot 1\\ \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
 (let* ((t_0 (* (atan2 x.im x.re) y.im))
        (t_1
         (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) t_0))))
   (if (<= y.re -3.4e-10)
     (* t_1 (cos (* y.re (atan2 x.im x.re))))
     (if (<= y.re 5.8e-37) (* (exp (- t_0)) 1.0) (* t_1 1.0)))))
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 t_0 = atan2(x_46_im, x_46_re) * y_46_im;
	double t_1 = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_0));
	double tmp;
	if (y_46_re <= -3.4e-10) {
		tmp = t_1 * cos((y_46_re * atan2(x_46_im, x_46_re)));
	} else if (y_46_re <= 5.8e-37) {
		tmp = exp(-t_0) * 1.0;
	} else {
		tmp = t_1 * 1.0;
	}
	return tmp;
}
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    code = exp(((log(sqrt(((x_46re * x_46re) + (x_46im * x_46im)))) * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((log(sqrt(((x_46re * x_46re) + (x_46im * x_46im)))) * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
real(8) function code(x_46re, x_46im, y_46re, y_46im)
    real(8), intent (in) :: x_46re
    real(8), intent (in) :: x_46im
    real(8), intent (in) :: y_46re
    real(8), intent (in) :: y_46im
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = atan2(x_46im, x_46re) * y_46im
    t_1 = exp(((log(sqrt(((x_46re * x_46re) + (x_46im * x_46im)))) * y_46re) - t_0))
    if (y_46re <= (-3.4d-10)) then
        tmp = t_1 * cos((y_46re * atan2(x_46im, x_46re)))
    else if (y_46re <= 5.8d-37) then
        tmp = exp(-t_0) * 1.0d0
    else
        tmp = t_1 * 1.0d0
    end if
    code = tmp
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	return Math.exp(((Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_im) + (Math.atan2(x_46_im, x_46_re) * y_46_re)));
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
	double t_0 = Math.atan2(x_46_im, x_46_re) * y_46_im;
	double t_1 = Math.exp(((Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_0));
	double tmp;
	if (y_46_re <= -3.4e-10) {
		tmp = t_1 * Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
	} else if (y_46_re <= 5.8e-37) {
		tmp = Math.exp(-t_0) * 1.0;
	} else {
		tmp = t_1 * 1.0;
	}
	return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	return math.exp(((math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
def code(x_46_re, x_46_im, y_46_re, y_46_im):
	t_0 = math.atan2(x_46_im, x_46_re) * y_46_im
	t_1 = math.exp(((math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_0))
	tmp = 0
	if y_46_re <= -3.4e-10:
		tmp = t_1 * math.cos((y_46_re * math.atan2(x_46_im, x_46_re)))
	elif y_46_re <= 5.8e-37:
		tmp = math.exp(-t_0) * 1.0
	else:
		tmp = t_1 * 1.0
	return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	return Float64(exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re))))
end
function code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = Float64(atan(x_46_im, x_46_re) * y_46_im)
	t_1 = exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - t_0))
	tmp = 0.0
	if (y_46_re <= -3.4e-10)
		tmp = Float64(t_1 * cos(Float64(y_46_re * atan(x_46_im, x_46_re))));
	elseif (y_46_re <= 5.8e-37)
		tmp = Float64(exp(Float64(-t_0)) * 1.0);
	else
		tmp = Float64(t_1 * 1.0);
	end
	return tmp
end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im)
	tmp = 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)));
end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im)
	t_0 = atan2(x_46_im, x_46_re) * y_46_im;
	t_1 = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_0));
	tmp = 0.0;
	if (y_46_re <= -3.4e-10)
		tmp = t_1 * cos((y_46_re * atan2(x_46_im, x_46_re)));
	elseif (y_46_re <= 5.8e-37)
		tmp = exp(-t_0) * 1.0;
	else
		tmp = t_1 * 1.0;
	end
	tmp_2 = tmp;
end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$46$re, -3.4e-10], N[(t$95$1 * N[Cos[N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 5.8e-37], N[(N[Exp[(-t$95$0)], $MachinePrecision] * 1.0), $MachinePrecision], N[(t$95$1 * 1.0), $MachinePrecision]]]]]
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}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_0}\\
\mathbf{if}\;y.re \leq -3.4 \cdot 10^{-10}:\\
\;\;\;\;t_1 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\

\mathbf{elif}\;y.re \leq 5.8 \cdot 10^{-37}:\\
\;\;\;\;e^{-t_0} \cdot 1\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot 1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if y.re < -3.40000000000000015e-10

    1. Initial program 37.1

      \[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 in y.im around 0 1.5

      \[\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)} \]

    if -3.40000000000000015e-10 < y.re < 5.80000000000000009e-37

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

      \[\leadsto \color{blue}{e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}} \cdot 1 \]

    if 5.80000000000000009e-37 < y.re

    1. Initial program 23.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 in y.im around 0 16.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}{\cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)} \]
    3. Taylor expanded in y.re around 0 16.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. Recombined 3 regimes into one program.
  4. Final simplification6.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;y.re \leq -3.4 \cdot 10^{-10}:\\ \;\;\;\;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(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{-37}:\\ \;\;\;\;e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;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 1\\ \end{array} \]

Alternatives

Alternative 1
Error6.9
Cost26888
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_0} \cdot 1\\ \mathbf{if}\;y.re \leq -8.5 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq 5.8 \cdot 10^{-37}:\\ \;\;\;\;e^{-t_0} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error7.0
Cost26244
\[\begin{array}{l} \mathbf{if}\;y.re \leq -1.5:\\ \;\;\;\;{\left(\sqrt{{x.re}^{2} + {x.im}^{2}}\right)}^{y.re} \cdot 1\\ \mathbf{elif}\;y.re \leq 7.2 \cdot 10^{+58}:\\ \;\;\;\;e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;{x.im}^{y.re} \cdot 1\\ \end{array} \]
Alternative 3
Error13.5
Cost13776
\[\begin{array}{l} t_0 := {x.im}^{y.re} \cdot 1\\ \mathbf{if}\;y.re \leq -2.65 \cdot 10^{+191}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq -2.15 \cdot 10^{+110}:\\ \;\;\;\;{x.re}^{y.re} \cdot 1\\ \mathbf{elif}\;y.re \leq -2.4 \cdot 10^{+35}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 6.8 \cdot 10^{+59}:\\ \;\;\;\;e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error7.3
Cost13636
\[\begin{array}{l} \mathbf{if}\;y.re \leq -1100000:\\ \;\;\;\;{\left(0.5 \cdot \frac{{x.re}^{2}}{x.im} + x.im\right)}^{y.re} \cdot 1\\ \mathbf{elif}\;y.re \leq 2 \cdot 10^{+70}:\\ \;\;\;\;e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;{x.im}^{y.re} \cdot 1\\ \end{array} \]
Alternative 5
Error23.3
Cost7504
\[\begin{array}{l} t_0 := {x.re}^{y.re} \cdot 1\\ \mathbf{if}\;y.re \leq -8 \cdot 10^{+190}:\\ \;\;\;\;{x.im}^{y.re} \cdot 1\\ \mathbf{elif}\;y.re \leq -3.2 \cdot 10^{+117}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq -2 \cdot 10^{-27}:\\ \;\;\;\;{\left(x.im \cdot -1\right)}^{y.re} \cdot 1\\ \mathbf{elif}\;y.re \leq 1.1 \cdot 10^{-16}:\\ \;\;\;\;\left(1 + \left(-y.im \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error22.9
Cost7184
\[\begin{array}{l} t_0 := {x.im}^{y.re} \cdot 1\\ t_1 := {x.re}^{y.re} \cdot 1\\ \mathbf{if}\;y.re \leq -1.4 \cdot 10^{+191}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq -5 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq -1.95:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 0.41:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error22.9
Cost7184
\[\begin{array}{l} t_0 := {x.re}^{y.re} \cdot 1\\ \mathbf{if}\;y.re \leq -2.25 \cdot 10^{+191}:\\ \;\;\;\;{x.im}^{y.re} \cdot 1\\ \mathbf{elif}\;y.re \leq -2.85 \cdot 10^{+119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq -4.9 \cdot 10^{-8}:\\ \;\;\;\;{\left(x.im \cdot -1\right)}^{y.re} \cdot 1\\ \mathbf{elif}\;y.re \leq 0.34:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error23.5
Cost7048
\[\begin{array}{l} \mathbf{if}\;x.im \leq -7 \cdot 10^{-264}:\\ \;\;\;\;{\left(x.im \cdot -1\right)}^{y.re} \cdot 1\\ \mathbf{elif}\;x.im \leq 3.5 \cdot 10^{-82}:\\ \;\;\;\;{\left(x.re \cdot -1\right)}^{y.re} \cdot 1\\ \mathbf{else}:\\ \;\;\;\;{x.im}^{y.re} \cdot 1\\ \end{array} \]
Alternative 9
Error23.4
Cost6920
\[\begin{array}{l} t_0 := {x.im}^{y.re} \cdot 1\\ \mathbf{if}\;y.re \leq -1.2:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y.re \leq 3.5:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error38.9
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023053 
(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)))))