| Alternative 1 | |
|---|---|
| Error | 16.3 |
| Cost | 39880 |
(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)))
(sin
(+
(* (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 (* y.re (atan2 x.im x.re)))
(t_1 (log (- x.im)))
(t_2 (log (sqrt (+ (* x.re x.re) (* x.im x.im)))))
(t_3 (* (atan2 x.im x.re) y.im))
(t_4 (exp (- (* t_2 y.re) t_3)))
(t_5 (* t_4 (sin t_0)))
(t_6 (* (atan2 x.im x.re) y.re)))
(if (<= y.re -2.1e-175)
t_5
(if (<= y.re 1.8e-287)
(* (exp (- (* (log x.im) y.re) t_3)) (sin (+ (* (log x.im) y.im) t_6)))
(if (<= y.re 1.52e-282)
(* (exp (- (* t_1 y.re) t_3)) (* y.im t_1))
(if (<= y.re 3.15e-133)
(* t_4 (sin (+ (* t_2 y.im) t_6)))
(if (<= y.re 7.4e-11)
(* (exp (* (atan2 x.im x.re) (- y.im))) t_0)
t_5)))))))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))) * sin(((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 = y_46_re * atan2(x_46_im, x_46_re);
double t_1 = log(-x_46_im);
double t_2 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_3 = atan2(x_46_im, x_46_re) * y_46_im;
double t_4 = exp(((t_2 * y_46_re) - t_3));
double t_5 = t_4 * sin(t_0);
double t_6 = atan2(x_46_im, x_46_re) * y_46_re;
double tmp;
if (y_46_re <= -2.1e-175) {
tmp = t_5;
} else if (y_46_re <= 1.8e-287) {
tmp = exp(((log(x_46_im) * y_46_re) - t_3)) * sin(((log(x_46_im) * y_46_im) + t_6));
} else if (y_46_re <= 1.52e-282) {
tmp = exp(((t_1 * y_46_re) - t_3)) * (y_46_im * t_1);
} else if (y_46_re <= 3.15e-133) {
tmp = t_4 * sin(((t_2 * y_46_im) + t_6));
} else if (y_46_re <= 7.4e-11) {
tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)) * t_0;
} else {
tmp = t_5;
}
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))) * sin(((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) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = y_46re * atan2(x_46im, x_46re)
t_1 = log(-x_46im)
t_2 = log(sqrt(((x_46re * x_46re) + (x_46im * x_46im))))
t_3 = atan2(x_46im, x_46re) * y_46im
t_4 = exp(((t_2 * y_46re) - t_3))
t_5 = t_4 * sin(t_0)
t_6 = atan2(x_46im, x_46re) * y_46re
if (y_46re <= (-2.1d-175)) then
tmp = t_5
else if (y_46re <= 1.8d-287) then
tmp = exp(((log(x_46im) * y_46re) - t_3)) * sin(((log(x_46im) * y_46im) + t_6))
else if (y_46re <= 1.52d-282) then
tmp = exp(((t_1 * y_46re) - t_3)) * (y_46im * t_1)
else if (y_46re <= 3.15d-133) then
tmp = t_4 * sin(((t_2 * y_46im) + t_6))
else if (y_46re <= 7.4d-11) then
tmp = exp((atan2(x_46im, x_46re) * -y_46im)) * t_0
else
tmp = t_5
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.sin(((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 = y_46_re * Math.atan2(x_46_im, x_46_re);
double t_1 = Math.log(-x_46_im);
double t_2 = Math.log(Math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im))));
double t_3 = Math.atan2(x_46_im, x_46_re) * y_46_im;
double t_4 = Math.exp(((t_2 * y_46_re) - t_3));
double t_5 = t_4 * Math.sin(t_0);
double t_6 = Math.atan2(x_46_im, x_46_re) * y_46_re;
double tmp;
if (y_46_re <= -2.1e-175) {
tmp = t_5;
} else if (y_46_re <= 1.8e-287) {
tmp = Math.exp(((Math.log(x_46_im) * y_46_re) - t_3)) * Math.sin(((Math.log(x_46_im) * y_46_im) + t_6));
} else if (y_46_re <= 1.52e-282) {
tmp = Math.exp(((t_1 * y_46_re) - t_3)) * (y_46_im * t_1);
} else if (y_46_re <= 3.15e-133) {
tmp = t_4 * Math.sin(((t_2 * y_46_im) + t_6));
} else if (y_46_re <= 7.4e-11) {
tmp = Math.exp((Math.atan2(x_46_im, x_46_re) * -y_46_im)) * t_0;
} else {
tmp = t_5;
}
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.sin(((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 = y_46_re * math.atan2(x_46_im, x_46_re) t_1 = math.log(-x_46_im) t_2 = math.log(math.sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))) t_3 = math.atan2(x_46_im, x_46_re) * y_46_im t_4 = math.exp(((t_2 * y_46_re) - t_3)) t_5 = t_4 * math.sin(t_0) t_6 = math.atan2(x_46_im, x_46_re) * y_46_re tmp = 0 if y_46_re <= -2.1e-175: tmp = t_5 elif y_46_re <= 1.8e-287: tmp = math.exp(((math.log(x_46_im) * y_46_re) - t_3)) * math.sin(((math.log(x_46_im) * y_46_im) + t_6)) elif y_46_re <= 1.52e-282: tmp = math.exp(((t_1 * y_46_re) - t_3)) * (y_46_im * t_1) elif y_46_re <= 3.15e-133: tmp = t_4 * math.sin(((t_2 * y_46_im) + t_6)) elif y_46_re <= 7.4e-11: tmp = math.exp((math.atan2(x_46_im, x_46_re) * -y_46_im)) * t_0 else: tmp = t_5 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))) * sin(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(y_46_re * atan(x_46_im, x_46_re)) t_1 = log(Float64(-x_46_im)) t_2 = log(sqrt(Float64(Float64(x_46_re * x_46_re) + Float64(x_46_im * x_46_im)))) t_3 = Float64(atan(x_46_im, x_46_re) * y_46_im) t_4 = exp(Float64(Float64(t_2 * y_46_re) - t_3)) t_5 = Float64(t_4 * sin(t_0)) t_6 = Float64(atan(x_46_im, x_46_re) * y_46_re) tmp = 0.0 if (y_46_re <= -2.1e-175) tmp = t_5; elseif (y_46_re <= 1.8e-287) tmp = Float64(exp(Float64(Float64(log(x_46_im) * y_46_re) - t_3)) * sin(Float64(Float64(log(x_46_im) * y_46_im) + t_6))); elseif (y_46_re <= 1.52e-282) tmp = Float64(exp(Float64(Float64(t_1 * y_46_re) - t_3)) * Float64(y_46_im * t_1)); elseif (y_46_re <= 3.15e-133) tmp = Float64(t_4 * sin(Float64(Float64(t_2 * y_46_im) + t_6))); elseif (y_46_re <= 7.4e-11) tmp = Float64(exp(Float64(atan(x_46_im, x_46_re) * Float64(-y_46_im))) * t_0); else tmp = t_5; 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))) * sin(((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 = y_46_re * atan2(x_46_im, x_46_re); t_1 = log(-x_46_im); t_2 = log(sqrt(((x_46_re * x_46_re) + (x_46_im * x_46_im)))); t_3 = atan2(x_46_im, x_46_re) * y_46_im; t_4 = exp(((t_2 * y_46_re) - t_3)); t_5 = t_4 * sin(t_0); t_6 = atan2(x_46_im, x_46_re) * y_46_re; tmp = 0.0; if (y_46_re <= -2.1e-175) tmp = t_5; elseif (y_46_re <= 1.8e-287) tmp = exp(((log(x_46_im) * y_46_re) - t_3)) * sin(((log(x_46_im) * y_46_im) + t_6)); elseif (y_46_re <= 1.52e-282) tmp = exp(((t_1 * y_46_re) - t_3)) * (y_46_im * t_1); elseif (y_46_re <= 3.15e-133) tmp = t_4 * sin(((t_2 * y_46_im) + t_6)); elseif (y_46_re <= 7.4e-11) tmp = exp((atan2(x_46_im, x_46_re) * -y_46_im)) * t_0; else tmp = t_5; 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[Sin[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[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Log[(-x$46$im)], $MachinePrecision]}, Block[{t$95$2 = N[Log[N[Sqrt[N[(N[(x$46$re * x$46$re), $MachinePrecision] + N[(x$46$im * x$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$im), $MachinePrecision]}, Block[{t$95$4 = N[Exp[N[(N[(t$95$2 * y$46$re), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * y$46$re), $MachinePrecision]}, If[LessEqual[y$46$re, -2.1e-175], t$95$5, If[LessEqual[y$46$re, 1.8e-287], N[(N[Exp[N[(N[(N[Log[x$46$im], $MachinePrecision] * y$46$re), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(N[(N[Log[x$46$im], $MachinePrecision] * y$46$im), $MachinePrecision] + t$95$6), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 1.52e-282], N[(N[Exp[N[(N[(t$95$1 * y$46$re), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision] * N[(y$46$im * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 3.15e-133], N[(t$95$4 * N[Sin[N[(N[(t$95$2 * y$46$im), $MachinePrecision] + t$95$6), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y$46$re, 7.4e-11], N[(N[Exp[N[(N[ArcTan[x$46$im / x$46$re], $MachinePrecision] * (-y$46$im)), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], t$95$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 \sin \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 := y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\\
t_1 := \log \left(-x.im\right)\\
t_2 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\
t_3 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\
t_4 := e^{t_2 \cdot y.re - t_3}\\
t_5 := t_4 \cdot \sin t_0\\
t_6 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\\
\mathbf{if}\;y.re \leq -2.1 \cdot 10^{-175}:\\
\;\;\;\;t_5\\
\mathbf{elif}\;y.re \leq 1.8 \cdot 10^{-287}:\\
\;\;\;\;e^{\log x.im \cdot y.re - t_3} \cdot \sin \left(\log x.im \cdot y.im + t_6\right)\\
\mathbf{elif}\;y.re \leq 1.52 \cdot 10^{-282}:\\
\;\;\;\;e^{t_1 \cdot y.re - t_3} \cdot \left(y.im \cdot t_1\right)\\
\mathbf{elif}\;y.re \leq 3.15 \cdot 10^{-133}:\\
\;\;\;\;t_4 \cdot \sin \left(t_2 \cdot y.im + t_6\right)\\
\mathbf{elif}\;y.re \leq 7.4 \cdot 10^{-11}:\\
\;\;\;\;e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(-y.im\right)} \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_5\\
\end{array}
Results
if y.re < -2.1e-175 or 7.4000000000000003e-11 < y.re Initial program 33.1
Taylor expanded in y.im around 0 13.6
if -2.1e-175 < y.re < 1.8000000000000001e-287Initial program 34.1
Taylor expanded in x.re around 0 49.3
Taylor expanded in x.re around 0 43.9
if 1.8000000000000001e-287 < y.re < 1.52e-282Initial program 39.1
Taylor expanded in x.im around -inf 47.8
Simplified47.8
[Start]47.8 | \[ e^{\log \left(-1 \cdot x.im\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \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)
\] |
|---|---|
rational.json-simplify-2 [=>]47.8 | \[ e^{\log \color{blue}{\left(x.im \cdot -1\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \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)
\] |
rational.json-simplify-9 [=>]47.8 | \[ e^{\log \color{blue}{\left(-x.im\right)} \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \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)
\] |
Taylor expanded in x.im around -inf 45.7
Simplified45.7
[Start]45.7 | \[ e^{\log \left(-x.im\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \left(-1 \cdot x.im\right) \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\] |
|---|---|
rational.json-simplify-2 [=>]45.7 | \[ e^{\log \left(-x.im\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(x.im \cdot -1\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\] |
rational.json-simplify-9 [=>]45.7 | \[ e^{\log \left(-x.im\right) \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(\log \color{blue}{\left(-x.im\right)} \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)
\] |
Taylor expanded in y.re around 0 49.0
Taylor expanded in y.im around 0 49.2
if 1.52e-282 < y.re < 3.1500000000000001e-133Initial program 36.3
if 3.1500000000000001e-133 < y.re < 7.4000000000000003e-11Initial program 35.2
Taylor expanded in y.im around 0 40.7
Taylor expanded in y.re around 0 40.7
Taylor expanded in x.re around 0 41.3
Taylor expanded in y.re around 0 20.5
Simplified20.5
[Start]20.5 | \[ e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
|---|---|
rational.json-simplify-8 [=>]20.5 | \[ e^{\color{blue}{\left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right) \cdot -1}} \cdot \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
rational.json-simplify-2 [=>]20.5 | \[ e^{\color{blue}{-1 \cdot \left(\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\right)}} \cdot \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
rational.json-simplify-43 [=>]20.5 | \[ e^{\color{blue}{\tan^{-1}_* \frac{x.im}{x.re} \cdot \left(y.im \cdot -1\right)}} \cdot \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
rational.json-simplify-9 [=>]20.5 | \[ e^{\tan^{-1}_* \frac{x.im}{x.re} \cdot \color{blue}{\left(-y.im\right)}} \cdot \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)
\] |
Final simplification22.9
| Alternative 1 | |
|---|---|
| Error | 16.3 |
| Cost | 39880 |
| Alternative 2 | |
|---|---|
| Error | 23.1 |
| Cost | 39752 |
| Alternative 3 | |
|---|---|
| Error | 16.4 |
| Cost | 39752 |
| Alternative 4 | |
|---|---|
| Error | 20.6 |
| Cost | 33480 |
| Alternative 5 | |
|---|---|
| Error | 25.0 |
| Cost | 33360 |
| Alternative 6 | |
|---|---|
| Error | 24.9 |
| Cost | 33360 |
| Alternative 7 | |
|---|---|
| Error | 24.9 |
| Cost | 33360 |
| Alternative 8 | |
|---|---|
| Error | 25.1 |
| Cost | 27344 |
| Alternative 9 | |
|---|---|
| Error | 28.1 |
| Cost | 27156 |
| Alternative 10 | |
|---|---|
| Error | 25.1 |
| Cost | 26960 |
| Alternative 11 | |
|---|---|
| Error | 27.9 |
| Cost | 26696 |
| Alternative 12 | |
|---|---|
| Error | 27.5 |
| Cost | 20104 |
| Alternative 13 | |
|---|---|
| Error | 42.1 |
| Cost | 13248 |
herbie shell --seed 2023077
(FPCore (x.re x.im y.re y.im)
:name "powComplex, imaginary part"
:precision binary64
(* (exp (- (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.re) (* (atan2 x.im x.re) y.im))) (sin (+ (* (log (sqrt (+ (* x.re x.re) (* x.im x.im)))) y.im) (* (atan2 x.im x.re) y.re)))))