
(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 5 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 (let* ((t_0 (+ (* x.im y.re) (* x.re y.im)))) (if (<= t_0 2e+273) t_0 (* y.re (+ x.im (* y.im (/ x.re y.re)))))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = (x_46_im * y_46_re) + (x_46_re * y_46_im);
double tmp;
if (t_0 <= 2e+273) {
tmp = t_0;
} else {
tmp = y_46_re * (x_46_im + (y_46_im * (x_46_re / 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) :: t_0
real(8) :: tmp
t_0 = (x_46im * y_46re) + (x_46re * y_46im)
if (t_0 <= 2d+273) then
tmp = t_0
else
tmp = y_46re * (x_46im + (y_46im * (x_46re / 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 t_0 = (x_46_im * y_46_re) + (x_46_re * y_46_im);
double tmp;
if (t_0 <= 2e+273) {
tmp = t_0;
} else {
tmp = y_46_re * (x_46_im + (y_46_im * (x_46_re / y_46_re)));
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = (x_46_im * y_46_re) + (x_46_re * y_46_im) tmp = 0 if t_0 <= 2e+273: tmp = t_0 else: tmp = y_46_re * (x_46_im + (y_46_im * (x_46_re / y_46_re))) return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(x_46_im * y_46_re) + Float64(x_46_re * y_46_im)) tmp = 0.0 if (t_0 <= 2e+273) tmp = t_0; else tmp = Float64(y_46_re * Float64(x_46_im + Float64(y_46_im * Float64(x_46_re / y_46_re)))); 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 * y_46_re) + (x_46_re * y_46_im); tmp = 0.0; if (t_0 <= 2e+273) tmp = t_0; else tmp = y_46_re * (x_46_im + (y_46_im * (x_46_re / y_46_re))); end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := Block[{t$95$0 = N[(N[(x$46$im * y$46$re), $MachinePrecision] + N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e+273], t$95$0, N[(y$46$re * N[(x$46$im + N[(y$46$im * N[(x$46$re / y$46$re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot y.re + x.re \cdot y.im\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{+273}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y.re \cdot \left(x.im + y.im \cdot \frac{x.re}{y.re}\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 x.re y.im) (*.f64 x.im y.re)) < 1.99999999999999989e273Initial program 100.0%
if 1.99999999999999989e273 < (+.f64 (*.f64 x.re y.im) (*.f64 x.im y.re)) Initial program 87.8%
Taylor expanded in y.re around inf 89.8%
*-commutative89.8%
associate-/l*100.0%
Applied egg-rr100.0%
Final simplification100.0%
(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 97.6%
fma-define99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (let* ((t_0 (+ (* x.im y.re) (* x.re y.im)))) (if (<= t_0 INFINITY) t_0 (* x.im y.re))))
double code(double x_46_re, double x_46_im, double y_46_re, double y_46_im) {
double t_0 = (x_46_im * y_46_re) + (x_46_re * y_46_im);
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = x_46_im * y_46_re;
}
return tmp;
}
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 * y_46_re) + (x_46_re * y_46_im);
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = x_46_im * y_46_re;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): t_0 = (x_46_im * y_46_re) + (x_46_re * y_46_im) tmp = 0 if t_0 <= math.inf: tmp = t_0 else: tmp = x_46_im * y_46_re return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) t_0 = Float64(Float64(x_46_im * y_46_re) + Float64(x_46_re * y_46_im)) tmp = 0.0 if (t_0 <= Inf) tmp = t_0; 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) t_0 = (x_46_im * y_46_re) + (x_46_re * y_46_im); tmp = 0.0; if (t_0 <= Inf) tmp = t_0; 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_] := Block[{t$95$0 = N[(N[(x$46$im * y$46$re), $MachinePrecision] + N[(x$46$re * y$46$im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[(x$46$im * y$46$re), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x.im \cdot y.re + x.re \cdot y.im\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x.im \cdot y.re\\
\end{array}
\end{array}
if (+.f64 (*.f64 x.re y.im) (*.f64 x.im y.re)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (*.f64 x.re y.im) (*.f64 x.im y.re)) Initial program 0.0%
Taylor expanded in x.re around 0 83.3%
Final simplification99.6%
(FPCore (x.re x.im y.re y.im) :precision binary64 (if (or (<= (* x.im y.re) -1.45e-112) (not (<= (* x.im y.re) 7e-20))) (* x.im y.re) (* x.re 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_im * y_46_re) <= -1.45e-112) || !((x_46_im * y_46_re) <= 7e-20)) {
tmp = x_46_im * y_46_re;
} else {
tmp = x_46_re * 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_46im * y_46re) <= (-1.45d-112)) .or. (.not. ((x_46im * y_46re) <= 7d-20))) then
tmp = x_46im * y_46re
else
tmp = x_46re * 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_im * y_46_re) <= -1.45e-112) || !((x_46_im * y_46_re) <= 7e-20)) {
tmp = x_46_im * y_46_re;
} else {
tmp = x_46_re * y_46_im;
}
return tmp;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): tmp = 0 if ((x_46_im * y_46_re) <= -1.45e-112) or not ((x_46_im * y_46_re) <= 7e-20): tmp = x_46_im * y_46_re else: tmp = x_46_re * y_46_im return tmp
function code(x_46_re, x_46_im, y_46_re, y_46_im) tmp = 0.0 if ((Float64(x_46_im * y_46_re) <= -1.45e-112) || !(Float64(x_46_im * y_46_re) <= 7e-20)) tmp = Float64(x_46_im * y_46_re); else tmp = Float64(x_46_re * 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_im * y_46_re) <= -1.45e-112) || ~(((x_46_im * y_46_re) <= 7e-20))) tmp = x_46_im * y_46_re; else tmp = x_46_re * y_46_im; end tmp_2 = tmp; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := If[Or[LessEqual[N[(x$46$im * y$46$re), $MachinePrecision], -1.45e-112], N[Not[LessEqual[N[(x$46$im * y$46$re), $MachinePrecision], 7e-20]], $MachinePrecision]], N[(x$46$im * y$46$re), $MachinePrecision], N[(x$46$re * y$46$im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \cdot y.re \leq -1.45 \cdot 10^{-112} \lor \neg \left(x.im \cdot y.re \leq 7 \cdot 10^{-20}\right):\\
\;\;\;\;x.im \cdot y.re\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot y.im\\
\end{array}
\end{array}
if (*.f64 x.im y.re) < -1.44999999999999996e-112 or 7.00000000000000007e-20 < (*.f64 x.im y.re) Initial program 95.8%
Taylor expanded in x.re around 0 76.1%
if -1.44999999999999996e-112 < (*.f64 x.im y.re) < 7.00000000000000007e-20Initial program 100.0%
Taylor expanded in x.re around inf 84.2%
Final simplification79.7%
(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 97.6%
Taylor expanded in x.re around 0 51.4%
Final simplification51.4%
herbie shell --seed 2024079
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, imaginary part"
:precision binary64
(+ (* x.re y.im) (* x.im y.re)))