?

Average Error: 33.4 → 3.6
Time: 2.3min
Precision: binary64
Cost: 65024

?

\[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 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ e^{\mathsf{fma}\left(t_0, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \sin \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right) \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)))
  (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 (log (hypot x.re x.im))))
   (*
    (exp (fma t_0 y.re (* (- (atan2 x.im x.re)) y.im)))
    (sin (fma t_0 y.im (* y.re (atan2 x.im x.re)))))))
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 = log(hypot(x_46_re, x_46_im));
	return exp(fma(t_0, y_46_re, (-atan2(x_46_im, x_46_re) * y_46_im))) * sin(fma(t_0, y_46_im, (y_46_re * atan2(x_46_im, x_46_re))));
}
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 = log(hypot(x_46_re, x_46_im))
	return Float64(exp(fma(t_0, y_46_re, Float64(Float64(-atan(x_46_im, x_46_re)) * y_46_im))) * sin(fma(t_0, y_46_im, Float64(y_46_re * atan(x_46_im, x_46_re)))))
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[Log[N[Sqrt[x$46$re ^ 2 + x$46$im ^ 2], $MachinePrecision]], $MachinePrecision]}, N[(N[Exp[N[(t$95$0 * y$46$re + N[((-N[ArcTan[x$46$im / x$46$re], $MachinePrecision]) * y$46$im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(t$95$0 * y$46$im + N[(y$46$re * N[ArcTan[x$46$im / x$46$re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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 \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 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\
e^{\mathsf{fma}\left(t_0, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \sin \left(\mathsf{fma}\left(t_0, y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)
\end{array}

Error?

Derivation?

  1. Initial program 33.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 \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) \]
  2. Simplified3.6

    \[\leadsto \color{blue}{e^{\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \sin \left(\mathsf{fma}\left(\log \left(\mathsf{hypot}\left(x.re, x.im\right)\right), y.im, y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\right)} \]
    Proof

Alternatives

Alternative 1
Error8.7
Cost118020
\[\begin{array}{l} t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ t_1 := e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(t_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ t_2 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;t_1 \leq 2 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{fma}\left(t_2, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \sin \left(y.im \cdot \sqrt[3]{{t_2}^{3}}\right)\\ \end{array} \]
Alternative 2
Error8.7
Cost106180
\[\begin{array}{l} t_0 := \log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right)\\ t_1 := e^{t_0 \cdot y.re - \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(t_0 \cdot y.im + \tan^{-1}_* \frac{x.im}{x.re} \cdot y.re\right)\\ t_2 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;t_1 \leq 2 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{fma}\left(t_2, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \sin \left(y.im \cdot t_2\right)\\ \end{array} \]
Alternative 3
Error10.9
Cost45896
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := e^{\mathsf{fma}\left(t_0, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{if}\;y.re \leq -1.92 \cdot 10^{-60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq 4.5 \cdot 10^{-96}:\\ \;\;\;\;e^{-{\left(\sqrt[3]{\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im}\right)}^{3}} \cdot \sin \left(y.im \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error13.5
Cost45768
\[\begin{array}{l} t_0 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ t_1 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ \mathbf{if}\;y.re \leq -1.55 \cdot 10^{-56}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_0} \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;y.re \leq 1.8:\\ \;\;\;\;e^{-{\left(\sqrt[3]{t_0}\right)}^{3}} \cdot \sin \left(y.im \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{fma}\left(t_1, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot 0\\ \end{array} \]
Alternative 5
Error13.5
Cost39748
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := \tan^{-1}_* \frac{x.im}{x.re} \cdot y.im\\ \mathbf{if}\;y.re \leq -5.5 \cdot 10^{-55}:\\ \;\;\;\;e^{\log \left(\sqrt{x.re \cdot x.re + x.im \cdot x.im}\right) \cdot y.re - t_1} \cdot \sin \left(y.re \cdot \tan^{-1}_* \frac{x.im}{x.re}\right)\\ \mathbf{elif}\;y.re \leq 1:\\ \;\;\;\;e^{-t_1} \cdot \sin \left(y.im \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{fma}\left(t_0, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot 0\\ \end{array} \]
Alternative 6
Error28.5
Cost32904
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(y.im \cdot t_0\right)\\ \mathbf{if}\;y.im \leq -1.28 \cdot 10^{-185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 1.45 \cdot 10^{-149}:\\ \;\;\;\;1 \cdot \sin \left(\sqrt[3]{{y.im}^{3}} \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error13.6
Cost32904
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := e^{\mathsf{fma}\left(t_0, y.re, \left(-\tan^{-1}_* \frac{x.im}{x.re}\right) \cdot y.im\right)} \cdot 0\\ \mathbf{if}\;y.re \leq -0.76:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.re \leq 1.48:\\ \;\;\;\;e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \sin \left(y.im \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error29.4
Cost32712
\[\begin{array}{l} t_0 := y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot t_0\\ \mathbf{if}\;y.im \leq -8.2 \cdot 10^{-185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 2.3 \cdot 10^{-150}:\\ \;\;\;\;1 \cdot \sqrt[3]{{\sin t_0}^{3}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error29.4
Cost32712
\[\begin{array}{l} t_0 := \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\\ t_1 := e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(y.im \cdot t_0\right)\\ \mathbf{if}\;y.im \leq -6.2 \cdot 10^{-187}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y.im \leq 9.8 \cdot 10^{-151}:\\ \;\;\;\;1 \cdot \sin \left(\sqrt[3]{{y.im}^{3}} \cdot t_0\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error31.3
Cost26240
\[e^{-\tan^{-1}_* \frac{x.im}{x.re} \cdot y.im} \cdot \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right) \]
Alternative 11
Error48.0
Cost19584
\[1 \cdot \sin \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right) \]
Alternative 12
Error48.8
Cost13184
\[1 \cdot \left(y.im \cdot \log \left(\mathsf{hypot}\left(x.re, x.im\right)\right)\right) \]

Error

Reproduce?

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