
(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 4 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.6%
*-commutativeN/A
fma-defineN/A
fma-lowering-fma.f64N/A
*-lowering-*.f6499.6%
Applied egg-rr99.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= (* y.im x.re) -4.2e+39) (* y.im x.re) (if (<= (* y.im x.re) 1.38e-31) (* x.im y.re) (* y.im x.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double tmp;
if ((y_46_im * x_46_re) <= -4.2e+39) {
tmp = y_46_im * x_46_re;
} else if ((y_46_im * x_46_re) <= 1.38e-31) {
tmp = x_46_im * y_46_re;
} else {
tmp = y_46_im * x_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 ((y_46im * x_46re) <= (-4.2d+39)) then
tmp = y_46im * x_46re
else if ((y_46im * x_46re) <= 1.38d-31) then
tmp = x_46im * y_46re
else
tmp = y_46im * x_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 ((y_46_im * x_46_re) <= -4.2e+39) {
tmp = y_46_im * x_46_re;
} else if ((y_46_im * x_46_re) <= 1.38e-31) {
tmp = x_46_im * y_46_re;
} else {
tmp = y_46_im * x_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_im * x_46_re) <= -4.2e+39: tmp = y_46_im * x_46_re elif (y_46_im * x_46_re) <= 1.38e-31: tmp = x_46_im * y_46_re else: tmp = y_46_im * x_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (Float64(y_46_im * x_46_re) <= -4.2e+39) tmp = Float64(y_46_im * x_46_re); elseif (Float64(y_46_im * x_46_re) <= 1.38e-31) tmp = Float64(x_46_im * y_46_re); else tmp = Float64(y_46_im * x_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 ((y_46_im * x_46_re) <= -4.2e+39) tmp = y_46_im * x_46_re; elseif ((y_46_im * x_46_re) <= 1.38e-31) tmp = x_46_im * y_46_re; else tmp = y_46_im * x_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[N[(y$46$im * x$46$re), $MachinePrecision], -4.2e+39], N[(y$46$im * x$46$re), $MachinePrecision], If[LessEqual[N[(y$46$im * x$46$re), $MachinePrecision], 1.38e-31], N[(x$46$im * y$46$re), $MachinePrecision], N[(y$46$im * x$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.im \cdot x.re \leq -4.2 \cdot 10^{+39}:\\
\;\;\;\;y.im \cdot x.re\\
\mathbf{elif}\;y.im \cdot x.re \leq 1.38 \cdot 10^{-31}:\\
\;\;\;\;x.im \cdot y.re\\
\mathbf{else}:\\
\;\;\;\;y.im \cdot x.re\\
\end{array}
\end{array}
if (*.f64 x.re y.im) < -4.1999999999999997e39 or 1.38000000000000004e-31 < (*.f64 x.re y.im) Initial program 99.3%
Taylor expanded in x.re around inf
*-lowering-*.f6475.1%
Simplified75.1%
if -4.1999999999999997e39 < (*.f64 x.re y.im) < 1.38000000000000004e-31Initial program 100.0%
Taylor expanded in x.re around 0
*-lowering-*.f6482.2%
Simplified82.2%
Final simplification78.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (+ (* x.im y.re) (* y.im x.re)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (x_46_im * y_46_re) + (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 = (x_46im * y_46re) + (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 (x_46_im * y_46_re) + (y_46_im * x_46_re);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (x_46_im * y_46_re) + (y_46_im * x_46_re)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(x_46_im * y_46_re) + Float64(y_46_im * x_46_re)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (x_46_im * y_46_re) + (y_46_im * x_46_re); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(x$46$im * y$46$re), $MachinePrecision] + N[(y$46$im * x$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot y.re + y.im \cdot x.re
\end{array}
Initial program 99.6%
Final simplification99.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* 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_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_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_im * y_46_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im * y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return 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_im * y_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im * y$46$re), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot y.re
\end{array}
Initial program 99.6%
Taylor expanded in x.re around 0
*-lowering-*.f6453.3%
Simplified53.3%
herbie shell --seed 2024161
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, imaginary part"
:precision binary64
(+ (* x.re y.im) (* x.im y.re)))