
(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 (- (* 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%
(FPCore (x.re x.im y.re y.im)
:precision binary64
(if (or (<= (* x.im y.im) -4e+54)
(and (not (<= (* x.im y.im) -2e-86))
(or (<= (* x.im y.im) -2e-182) (not (<= (* x.im y.im) 1e+43)))))
(* y.im (- x.im))
(* x.re 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 * y_46_im) <= -4e+54) || (!((x_46_im * y_46_im) <= -2e-86) && (((x_46_im * y_46_im) <= -2e-182) || !((x_46_im * y_46_im) <= 1e+43)))) {
tmp = y_46_im * -x_46_im;
} else {
tmp = 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) :: tmp
if (((x_46im * y_46im) <= (-4d+54)) .or. (.not. ((x_46im * y_46im) <= (-2d-86))) .and. ((x_46im * y_46im) <= (-2d-182)) .or. (.not. ((x_46im * y_46im) <= 1d+43))) then
tmp = y_46im * -x_46im
else
tmp = 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 tmp;
if (((x_46_im * y_46_im) <= -4e+54) || (!((x_46_im * y_46_im) <= -2e-86) && (((x_46_im * y_46_im) <= -2e-182) || !((x_46_im * y_46_im) <= 1e+43)))) {
tmp = y_46_im * -x_46_im;
} else {
tmp = x_46_re * 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 * y_46_im) <= -4e+54) or (not ((x_46_im * y_46_im) <= -2e-86) and (((x_46_im * y_46_im) <= -2e-182) or not ((x_46_im * y_46_im) <= 1e+43))): tmp = y_46_im * -x_46_im else: tmp = x_46_re * y_46_re 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_im) <= -4e+54) || (!(Float64(x_46_im * y_46_im) <= -2e-86) && ((Float64(x_46_im * y_46_im) <= -2e-182) || !(Float64(x_46_im * y_46_im) <= 1e+43)))) tmp = Float64(y_46_im * Float64(-x_46_im)); else tmp = 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) tmp = 0.0; if (((x_46_im * y_46_im) <= -4e+54) || (~(((x_46_im * y_46_im) <= -2e-86)) && (((x_46_im * y_46_im) <= -2e-182) || ~(((x_46_im * y_46_im) <= 1e+43))))) tmp = y_46_im * -x_46_im; else tmp = x_46_re * y_46_re; 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$im), $MachinePrecision], -4e+54], And[N[Not[LessEqual[N[(x$46$im * y$46$im), $MachinePrecision], -2e-86]], $MachinePrecision], Or[LessEqual[N[(x$46$im * y$46$im), $MachinePrecision], -2e-182], N[Not[LessEqual[N[(x$46$im * y$46$im), $MachinePrecision], 1e+43]], $MachinePrecision]]]], N[(y$46$im * (-x$46$im)), $MachinePrecision], N[(x$46$re * y$46$re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x.im \cdot y.im \leq -4 \cdot 10^{+54} \lor \neg \left(x.im \cdot y.im \leq -2 \cdot 10^{-86}\right) \land \left(x.im \cdot y.im \leq -2 \cdot 10^{-182} \lor \neg \left(x.im \cdot y.im \leq 10^{+43}\right)\right):\\
\;\;\;\;y.im \cdot \left(-x.im\right)\\
\mathbf{else}:\\
\;\;\;\;x.re \cdot y.re\\
\end{array}
\end{array}
if (*.f64 x.im y.im) < -4.0000000000000003e54 or -2.00000000000000017e-86 < (*.f64 x.im y.im) < -2.0000000000000001e-182 or 1.00000000000000001e43 < (*.f64 x.im y.im) Initial program 99.2%
Taylor expanded in x.re around 0 86.8%
mul-1-neg86.8%
distribute-rgt-neg-out86.8%
Simplified86.8%
if -4.0000000000000003e54 < (*.f64 x.im y.im) < -2.00000000000000017e-86 or -2.0000000000000001e-182 < (*.f64 x.im y.im) < 1.00000000000000001e43Initial program 100.0%
Taylor expanded in x.re around inf 78.0%
Final simplification82.2%
(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.2%
(FPCore (x.re x.im y.re y.im) :precision binary64 (* 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_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_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_im * y_46_im;
}
def code(x_46_re, x_46_im, y_46_re, y_46_im): return x_46_im * y_46_im
function code(x_46_re, x_46_im, y_46_re, y_46_im) return 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_im * y_46_im; end
code[x$46$re_, x$46$im_, y$46$re_, y$46$im_] := N[(x$46$im * y$46$im), $MachinePrecision]
\begin{array}{l}
\\
x.im \cdot y.im
\end{array}
Initial program 99.6%
Taylor expanded in x.re around 0 53.8%
mul-1-neg53.8%
distribute-rgt-neg-out53.8%
Simplified53.8%
expm1-log1p-u35.1%
expm1-undefine24.5%
*-commutative24.5%
add-sqr-sqrt10.4%
sqrt-unprod9.0%
sqr-neg9.0%
sqrt-unprod1.0%
add-sqr-sqrt2.3%
Applied egg-rr2.3%
log1p-undefine2.3%
rem-exp-log2.5%
+-commutative2.5%
associate--l+2.5%
metadata-eval2.5%
mul0-lft2.5%
distribute-rgt-in2.5%
+-rgt-identity2.5%
Simplified2.5%
herbie shell --seed 2024111
(FPCore (x.re x.im y.re y.im)
:name "_multiplyComplex, real part"
:precision binary64
(- (* x.re y.re) (* x.im y.im)))