
(FPCore (x.re x.im y.re y.im) :precision binary64 (+ (* x.re y.im) (* x.im y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (x_46_re * y_46_im) + (x_46_im * 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
code = (x_46re * y_46im) + (x_46im * y_46re)
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (x_46_re * y_46_im) + (x_46_im * y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (x_46_re * y_46_im) + (x_46_im * y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(x_46_re * y_46_im) + Float64(x_46_im * y_46_re)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (x_46_re * y_46_im) + (x_46_im * y_46_re); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(x$46$re * y$46$im), $MachinePrecision] + N[(x$46$im * y$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot y.im + x.im \cdot y.re
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x.re x.im y.re y.im) :precision binary64 (+ (* x.re y.im) (* x.im y.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (x_46_re * y_46_im) + (x_46_im * 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
code = (x_46re * y_46im) + (x_46im * y_46re)
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (x_46_re * y_46_im) + (x_46_im * y_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (x_46_re * y_46_im) + (x_46_im * y_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(x_46_re * y_46_im) + Float64(x_46_im * y_46_re)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (x_46_re * y_46_im) + (x_46_im * y_46_re); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(x$46$re * y$46$im), $MachinePrecision] + N[(x$46$im * y$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot y.im + x.im \cdot y.re
\end{array}
(FPCore (x.re x.im y.re y.im) :precision binary64 (fma y.im 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 fma(y_46_im, x_46_re, (x_46_im * y_46_re));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return fma(y_46_im, x_46_re, Float64(x_46_im * y_46_re)) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(y$46$im * x$46$re + N[(x$46$im * y$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y.im, x.re, x.im \cdot y.re\right)
\end{array}
Initial program 99.2%
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64100.0
Applied egg-rr100.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= (* x.im y.re) -1e-15) (* x.im y.re) (if (<= (* x.im y.re) 5e+75) (* y.im x.re) (* x.im y.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((x_46_im * y_46_re) <= -1e-15) {
tmp = x_46_im * y_46_re;
} else if ((x_46_im * y_46_re) <= 5e+75) {
tmp = y_46_im * x_46_re;
} else {
tmp = x_46_im * y_46_re;
}
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
real(8) :: tmp
if ((x_46im * y_46re) <= (-1d-15)) then
tmp = x_46im * y_46re
else if ((x_46im * y_46re) <= 5d+75) then
tmp = y_46im * x_46re
else
tmp = x_46im * y_46re
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) {
double tmp;
if ((x_46_im * y_46_re) <= -1e-15) {
tmp = x_46_im * y_46_re;
} else if ((x_46_im * y_46_re) <= 5e+75) {
tmp = y_46_im * x_46_re;
} else {
tmp = x_46_im * y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (x_46_im * y_46_re) <= -1e-15: tmp = x_46_im * y_46_re elif (x_46_im * y_46_re) <= 5e+75: tmp = y_46_im * x_46_re else: tmp = x_46_im * y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (Float64(x_46_im * y_46_re) <= -1e-15) tmp = Float64(x_46_im * y_46_re); elseif (Float64(x_46_im * y_46_re) <= 5e+75) tmp = Float64(y_46_im * x_46_re); else tmp = Float64(x_46_im * y_46_re); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((x_46_im * y_46_re) <= -1e-15) tmp = x_46_im * y_46_re; elseif ((x_46_im * y_46_re) <= 5e+75) tmp = y_46_im * x_46_re; else tmp = x_46_im * y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[N[(x$46$im * y$46$re), $MachinePrecision], -1e-15], N[(x$46$im * y$46$re), $MachinePrecision], If[LessEqual[N[(x$46$im * y$46$re), $MachinePrecision], 5e+75], N[(y$46$im * x$46$re), $MachinePrecision], N[(x$46$im * y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \cdot y.re \leq -1 \cdot 10^{-15}:\\
\;\;\;\;x.im \cdot y.re\\
\mathbf{elif}\;x.im \cdot y.re \leq 5 \cdot 10^{+75}:\\
\;\;\;\;y.im \cdot x.re\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot y.re\\
\end{array}
\end{array}
if (*.f64 x.im y.re) < -1.0000000000000001e-15 or 5.0000000000000002e75 < (*.f64 x.im y.re) Initial program 98.4%
Taylor expanded in x.re around 0
+-rgt-identityN/A
accelerator-lowering-fma.f6480.7
Simplified80.7%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f6480.7
Applied egg-rr80.7%
if -1.0000000000000001e-15 < (*.f64 x.im y.re) < 5.0000000000000002e75Initial program 100.0%
Taylor expanded in x.re around inf
remove-double-negN/A
mul-1-negN/A
+-rgt-identityN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
metadata-evalN/A
accelerator-lowering-fma.f6477.3
Simplified77.3%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f6477.3
Applied egg-rr77.3%
Final simplification78.9%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* y.im x.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return y_46_im * x_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
code = y_46im * x_46re
end function
public static double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return y_46_im * x_46_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return y_46_im * x_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(y_46_im * x_46_re) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = y_46_im * x_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(y$46$im * x$46$re), $MachinePrecision]
\begin{array}{l}
\\
y.im \cdot x.re
\end{array}
Initial program 99.2%
Taylor expanded in x.re around inf
remove-double-negN/A
mul-1-negN/A
+-rgt-identityN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
metadata-evalN/A
accelerator-lowering-fma.f6451.1
Simplified51.1%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f6451.1
Applied egg-rr51.1%
herbie shell --seed 2024198
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, imaginary part"
:precision binary64
(+ (* x.re y.im) (* x.im y.re)))