
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
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
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * 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.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (log (sqrt (+ (* x.re x.re) (* x.im x.im))))))
(*
(exp (- (* t_0 y.re) (* (atan2 x.im x.re) y.im)))
(cos (+ (* t_0 y.im) (* (atan2 x.im x.re) y.re))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re)));
}
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
t_0 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
code = exp(((t_0 * y_46re) - (atan2(x_46im, x_46re) * y_46im))) * cos(((t_0 * y_46im) + (atan2(x_46im, x_46re) * y_46re)))
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
return Math.exp(((t_0 * y_46_re) - (Math.atan2(x_46_im, x_46_re) * y_46_im))) * Math.cos(((t_0 * 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.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) return math.exp(((t_0 * y_46_re) - (math.atan2(x_46_im, x_46_re) * y_46_im))) * math.cos(((t_0 * y_46_im) + (math.atan2(x_46_im, x_46_re) * y_46_re)))
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) return Float64(exp(Float64(Float64(t_0 * y_46_re) - Float64(atan(x_46_im, x_46_re) * y_46_im))) * cos(Float64(Float64(t_0 * y_46_im) + Float64(atan(x_46_im, x_46_re) * y_46_re)))) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); tmp = exp(((t_0 * y_46_re) - (atan2(x_46_im, x_46_re) * y_46_im))) * cos(((t_0 * y_46_im) + (atan2(x_46_im, x_46_re) * y_46_re))); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(N[(t$95$0 * y$46$re), $MachinePrecision] - N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(t$95$0 * y$46$im), $MachinePrecision] + N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
e^{t\_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \cos \left(t\_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\end{array}
\end{array}
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im))
(t_1 (* y.re (atan2 x.im x.re)))
(t_2
(exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) t_0))))
(if (<= y.re -1.08e-63)
(* t_2 (cos t_1))
(if (<= y.re 1.2e-17)
(* (/ 1.0 (exp t_0)) (cos (fma (log (hypot x.re x.im)) y.im t_1)))
t_2))))
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 = y_46_re * atan2(x_46_im, x_46_re);
double t_2 = 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 <= -1.08e-63) {
tmp = t_2 * cos(t_1);
} else if (y_46_re <= 1.2e-17) {
tmp = (1.0 / exp(t_0)) * cos(fma(log(hypot(x_46_re, x_46_im)), y_46_im, t_1));
} else {
tmp = t_2;
}
return tmp;
}
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 = Float64(y_46_re * atan(x_46_im, x_46_re)) t_2 = 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 <= -1.08e-63) tmp = Float64(t_2 * cos(t_1)); elseif (y_46_re <= 1.2e-17) tmp = Float64(Float64(1.0 / exp(t_0)) * cos(fma(log(hypot(x_46_re, x_46_im)), y_46_im, t_1))); else tmp = t_2; end return tmp end
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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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, -1.08e-63], N[(t$95$2 * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.2e-17], N[(N[(1.0 / N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(N[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision] * y$46$im + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_2 := 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 -1.08 \cdot 10^{-63}:\\
\;\;\;\;t\_2 \cdot \cos t\_1\\
\mathbf{elif}\;y.re \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{e^{t\_0}} \cdot \cos \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, t\_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if y.re < -1.07999999999999994e-63Initial program 40.3%
Taylor expanded in y.im around 0 80.9%
if -1.07999999999999994e-63 < y.re < 1.19999999999999993e-17Initial program 38.9%
exp-diff38.9%
exp-to-pow38.9%
hypot-define38.9%
*-commutative38.9%
exp-prod38.9%
fma-define38.9%
hypot-define81.5%
*-commutative81.5%
Simplified81.5%
Taylor expanded in y.re around 0 81.5%
if 1.19999999999999993e-17 < y.re Initial program 31.7%
Taylor expanded in y.re around 0 28.6%
+-commutative28.6%
unpow228.6%
unpow228.6%
unpow1/228.6%
exp-to-pow28.6%
*-commutative28.6%
rem-log-exp28.6%
associate-*r*28.6%
Simplified28.6%
Taylor expanded in x.re around 0 27.0%
unpow227.0%
Simplified27.0%
Taylor expanded in y.im around 0 68.3%
Final simplification78.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im))
(t_1 (+ (* x.re x.re) (* x.im x.im)))
(t_2 (log (sqrt t_1)))
(t_3 (exp (- (* t_2 y.re) t_0)))
(t_4 (* (* y.im 0.5) (log t_1))))
(if (<= (* t_3 (cos (+ (* t_2 y.im) (* y.re (atan2 x.im x.re))))) INFINITY)
(* t_3 (- (cos t_4) (* y.re (* (atan2 x.im x.re) (sin t_4)))))
(/ (pow (hypot x.re x.im) y.re) (exp t_0)))))
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 = (x_46_re * x_46_re) + (x_46_im * x_46_im);
double t_2 = log(sqrt(t_1));
double t_3 = exp(((t_2 * y_46_re) - t_0));
double t_4 = (y_46_im * 0.5) * log(t_1);
double tmp;
if ((t_3 * cos(((t_2 * y_46_im) + (y_46_re * atan2(x_46_im, x_46_re))))) <= ((double) INFINITY)) {
tmp = t_3 * (cos(t_4) - (y_46_re * (atan2(x_46_im, x_46_re) * sin(t_4))));
} else {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / exp(t_0);
}
return tmp;
}
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 = (x_46_re * x_46_re) + (x_46_im * x_46_im);
double t_2 = Math.log(Math.sqrt(t_1));
double t_3 = Math.exp(((t_2 * y_46_re) - t_0));
double t_4 = (y_46_im * 0.5) * Math.log(t_1);
double tmp;
if ((t_3 * Math.cos(((t_2 * y_46_im) + (y_46_re * Math.atan2(x_46_im, x_46_re))))) <= Double.POSITIVE_INFINITY) {
tmp = t_3 * (Math.cos(t_4) - (y_46_re * (Math.atan2(x_46_im, x_46_re) * Math.sin(t_4))));
} else {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / Math.exp(t_0);
}
return tmp;
}
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 = (x_46_re * x_46_re) + (x_46_im * x_46_im) t_2 = math.log(math.sqrt(t_1)) t_3 = math.exp(((t_2 * y_46_re) - t_0)) t_4 = (y_46_im * 0.5) * math.log(t_1) tmp = 0 if (t_3 * math.cos(((t_2 * y_46_im) + (y_46_re * math.atan2(x_46_im, x_46_re))))) <= math.inf: tmp = t_3 * (math.cos(t_4) - (y_46_re * (math.atan2(x_46_im, x_46_re) * math.sin(t_4)))) else: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / math.exp(t_0) return tmp
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 = Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)) t_2 = log(sqrt(t_1)) t_3 = exp(Float64(Float64(t_2 * y_46_re) - t_0)) t_4 = Float64(Float64(y_46_im * 0.5) * log(t_1)) tmp = 0.0 if (Float64(t_3 * cos(Float64(Float64(t_2 * y_46_im) + Float64(y_46_re * atan(x_46_im, x_46_re))))) <= Inf) tmp = Float64(t_3 * Float64(cos(t_4) - Float64(y_46_re * Float64(atan(x_46_im, x_46_re) * sin(t_4))))); else tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / exp(t_0)); end return tmp 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 = (x_46_re * x_46_re) + (x_46_im * x_46_im); t_2 = log(sqrt(t_1)); t_3 = exp(((t_2 * y_46_re) - t_0)); t_4 = (y_46_im * 0.5) * log(t_1); tmp = 0.0; if ((t_3 * cos(((t_2 * y_46_im) + (y_46_re * atan2(x_46_im, x_46_re))))) <= Inf) tmp = t_3 * (cos(t_4) - (y_46_re * (atan2(x_46_im, x_46_re) * sin(t_4)))); else tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / exp(t_0); end tmp_2 = tmp; end
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[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Log[N[Sqrt[t$95$1], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(N[(t$95$2 * y$46$re), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(y$46$im * 0.5), $MachinePrecision] * N[Log[t$95$1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$3 * N[Cos[N[(N[(t$95$2 * y$46$im), $MachinePrecision] + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$3 * N[(N[Cos[t$95$4], $MachinePrecision] - N[(y$46$re * N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * N[Sin[t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := x.re \cdot x.re + x.im \cdot x.im\\
t_2 := \log \left(\sqrt{t\_1}\right)\\
t_3 := e^{t\_2 \cdot y.re - t\_0}\\
t_4 := \left(y.im \cdot 0.5\right) \cdot \log t\_1\\
\mathbf{if}\;t\_3 \cdot \cos \left(t\_2 \cdot y.im + y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right) \leq \infty:\\
\;\;\;\;t\_3 \cdot \left(\cos t\_4 - y.re \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot \sin t\_4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{t\_0}}\\
\end{array}
\end{array}
if (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) < +inf.0Initial program 77.5%
Taylor expanded in y.re around 0 79.9%
mul-1-neg79.9%
unsub-neg79.9%
Simplified79.9%
if +inf.0 < (*.f64 (exp.f64 (-.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.re) (*.f64 (atan2.f64 x.im x.re) y.im))) (cos.f64 (+.f64 (*.f64 (log.f64 (sqrt.f64 (+.f64 (*.f64 x.re x.re) (*.f64 x.im x.im)))) y.im) (*.f64 (atan2.f64 x.im x.re) y.re)))) Initial program 0.0%
exp-diff0.0%
exp-to-pow0.0%
hypot-define0.0%
*-commutative0.0%
exp-prod0.0%
fma-define0.0%
hypot-define69.5%
*-commutative69.5%
Simplified69.5%
Taylor expanded in y.im around 0 70.9%
Taylor expanded in y.re around 0 73.9%
Taylor expanded in y.im around inf 74.7%
*-commutative74.7%
Simplified74.7%
Final simplification77.2%
(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 -7.5e+54)
(* t_1 (cos (* y.re (atan2 x.im x.re))))
(if (<= y.re 1.2e-17) (/ (pow (hypot x.re x.im) y.re) (exp t_0)) t_1))))
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 <= -7.5e+54) {
tmp = t_1 * cos((y_46_re * atan2(x_46_im, x_46_re)));
} else if (y_46_re <= 1.2e-17) {
tmp = pow(hypot(x_46_re, x_46_im), y_46_re) / exp(t_0);
} else {
tmp = t_1;
}
return tmp;
}
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 <= -7.5e+54) {
tmp = t_1 * Math.cos((y_46_re * Math.atan2(x_46_im, x_46_re)));
} else if (y_46_re <= 1.2e-17) {
tmp = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / Math.exp(t_0);
} else {
tmp = t_1;
}
return tmp;
}
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 <= -7.5e+54: tmp = t_1 * math.cos((y_46_re * math.atan2(x_46_im, x_46_re))) elif y_46_re <= 1.2e-17: tmp = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / math.exp(t_0) else: tmp = t_1 return tmp
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 <= -7.5e+54) tmp = Float64(t_1 * cos(Float64(y_46_re * atan(x_46_im, x_46_re)))); elseif (y_46_re <= 1.2e-17) tmp = Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / exp(t_0)); else tmp = t_1; end return tmp 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 <= -7.5e+54) tmp = t_1 * cos((y_46_re * atan2(x_46_im, x_46_re))); elseif (y_46_re <= 1.2e-17) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / exp(t_0); else tmp = t_1; end tmp_2 = tmp; end
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, -7.5e+54], 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, 1.2e-17], N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\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 -7.5 \cdot 10^{+54}:\\
\;\;\;\;t\_1 \cdot \cos \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\
\mathbf{elif}\;y.re \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{e^{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y.re < -7.50000000000000042e54Initial program 44.4%
Taylor expanded in y.im around 0 89.0%
if -7.50000000000000042e54 < y.re < 1.19999999999999993e-17Initial program 37.9%
exp-diff37.9%
exp-to-pow37.9%
hypot-define37.9%
*-commutative37.9%
exp-prod37.9%
fma-define37.9%
hypot-define78.9%
*-commutative78.9%
Simplified78.9%
Taylor expanded in y.im around 0 78.1%
Taylor expanded in y.re around 0 78.8%
Taylor expanded in y.im around inf 78.9%
*-commutative78.9%
Simplified78.9%
if 1.19999999999999993e-17 < y.re Initial program 31.7%
Taylor expanded in y.re around 0 28.6%
+-commutative28.6%
unpow228.6%
unpow228.6%
unpow1/228.6%
exp-to-pow28.6%
*-commutative28.6%
rem-log-exp28.6%
associate-*r*28.6%
Simplified28.6%
Taylor expanded in x.re around 0 27.0%
unpow227.0%
Simplified27.0%
Taylor expanded in y.im around 0 68.3%
Final simplification78.1%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (pow (hypot x.re x.im) y.re)) (t_1 (* (atan2 x.im x.re) y.im)))
(if (<= y.re -80.0)
(/ t_0 (+ t_1 1.0))
(if (<= y.re 1.2e-17)
(/ t_0 (exp t_1))
(exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) t_1))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = pow(hypot(x_46_re, x_46_im), y_46_re);
double t_1 = atan2(x_46_im, x_46_re) * y_46_im;
double tmp;
if (y_46_re <= -80.0) {
tmp = t_0 / (t_1 + 1.0);
} else if (y_46_re <= 1.2e-17) {
tmp = t_0 / exp(t_1);
} else {
tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_1));
}
return tmp;
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
double t_1 = Math.atan2(x_46_im, x_46_re) * y_46_im;
double tmp;
if (y_46_re <= -80.0) {
tmp = t_0 / (t_1 + 1.0);
} else if (y_46_re <= 1.2e-17) {
tmp = t_0 / Math.exp(t_1);
} else {
tmp = Math.exp(((Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_1));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = math.pow(math.hypot(x_46_re, x_46_im), y_46_re) t_1 = math.atan2(x_46_im, x_46_re) * y_46_im tmp = 0 if y_46_re <= -80.0: tmp = t_0 / (t_1 + 1.0) elif y_46_re <= 1.2e-17: tmp = t_0 / math.exp(t_1) else: tmp = math.exp(((math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_1)) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = hypot(x_46_re, x_46_im) ^ y_46_re t_1 = Float64(atan(x_46_im, x_46_re) * y_46_im) tmp = 0.0 if (y_46_re <= -80.0) tmp = Float64(t_0 / Float64(t_1 + 1.0)); elseif (y_46_re <= 1.2e-17) tmp = Float64(t_0 / exp(t_1)); else tmp = exp(Float64(Float64(log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) * y_46_re) - t_1)); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = hypot(x_46_re, x_46_im) ^ y_46_re; t_1 = atan2(x_46_im, x_46_re) * y_46_im; tmp = 0.0; if (y_46_re <= -80.0) tmp = t_0 / (t_1 + 1.0); elseif (y_46_re <= 1.2e-17) tmp = t_0 / exp(t_1); else tmp = exp(((log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) * y_46_re) - t_1)); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, Block[{t$95$1 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, If[LessEqual[y$46$re, -80.0], N[(t$95$0 / N[(t$95$1 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.2e-17], N[(t$95$0 / N[Exp[t$95$1], $MachinePrecision]), $MachinePrecision], 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$1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
t_1 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
\mathbf{if}\;y.re \leq -80:\\
\;\;\;\;\frac{t\_0}{t\_1 + 1}\\
\mathbf{elif}\;y.re \leq 1.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{t\_0}{e^{t\_1}}\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t\_1}\\
\end{array}
\end{array}
if y.re < -80Initial program 41.5%
exp-diff32.1%
exp-to-pow32.1%
hypot-define32.1%
*-commutative32.1%
exp-prod28.3%
fma-define28.3%
hypot-define64.2%
*-commutative64.2%
Simplified64.2%
Taylor expanded in y.im around 0 64.2%
Taylor expanded in y.re around 0 62.3%
Taylor expanded in y.im around 0 79.5%
*-commutative79.5%
Simplified79.5%
if -80 < y.re < 1.19999999999999993e-17Initial program 38.6%
exp-diff38.6%
exp-to-pow38.6%
hypot-define38.6%
*-commutative38.6%
exp-prod38.6%
fma-define38.6%
hypot-define80.5%
*-commutative80.5%
Simplified80.5%
Taylor expanded in y.im around 0 79.7%
Taylor expanded in y.re around 0 79.7%
Taylor expanded in y.im around inf 79.9%
*-commutative79.9%
Simplified79.9%
if 1.19999999999999993e-17 < y.re Initial program 31.7%
Taylor expanded in y.re around 0 28.6%
+-commutative28.6%
unpow228.6%
unpow228.6%
unpow1/228.6%
exp-to-pow28.6%
*-commutative28.6%
rem-log-exp28.6%
associate-*r*28.6%
Simplified28.6%
Taylor expanded in x.re around 0 27.0%
unpow227.0%
Simplified27.0%
Taylor expanded in y.im around 0 68.3%
Final simplification77.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* (atan2 x.im x.re) y.im)) (t_1 (pow (hypot x.re x.im) y.re)))
(if (or (<= y.re -100000.0) (not (<= y.re 2.3e+114)))
(/ t_1 (+ t_0 1.0))
(/ t_1 (exp t_0)))))
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 = pow(hypot(x_46_re, x_46_im), y_46_re);
double tmp;
if ((y_46_re <= -100000.0) || !(y_46_re <= 2.3e+114)) {
tmp = t_1 / (t_0 + 1.0);
} else {
tmp = t_1 / exp(t_0);
}
return tmp;
}
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.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
double tmp;
if ((y_46_re <= -100000.0) || !(y_46_re <= 2.3e+114)) {
tmp = t_1 / (t_0 + 1.0);
} else {
tmp = t_1 / Math.exp(t_0);
}
return tmp;
}
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.pow(math.hypot(x_46_re, x_46_im), y_46_re) tmp = 0 if (y_46_re <= -100000.0) or not (y_46_re <= 2.3e+114): tmp = t_1 / (t_0 + 1.0) else: tmp = t_1 / math.exp(t_0) return tmp
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 = hypot(x_46_re, x_46_im) ^ y_46_re tmp = 0.0 if ((y_46_re <= -100000.0) || !(y_46_re <= 2.3e+114)) tmp = Float64(t_1 / Float64(t_0 + 1.0)); else tmp = Float64(t_1 / exp(t_0)); end return tmp 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 = hypot(x_46_re, x_46_im) ^ y_46_re; tmp = 0.0; if ((y_46_re <= -100000.0) || ~((y_46_re <= 2.3e+114))) tmp = t_1 / (t_0 + 1.0); else tmp = t_1 / exp(t_0); end tmp_2 = tmp; end
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[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]}, If[Or[LessEqual[y$46$re, -100000.0], N[Not[LessEqual[y$46$re, 2.3e+114]], $MachinePrecision]], N[(t$95$1 / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_1 := {\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}\\
\mathbf{if}\;y.re \leq -100000 \lor \neg \left(y.re \leq 2.3 \cdot 10^{+114}\right):\\
\;\;\;\;\frac{t\_1}{t\_0 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{e^{t\_0}}\\
\end{array}
\end{array}
if y.re < -1e5 or 2.3e114 < y.re Initial program 38.5%
exp-diff31.3%
exp-to-pow31.3%
hypot-define31.3%
*-commutative31.3%
exp-prod29.2%
fma-define29.2%
hypot-define55.2%
*-commutative55.2%
Simplified55.2%
Taylor expanded in y.im around 0 56.3%
Taylor expanded in y.re around 0 58.3%
Taylor expanded in y.im around 0 74.1%
*-commutative74.1%
Simplified74.1%
if -1e5 < y.re < 2.3e114Initial program 36.9%
exp-diff35.7%
exp-to-pow35.7%
hypot-define35.7%
*-commutative35.7%
exp-prod35.6%
fma-define35.6%
hypot-define78.0%
*-commutative78.0%
Simplified78.0%
Taylor expanded in y.im around 0 77.3%
Taylor expanded in y.re around 0 77.9%
Taylor expanded in y.im around inf 78.0%
*-commutative78.0%
Simplified78.0%
Final simplification76.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (/ (pow (hypot x.re x.im) y.re) (+ (* (atan2 x.im x.re) y.im) 1.0)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return pow(hypot(x_46_re, x_46_im), y_46_re) / ((atan2(x_46_im, x_46_re) * y_46_im) + 1.0);
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re) / ((Math.atan2(x_46_im, x_46_re) * y_46_im) + 1.0);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow(math.hypot(x_46_re, x_46_im), y_46_re) / ((math.atan2(x_46_im, x_46_re) * y_46_im) + 1.0)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64((hypot(x_46_re, x_46_im) ^ y_46_re) / Float64(Float64(atan(x_46_im, x_46_re) * y_46_im) + 1.0)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (hypot(x_46_re, x_46_im) ^ y_46_re) / ((atan2(x_46_im, x_46_re) * y_46_im) + 1.0); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision] / N[(N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}}{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im + 1}
\end{array}
Initial program 37.5%
exp-diff34.0%
exp-to-pow34.0%
hypot-define34.0%
*-commutative34.0%
exp-prod33.2%
fma-define33.2%
hypot-define69.4%
*-commutative69.4%
Simplified69.4%
Taylor expanded in y.im around 0 69.4%
Taylor expanded in y.re around 0 70.5%
Taylor expanded in y.im around 0 62.8%
*-commutative62.8%
Simplified62.8%
Final simplification62.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (pow (hypot x.re x.im) y.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return pow(hypot(x_46_re, x_46_im), y_46_re);
}
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return Math.pow(Math.hypot(x_46_re, x_46_im), y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return math.pow(math.hypot(x_46_re, x_46_im), y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return hypot(x_46_re, x_46_im) ^ y_46_re end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = hypot(x_46_re, x_46_im) ^ y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[Power[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision], y$46$re], $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(x.re, x.im\right)\right)}^{y.re}
\end{array}
Initial program 37.5%
exp-diff34.0%
exp-to-pow34.0%
hypot-define34.0%
*-commutative34.0%
exp-prod33.2%
fma-define33.2%
hypot-define69.4%
*-commutative69.4%
Simplified69.4%
Taylor expanded in y.im around 0 69.4%
Taylor expanded in y.im around 0 60.5%
Taylor expanded in y.re around 0 62.1%
Final simplification62.1%
herbie shell --seed 2024107
(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)))))