
(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 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 * 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(-Float64(x_46_im * 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 * y$46$im), $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y.re, x.re, -x.im \cdot y.im\right)
\end{array}
Initial program 98.8%
sub-negN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
*-lowering-*.f6499.2
Applied egg-rr99.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= (* y.re x.re) -8.6e+23) (* y.re x.re) (if (<= (* y.re x.re) 4.4e-119) (- (* x.im y.im)) (* y.re 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_re * x_46_re) <= -8.6e+23) {
tmp = y_46_re * x_46_re;
} else if ((y_46_re * x_46_re) <= 4.4e-119) {
tmp = -(x_46_im * y_46_im);
} else {
tmp = y_46_re * 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_46re * x_46re) <= (-8.6d+23)) then
tmp = y_46re * x_46re
else if ((y_46re * x_46re) <= 4.4d-119) then
tmp = -(x_46im * y_46im)
else
tmp = y_46re * 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_re * x_46_re) <= -8.6e+23) {
tmp = y_46_re * x_46_re;
} else if ((y_46_re * x_46_re) <= 4.4e-119) {
tmp = -(x_46_im * y_46_im);
} else {
tmp = y_46_re * x_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (y_46_re * x_46_re) <= -8.6e+23: tmp = y_46_re * x_46_re elif (y_46_re * x_46_re) <= 4.4e-119: tmp = -(x_46_im * y_46_im) else: tmp = y_46_re * 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_re * x_46_re) <= -8.6e+23) tmp = Float64(y_46_re * x_46_re); elseif (Float64(y_46_re * x_46_re) <= 4.4e-119) tmp = Float64(-Float64(x_46_im * y_46_im)); else tmp = Float64(y_46_re * 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_re * x_46_re) <= -8.6e+23) tmp = y_46_re * x_46_re; elseif ((y_46_re * x_46_re) <= 4.4e-119) tmp = -(x_46_im * y_46_im); else tmp = y_46_re * 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$re * x$46$re), $MachinePrecision], -8.6e+23], N[(y$46$re * x$46$re), $MachinePrecision], If[LessEqual[N[(y$46$re * x$46$re), $MachinePrecision], 4.4e-119], (-N[(x$46$im * y$46$im), $MachinePrecision]), N[(y$46$re * x$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y.re \cdot x.re \leq -8.6 \cdot 10^{+23}:\\
\;\;\;\;y.re \cdot x.re\\
\mathbf{elif}\;y.re \cdot x.re \leq 4.4 \cdot 10^{-119}:\\
\;\;\;\;-x.im \cdot y.im\\
\mathbf{else}:\\
\;\;\;\;y.re \cdot x.re\\
\end{array}
\end{array}
if (*.f64 x.re y.re) < -8.5999999999999997e23 or 4.4000000000000001e-119 < (*.f64 x.re y.re) Initial program 98.0%
Taylor expanded in x.re around inf
*-lowering-*.f6483.0
Simplified83.0%
if -8.5999999999999997e23 < (*.f64 x.re y.re) < 4.4000000000000001e-119Initial program 100.0%
Taylor expanded in x.re around 0
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f6477.6
Simplified77.6%
Final simplification80.8%
(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 98.8%
Final simplification98.8%
(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 98.8%
Taylor expanded in x.re around inf
*-lowering-*.f6459.2
Simplified59.2%
Final simplification59.2%
herbie shell --seed 2024204
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, real part"
:precision binary64
(- (* x.re y.re) (* x.im y.im)))