
(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 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 fma(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 fma(x_46_re, y_46_im, Float64(x_46_im * y_46_re)) end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$re * y$46$im + N[(x$46$im * y$46$re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x.re, y.im, x.im \cdot y.re\right)
\end{array}
Initial program 98.8%
fma-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (<= x.im -1.8e+51) (* x.im y.re) (if (<= x.im 2.3e-106) (* 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) {
double tmp;
if (x_46_im <= -1.8e+51) {
tmp = x_46_im * y_46_re;
} else if (x_46_im <= 2.3e-106) {
tmp = x_46_re * y_46_im;
} else {
tmp = x_46_im * y_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 (x_46im <= (-1.8d+51)) then
tmp = x_46im * y_46re
else if (x_46im <= 2.3d-106) then
tmp = x_46re * y_46im
else
tmp = x_46im * y_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 (x_46_im <= -1.8e+51) {
tmp = x_46_im * y_46_re;
} else if (x_46_im <= 2.3e-106) {
tmp = x_46_re * y_46_im;
} else {
tmp = x_46_im * y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if x_46_im <= -1.8e+51: tmp = x_46_im * y_46_re elif x_46_im <= 2.3e-106: tmp = x_46_re * y_46_im else: tmp = x_46_im * y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if (x_46_im <= -1.8e+51) tmp = Float64(x_46_im * y_46_re); elseif (x_46_im <= 2.3e-106) tmp = Float64(x_46_re * y_46_im); else tmp = Float64(x_46_im * y_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 (x_46_im <= -1.8e+51) tmp = x_46_im * y_46_re; elseif (x_46_im <= 2.3e-106) tmp = x_46_re * y_46_im; else tmp = x_46_im * y_46_re; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[LessEqual[x$46$im, -1.8e+51], N[(x$46$im * y$46$re), $MachinePrecision], If[LessEqual[x$46$im, 2.3e-106], N[(x$46$re * y$46$im), $MachinePrecision], N[(x$46$im * y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -1.8 \cdot 10^{+51}:\\
\;\;\;\;x.im \cdot y.re\\
\mathbf{elif}\;x.im \leq 2.3 \cdot 10^{-106}:\\
\;\;\;\;x.re \cdot y.im\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot y.re\\
\end{array}
\end{array}
if x.im < -1.80000000000000005e51 or 2.3000000000000001e-106 < x.im Initial program 97.8%
Taylor expanded in x.re around 0 61.6%
if -1.80000000000000005e51 < x.im < 2.3000000000000001e-106Initial program 100.0%
Taylor expanded in x.re around inf 69.3%
Final simplification65.2%
(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}
Initial program 98.8%
Final simplification98.8%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* x.re 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_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_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_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_re * y_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im) return Float64(x_46_re * 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_im; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$re * y$46$im), $MachinePrecision]
\begin{array}{l}
\\
x.re \cdot y.im
\end{array}
Initial program 98.8%
Taylor expanded in x.re around inf 54.4%
Final simplification54.4%
herbie shell --seed 2023199
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, imaginary part"
:precision binary64
(+ (* x.re y.im) (* x.im y.re)))