
(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 3 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 (- (* 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}
Initial program 99.6%
Final simplification99.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= x.re -1.18e+61) (not (<= x.re 9.6e-96))) (* 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) {
double tmp;
if ((x_46_re <= -1.18e+61) || !(x_46_re <= 9.6e-96)) {
tmp = x_46_re * y_46_re;
} else {
tmp = x_46_im * -y_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 ((x_46re <= (-1.18d+61)) .or. (.not. (x_46re <= 9.6d-96))) then
tmp = x_46re * y_46re
else
tmp = x_46im * -y_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 ((x_46_re <= -1.18e+61) || !(x_46_re <= 9.6e-96)) {
tmp = x_46_re * y_46_re;
} else {
tmp = x_46_im * -y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if (x_46_re <= -1.18e+61) or not (x_46_re <= 9.6e-96): tmp = x_46_re * y_46_re else: tmp = x_46_im * -y_46_im return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((x_46_re <= -1.18e+61) || !(x_46_re <= 9.6e-96)) tmp = Float64(x_46_re * y_46_re); else tmp = Float64(x_46_im * Float64(-y_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 ((x_46_re <= -1.18e+61) || ~((x_46_re <= 9.6e-96))) tmp = x_46_re * y_46_re; else tmp = x_46_im * -y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[x$46$re, -1.18e+61], N[Not[LessEqual[x$46$re, 9.6e-96]], $MachinePrecision]], N[(x$46$re * y$46$re), $MachinePrecision], N[(x$46$im * (-y$46$im)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.re \leq -1.18 \cdot 10^{+61} \lor \neg \left(x.re \leq 9.6 \cdot 10^{-96}\right):\\
\;\;\;\;x.re \cdot y.re\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot \left(-y.im\right)\\
\end{array}
\end{array}
if x.re < -1.18000000000000004e61 or 9.60000000000000076e-96 < x.re Initial program 99.3%
Taylor expanded in x.re around inf 67.1%
if -1.18000000000000004e61 < x.re < 9.60000000000000076e-96Initial program 100.0%
Taylor expanded in x.re around 0 74.5%
mul-1-neg74.5%
distribute-rgt-neg-out74.5%
Simplified74.5%
Final simplification70.5%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* x.re 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_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_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_re;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_re * y_46_re
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_re * 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_re; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$re * y$46$re), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot y.re
\end{array}
Initial program 99.6%
Taylor expanded in x.re around inf 48.5%
Final simplification48.5%
herbie shell --seed 2024131
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, real part"
:precision binary64
(- (* x.re y.re) (* x.im y.im)))