
(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.re x.im (* x.re y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return fma(y_46_re, x_46_im, (x_46_re * y_46_im));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return fma(y_46_re, x_46_im, Float64(x_46_re * y_46_im)) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(y$46$re * x$46$im + N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y.re, x.im, x.re \cdot y.im\right)
\end{array}
Initial program 99.6%
+-commutativeN/A
*-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 (<= (* y.re x.im) -2000000000000.0) (* y.re x.im) (if (<= (* y.re x.im) 4.9e-116) (* x.re y.im) (* y.re x.im))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_re * x_46_im) <= -2000000000000.0) {
tmp = y_46_re * x_46_im;
} else if ((y_46_re * x_46_im) <= 4.9e-116) {
tmp = x_46_re * y_46_im;
} else {
tmp = y_46_re * x_46_im;
}
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 ((y_46re * x_46im) <= (-2000000000000.0d0)) then
tmp = y_46re * x_46im
else if ((y_46re * x_46im) <= 4.9d-116) then
tmp = x_46re * y_46im
else
tmp = y_46re * x_46im
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 ((y_46_re * x_46_im) <= -2000000000000.0) {
tmp = y_46_re * x_46_im;
} else if ((y_46_re * x_46_im) <= 4.9e-116) {
tmp = x_46_re * y_46_im;
} else {
tmp = y_46_re * x_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re * x_46_im) <= -2000000000000.0: tmp = y_46_re * x_46_im elif (y_46_re * x_46_im) <= 4.9e-116: tmp = x_46_re * y_46_im else: tmp = y_46_re * x_46_im return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (Float64(y_46_re * x_46_im) <= -2000000000000.0) tmp = Float64(y_46_re * x_46_im); elseif (Float64(y_46_re * x_46_im) <= 4.9e-116) tmp = Float64(x_46_re * y_46_im); else tmp = Float64(y_46_re * x_46_im); end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0; if ((y_46_re * x_46_im) <= -2000000000000.0) tmp = y_46_re * x_46_im; elseif ((y_46_re * x_46_im) <= 4.9e-116) tmp = x_46_re * y_46_im; else tmp = y_46_re * x_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[N[(y$46$re * x$46$im), $MachinePrecision], -2000000000000.0], N[(y$46$re * x$46$im), $MachinePrecision], If[LessEqual[N[(y$46$re * x$46$im), $MachinePrecision], 4.9e-116], N[(x$46$re * y$46$im), $MachinePrecision], N[(y$46$re * x$46$im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \cdot x.im \leq -2000000000000:\\
\;\;\;\;y.re \cdot x.im\\
\mathbf{elif}\;y.re \cdot x.im \leq 4.9 \cdot 10^{-116}:\\
\;\;\;\;x.re \cdot y.im\\
\mathbf{else}:\\
\;\;\;\;y.re \cdot x.im\\
\end{array}
\end{array}
if (*.f64 x.im y.re) < -2e12 or 4.89999999999999977e-116 < (*.f64 x.im y.re) Initial program 99.3%
Taylor expanded in x.re around 0
*-lowering-*.f6475.6
Simplified75.6%
if -2e12 < (*.f64 x.im y.re) < 4.89999999999999977e-116Initial program 100.0%
Taylor expanded in x.re around inf
*-lowering-*.f6481.1
Simplified81.1%
Final simplification78.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* y.re x.im))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return y_46_re * x_46_im;
}
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_46re * x_46im
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_re * x_46_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return y_46_re * x_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(y_46_re * x_46_im) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = y_46_re * x_46_im; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(y$46$re * x$46$im), $MachinePrecision]
\begin{array}{l}
\\
y.re \cdot x.im
\end{array}
Initial program 99.6%
Taylor expanded in x.re around 0
*-lowering-*.f6452.2
Simplified52.2%
Final simplification52.2%
herbie shell --seed 2024199
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, imaginary part"
:precision binary64
(+ (* x.re y.im) (* x.im y.re)))