
(FPCore (x.re x.im y.re y.im) :precision binary64 (- (* x.re y.re) (* x.im y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (x_46_re * y_46_re) - (x_46_im * y_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 = (x_46re * y_46re) - (x_46im * y_46im)
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_re) - (x_46_im * y_46_im);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (x_46_re * y_46_re) - (x_46_im * y_46_im)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(x_46_re * y_46_re) - Float64(x_46_im * y_46_im)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (x_46_re * y_46_re) - (x_46_im * y_46_im); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(x$46$re * y$46$re), $MachinePrecision] - N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot y.re - x.im \cdot y.im
\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.re) (* x.im y.im)))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return (x_46_re * y_46_re) - (x_46_im * y_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 = (x_46re * y_46re) - (x_46im * y_46im)
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_re) - (x_46_im * y_46_im);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (x_46_re * y_46_re) - (x_46_im * y_46_im)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(x_46_re * y_46_re) - Float64(x_46_im * y_46_im)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (x_46_re * y_46_re) - (x_46_im * y_46_im); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(x$46$re * y$46$re), $MachinePrecision] - N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot y.re - x.im \cdot y.im
\end{array}
(FPCore (x.re x.im y.re y.im) :precision binary64 (fma y.re x.re (* x.im (- 0.0 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_re, (x_46_im * (0.0 - y_46_im)));
}
function code(x_46_re, x_46_im, y_46_re, y_46_im) return fma(y_46_re, x_46_re, Float64(x_46_im * Float64(0.0 - y_46_im))) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(y$46$re * x$46$re + N[(x$46$im * N[(0.0 - y$46$im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y.re, x.re, x.im \cdot \left(0 - y.im\right)\right)
\end{array}
Initial program 100.0%
*-commutativeN/A
fmm-defN/A
fma-lowering-fma.f64N/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f64100.0%
Applied egg-rr100.0%
sub0-negN/A
neg-lowering-neg.f64N/A
*-lowering-*.f64100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(let* ((t_0 (* x.im (- 0.0 y.im))))
(if (<= (* x.im y.im) -5e+21)
t_0
(if (<= (* x.im y.im) 1.2e-32) (* y.re x.re) t_0))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = x_46_im * (0.0 - y_46_im);
double tmp;
if ((x_46_im * y_46_im) <= -5e+21) {
tmp = t_0;
} else if ((x_46_im * y_46_im) <= 1.2e-32) {
tmp = y_46_re * x_46_re;
} else {
tmp = t_0;
}
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) :: t_0
real(8) :: tmp
t_0 = x_46im * (0.0d0 - y_46im)
if ((x_46im * y_46im) <= (-5d+21)) then
tmp = t_0
else if ((x_46im * y_46im) <= 1.2d-32) then
tmp = y_46re * x_46re
else
tmp = t_0
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 t_0 = x_46_im * (0.0 - y_46_im);
double tmp;
if ((x_46_im * y_46_im) <= -5e+21) {
tmp = t_0;
} else if ((x_46_im * y_46_im) <= 1.2e-32) {
tmp = y_46_re * x_46_re;
} else {
tmp = t_0;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = x_46_im * (0.0 - y_46_im) tmp = 0 if (x_46_im * y_46_im) <= -5e+21: tmp = t_0 elif (x_46_im * y_46_im) <= 1.2e-32: tmp = y_46_re * x_46_re else: tmp = t_0 return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(x_46_im * Float64(0.0 - y_46_im)) tmp = 0.0 if (Float64(x_46_im * y_46_im) <= -5e+21) tmp = t_0; elseif (Float64(x_46_im * y_46_im) <= 1.2e-32) tmp = Float64(y_46_re * x_46_re); else tmp = t_0; end return tmp end
function tmp_2 = code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = x_46_im * (0.0 - y_46_im); tmp = 0.0; if ((x_46_im * y_46_im) <= -5e+21) tmp = t_0; elseif ((x_46_im * y_46_im) <= 1.2e-32) tmp = y_46_re * x_46_re; else tmp = t_0; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(x$46$im * N[(0.0 - y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x$46$im * y$46$im), $MachinePrecision], -5e+21], t$95$0, If[LessEqual[N[(x$46$im * y$46$im), $MachinePrecision], 1.2e-32], N[(y$46$re * x$46$re), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot \left(0 - y.im\right)\\
\mathbf{if}\;x.im \cdot y.im \leq -5 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x.im \cdot y.im \leq 1.2 \cdot 10^{-32}:\\
\;\;\;\;y.re \cdot x.re\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 x.im y.im) < -5e21 or 1.2000000000000001e-32 < (*.f64 x.im y.im) Initial program 100.0%
Taylor expanded in x.re around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
*-lowering-*.f6483.7%
Simplified83.7%
sub0-negN/A
neg-lowering-neg.f64N/A
*-lowering-*.f6483.7%
Applied egg-rr83.7%
if -5e21 < (*.f64 x.im y.im) < 1.2000000000000001e-32Initial program 100.0%
Taylor expanded in x.re around inf
*-lowering-*.f6481.0%
Simplified81.0%
Final simplification82.4%
(FPCore (x.re x.im y.re y.im) :precision binary64 (- (* y.re x.re) (* x.im y.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_re) - (x_46_im * y_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_46re) - (x_46im * y_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_re) - (x_46_im * y_46_im);
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return (y_46_re * x_46_re) - (x_46_im * y_46_im)
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(Float64(y_46_re * x_46_re) - Float64(x_46_im * y_46_im)) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = (y_46_re * x_46_re) - (x_46_im * y_46_im); end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(N[(y$46$re * x$46$re), $MachinePrecision] - N[(x$46$im * y$46$im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y.re \cdot x.re - x.im \cdot y.im
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* y.re x.re))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
return y_46_re * 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_46re * 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_re * x_46_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return y_46_re * x_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(y_46_re * x_46_re) end
function tmp = code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = y_46_re * x_46_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(y$46$re * x$46$re), $MachinePrecision]
\begin{array}{l}
\\
y.re \cdot x.re
\end{array}
Initial program 100.0%
Taylor expanded in x.re around inf
*-lowering-*.f6449.4%
Simplified49.4%
Final simplification49.4%
herbie shell --seed 2024160
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, real part"
:precision binary64
(- (* x.re y.re) (* x.im y.im)))