_multiplyComplex, real part

Percentage Accurate: 99.2% → 99.2%
Time: 3.3s
Alternatives: 3
Speedup: 1.0×

Specification

?
\[\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}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 3 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.2% accurate, 1.0× speedup?

\[\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}

Alternative 1: 99.2% accurate, 1.0× speedup?

\[\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}
Derivation
  1. Initial program 99.6%

    \[x.re \cdot y.re - x.im \cdot y.im \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 67.7% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x.im \leq -3.35 \cdot 10^{-34} \lor \neg \left(x.im \leq -5.6 \cdot 10^{-104}\right) \land \left(x.im \leq -9 \cdot 10^{-106} \lor \neg \left(x.im \leq -8.5 \cdot 10^{-113}\right) \land \left(x.im \leq -1.4 \cdot 10^{-114} \lor \neg \left(x.im \leq -9.6 \cdot 10^{-139}\right) \land \left(x.im \leq -7 \cdot 10^{-139} \lor \neg \left(x.im \leq -2.3 \cdot 10^{-147}\right) \land \left(x.im \leq -1.22 \cdot 10^{-147} \lor \neg \left(x.im \leq -4.2 \cdot 10^{-161}\right) \land \left(x.im \leq -4.8 \cdot 10^{-172} \lor \neg \left(x.im \leq -4.8 \cdot 10^{-192}\right) \land \left(x.im \leq -4.7 \cdot 10^{-192} \lor \neg \left(x.im \leq -1.5 \cdot 10^{-259}\right) \land \left(x.im \leq -8.6 \cdot 10^{-260} \lor \neg \left(x.im \leq -7.8 \cdot 10^{-271}\right) \land \left(x.im \leq -7.6 \cdot 10^{-271} \lor \neg \left(x.im \leq 1.3 \cdot 10^{-255}\right) \land \left(x.im \leq 1.35 \cdot 10^{-255} \lor \neg \left(x.im \leq 1.05 \cdot 10^{-248}\right) \land \left(x.im \leq 5.4 \cdot 10^{-248} \lor \neg \left(x.im \leq 2.4 \cdot 10^{-196}\right) \land \left(x.im \leq 2.5 \cdot 10^{-196} \lor \neg \left(x.im \leq 5 \cdot 10^{-187}\right) \land \left(x.im \leq 5.2 \cdot 10^{-187} \lor \neg \left(x.im \leq 2.3 \cdot 10^{-178}\right) \land \left(x.im \leq 2.35 \cdot 10^{-178} \lor \neg \left(x.im \leq 9.5 \cdot 10^{-150}\right) \land \left(x.im \leq 1.2 \cdot 10^{-120} \lor \neg \left(x.im \leq 1.55 \cdot 10^{-105}\right) \land \left(x.im \leq 2.35 \cdot 10^{-102} \lor \neg \left(x.im \leq 7.5 \cdot 10^{-95}\right) \land \left(x.im \leq 1.85 \cdot 10^{-90} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-83}\right) \land \left(x.im \leq 1.45 \cdot 10^{-65} \lor \neg \left(x.im \leq 1.05 \cdot 10^{-58} \lor \neg \left(x.im \leq 9.6 \cdot 10^{-57}\right) \land \left(x.im \leq 1.15 \cdot 10^{-49} \lor \neg \left(x.im \leq 7.6 \cdot 10^{-25}\right) \land \left(x.im \leq 18 \lor \neg \left(x.im \leq 1300\right) \land \left(x.im \leq 125000000 \lor \neg \left(x.im \leq 1.9 \cdot 10^{+75}\right) \land x.im \leq 5.8 \cdot 10^{+76}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\ \;\;\;\;x.im \cdot \left(-y.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot y.re\\ \end{array} \end{array} \]
(FPCore (x.re x.im y.re y.im)
 :precision binary64
 (if (or (<= x.im -3.35e-34)
         (and (not (<= x.im -5.6e-104))
              (or (<= x.im -9e-106)
                  (and (not (<= x.im -8.5e-113))
                       (or (<= x.im -1.4e-114)
                           (and (not (<= x.im -9.6e-139))
                                (or (<= x.im -7e-139)
                                    (and (not (<= x.im -2.3e-147))
                                         (or (<= x.im -1.22e-147)
                                             (and (not (<= x.im -4.2e-161))
                                                  (or (<= x.im -4.8e-172)
                                                      (and (not
                                                            (<=
                                                             x.im
                                                             -4.8e-192))
                                                           (or (<=
                                                                x.im
                                                                -4.7e-192)
                                                               (and (not
                                                                     (<=
                                                                      x.im
                                                                      -1.5e-259))
                                                                    (or (<=
                                                                         x.im
                                                                         -8.6e-260)
                                                                        (and (not
                                                                              (<=
                                                                               x.im
                                                                               -7.8e-271))
                                                                             (or (<=
                                                                                  x.im
                                                                                  -7.6e-271)
                                                                                 (and (not
                                                                                       (<=
                                                                                        x.im
                                                                                        1.3e-255))
                                                                                      (or (<=
                                                                                           x.im
                                                                                           1.35e-255)
                                                                                          (and (not
                                                                                                (<=
                                                                                                 x.im
                                                                                                 1.05e-248))
                                                                                               (or (<=
                                                                                                    x.im
                                                                                                    5.4e-248)
                                                                                                   (and (not
                                                                                                         (<=
                                                                                                          x.im
                                                                                                          2.4e-196))
                                                                                                        (or (<=
                                                                                                             x.im
                                                                                                             2.5e-196)
                                                                                                            (and (not
                                                                                                                  (<=
                                                                                                                   x.im
                                                                                                                   5e-187))
                                                                                                                 (or (<=
                                                                                                                      x.im
                                                                                                                      5.2e-187)
                                                                                                                     (and (not
                                                                                                                           (<=
                                                                                                                            x.im
                                                                                                                            2.3e-178))
                                                                                                                          (or (<=
                                                                                                                               x.im
                                                                                                                               2.35e-178)
                                                                                                                              (and (not
                                                                                                                                    (<=
                                                                                                                                     x.im
                                                                                                                                     9.5e-150))
                                                                                                                                   (or (<=
                                                                                                                                        x.im
                                                                                                                                        1.2e-120)
                                                                                                                                       (and (not
                                                                                                                                             (<=
                                                                                                                                              x.im
                                                                                                                                              1.55e-105))
                                                                                                                                            (or (<=
                                                                                                                                                 x.im
                                                                                                                                                 2.35e-102)
                                                                                                                                                (and (not
                                                                                                                                                      (<=
                                                                                                                                                       x.im
                                                                                                                                                       7.5e-95))
                                                                                                                                                     (or (<=
                                                                                                                                                          x.im
                                                                                                                                                          1.85e-90)
                                                                                                                                                         (and (not
                                                                                                                                                               (<=
                                                                                                                                                                x.im
                                                                                                                                                                1.4e-83))
                                                                                                                                                              (or (<=
                                                                                                                                                                   x.im
                                                                                                                                                                   1.45e-65)
                                                                                                                                                                  (not
                                                                                                                                                                   (or (<=
                                                                                                                                                                        x.im
                                                                                                                                                                        1.05e-58)
                                                                                                                                                                       (and (not
                                                                                                                                                                             (<=
                                                                                                                                                                              x.im
                                                                                                                                                                              9.6e-57))
                                                                                                                                                                            (or (<=
                                                                                                                                                                                 x.im
                                                                                                                                                                                 1.15e-49)
                                                                                                                                                                                (and (not
                                                                                                                                                                                      (<=
                                                                                                                                                                                       x.im
                                                                                                                                                                                       7.6e-25))
                                                                                                                                                                                     (or (<=
                                                                                                                                                                                          x.im
                                                                                                                                                                                          18.0)
                                                                                                                                                                                         (and (not
                                                                                                                                                                                               (<=
                                                                                                                                                                                                x.im
                                                                                                                                                                                                1300.0))
                                                                                                                                                                                              (or (<=
                                                                                                                                                                                                   x.im
                                                                                                                                                                                                   125000000.0)
                                                                                                                                                                                                  (and (not
                                                                                                                                                                                                        (<=
                                                                                                                                                                                                         x.im
                                                                                                                                                                                                         1.9e+75))
                                                                                                                                                                                                       (<=
                                                                                                                                                                                                        x.im
                                                                                                                                                                                                        5.8e+76)))))))))))))))))))))))))))))))))))))))))))))
   (* 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 tmp;
	if ((x_46_im <= -3.35e-34) || (!(x_46_im <= -5.6e-104) && ((x_46_im <= -9e-106) || (!(x_46_im <= -8.5e-113) && ((x_46_im <= -1.4e-114) || (!(x_46_im <= -9.6e-139) && ((x_46_im <= -7e-139) || (!(x_46_im <= -2.3e-147) && ((x_46_im <= -1.22e-147) || (!(x_46_im <= -4.2e-161) && ((x_46_im <= -4.8e-172) || (!(x_46_im <= -4.8e-192) && ((x_46_im <= -4.7e-192) || (!(x_46_im <= -1.5e-259) && ((x_46_im <= -8.6e-260) || (!(x_46_im <= -7.8e-271) && ((x_46_im <= -7.6e-271) || (!(x_46_im <= 1.3e-255) && ((x_46_im <= 1.35e-255) || (!(x_46_im <= 1.05e-248) && ((x_46_im <= 5.4e-248) || (!(x_46_im <= 2.4e-196) && ((x_46_im <= 2.5e-196) || (!(x_46_im <= 5e-187) && ((x_46_im <= 5.2e-187) || (!(x_46_im <= 2.3e-178) && ((x_46_im <= 2.35e-178) || (!(x_46_im <= 9.5e-150) && ((x_46_im <= 1.2e-120) || (!(x_46_im <= 1.55e-105) && ((x_46_im <= 2.35e-102) || (!(x_46_im <= 7.5e-95) && ((x_46_im <= 1.85e-90) || (!(x_46_im <= 1.4e-83) && ((x_46_im <= 1.45e-65) || !((x_46_im <= 1.05e-58) || (!(x_46_im <= 9.6e-57) && ((x_46_im <= 1.15e-49) || (!(x_46_im <= 7.6e-25) && ((x_46_im <= 18.0) || (!(x_46_im <= 1300.0) && ((x_46_im <= 125000000.0) || (!(x_46_im <= 1.9e+75) && (x_46_im <= 5.8e+76)))))))))))))))))))))))))))))))))))))))))))) {
		tmp = x_46_im * -y_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 <= (-3.35d-34)) .or. (.not. (x_46im <= (-5.6d-104))) .and. (x_46im <= (-9d-106)) .or. (.not. (x_46im <= (-8.5d-113))) .and. (x_46im <= (-1.4d-114)) .or. (.not. (x_46im <= (-9.6d-139))) .and. (x_46im <= (-7d-139)) .or. (.not. (x_46im <= (-2.3d-147))) .and. (x_46im <= (-1.22d-147)) .or. (.not. (x_46im <= (-4.2d-161))) .and. (x_46im <= (-4.8d-172)) .or. (.not. (x_46im <= (-4.8d-192))) .and. (x_46im <= (-4.7d-192)) .or. (.not. (x_46im <= (-1.5d-259))) .and. (x_46im <= (-8.6d-260)) .or. (.not. (x_46im <= (-7.8d-271))) .and. (x_46im <= (-7.6d-271)) .or. (.not. (x_46im <= 1.3d-255)) .and. (x_46im <= 1.35d-255) .or. (.not. (x_46im <= 1.05d-248)) .and. (x_46im <= 5.4d-248) .or. (.not. (x_46im <= 2.4d-196)) .and. (x_46im <= 2.5d-196) .or. (.not. (x_46im <= 5d-187)) .and. (x_46im <= 5.2d-187) .or. (.not. (x_46im <= 2.3d-178)) .and. (x_46im <= 2.35d-178) .or. (.not. (x_46im <= 9.5d-150)) .and. (x_46im <= 1.2d-120) .or. (.not. (x_46im <= 1.55d-105)) .and. (x_46im <= 2.35d-102) .or. (.not. (x_46im <= 7.5d-95)) .and. (x_46im <= 1.85d-90) .or. (.not. (x_46im <= 1.4d-83)) .and. (x_46im <= 1.45d-65) .or. (.not. (x_46im <= 1.05d-58) .or. (.not. (x_46im <= 9.6d-57)) .and. (x_46im <= 1.15d-49) .or. (.not. (x_46im <= 7.6d-25)) .and. (x_46im <= 18.0d0) .or. (.not. (x_46im <= 1300.0d0)) .and. (x_46im <= 125000000.0d0) .or. (.not. (x_46im <= 1.9d+75)) .and. (x_46im <= 5.8d+76))) then
        tmp = x_46im * -y_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 <= -3.35e-34) || (!(x_46_im <= -5.6e-104) && ((x_46_im <= -9e-106) || (!(x_46_im <= -8.5e-113) && ((x_46_im <= -1.4e-114) || (!(x_46_im <= -9.6e-139) && ((x_46_im <= -7e-139) || (!(x_46_im <= -2.3e-147) && ((x_46_im <= -1.22e-147) || (!(x_46_im <= -4.2e-161) && ((x_46_im <= -4.8e-172) || (!(x_46_im <= -4.8e-192) && ((x_46_im <= -4.7e-192) || (!(x_46_im <= -1.5e-259) && ((x_46_im <= -8.6e-260) || (!(x_46_im <= -7.8e-271) && ((x_46_im <= -7.6e-271) || (!(x_46_im <= 1.3e-255) && ((x_46_im <= 1.35e-255) || (!(x_46_im <= 1.05e-248) && ((x_46_im <= 5.4e-248) || (!(x_46_im <= 2.4e-196) && ((x_46_im <= 2.5e-196) || (!(x_46_im <= 5e-187) && ((x_46_im <= 5.2e-187) || (!(x_46_im <= 2.3e-178) && ((x_46_im <= 2.35e-178) || (!(x_46_im <= 9.5e-150) && ((x_46_im <= 1.2e-120) || (!(x_46_im <= 1.55e-105) && ((x_46_im <= 2.35e-102) || (!(x_46_im <= 7.5e-95) && ((x_46_im <= 1.85e-90) || (!(x_46_im <= 1.4e-83) && ((x_46_im <= 1.45e-65) || !((x_46_im <= 1.05e-58) || (!(x_46_im <= 9.6e-57) && ((x_46_im <= 1.15e-49) || (!(x_46_im <= 7.6e-25) && ((x_46_im <= 18.0) || (!(x_46_im <= 1300.0) && ((x_46_im <= 125000000.0) || (!(x_46_im <= 1.9e+75) && (x_46_im <= 5.8e+76)))))))))))))))))))))))))))))))))))))))))))) {
		tmp = x_46_im * -y_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 <= -3.35e-34) or (not (x_46_im <= -5.6e-104) and ((x_46_im <= -9e-106) or (not (x_46_im <= -8.5e-113) and ((x_46_im <= -1.4e-114) or (not (x_46_im <= -9.6e-139) and ((x_46_im <= -7e-139) or (not (x_46_im <= -2.3e-147) and ((x_46_im <= -1.22e-147) or (not (x_46_im <= -4.2e-161) and ((x_46_im <= -4.8e-172) or (not (x_46_im <= -4.8e-192) and ((x_46_im <= -4.7e-192) or (not (x_46_im <= -1.5e-259) and ((x_46_im <= -8.6e-260) or (not (x_46_im <= -7.8e-271) and ((x_46_im <= -7.6e-271) or (not (x_46_im <= 1.3e-255) and ((x_46_im <= 1.35e-255) or (not (x_46_im <= 1.05e-248) and ((x_46_im <= 5.4e-248) or (not (x_46_im <= 2.4e-196) and ((x_46_im <= 2.5e-196) or (not (x_46_im <= 5e-187) and ((x_46_im <= 5.2e-187) or (not (x_46_im <= 2.3e-178) and ((x_46_im <= 2.35e-178) or (not (x_46_im <= 9.5e-150) and ((x_46_im <= 1.2e-120) or (not (x_46_im <= 1.55e-105) and ((x_46_im <= 2.35e-102) or (not (x_46_im <= 7.5e-95) and ((x_46_im <= 1.85e-90) or (not (x_46_im <= 1.4e-83) and ((x_46_im <= 1.45e-65) or not ((x_46_im <= 1.05e-58) or (not (x_46_im <= 9.6e-57) and ((x_46_im <= 1.15e-49) or (not (x_46_im <= 7.6e-25) and ((x_46_im <= 18.0) or (not (x_46_im <= 1300.0) and ((x_46_im <= 125000000.0) or (not (x_46_im <= 1.9e+75) and (x_46_im <= 5.8e+76))))))))))))))))))))))))))))))))))))))))))):
		tmp = x_46_im * -y_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 ((x_46_im <= -3.35e-34) || (!(x_46_im <= -5.6e-104) && ((x_46_im <= -9e-106) || (!(x_46_im <= -8.5e-113) && ((x_46_im <= -1.4e-114) || (!(x_46_im <= -9.6e-139) && ((x_46_im <= -7e-139) || (!(x_46_im <= -2.3e-147) && ((x_46_im <= -1.22e-147) || (!(x_46_im <= -4.2e-161) && ((x_46_im <= -4.8e-172) || (!(x_46_im <= -4.8e-192) && ((x_46_im <= -4.7e-192) || (!(x_46_im <= -1.5e-259) && ((x_46_im <= -8.6e-260) || (!(x_46_im <= -7.8e-271) && ((x_46_im <= -7.6e-271) || (!(x_46_im <= 1.3e-255) && ((x_46_im <= 1.35e-255) || (!(x_46_im <= 1.05e-248) && ((x_46_im <= 5.4e-248) || (!(x_46_im <= 2.4e-196) && ((x_46_im <= 2.5e-196) || (!(x_46_im <= 5e-187) && ((x_46_im <= 5.2e-187) || (!(x_46_im <= 2.3e-178) && ((x_46_im <= 2.35e-178) || (!(x_46_im <= 9.5e-150) && ((x_46_im <= 1.2e-120) || (!(x_46_im <= 1.55e-105) && ((x_46_im <= 2.35e-102) || (!(x_46_im <= 7.5e-95) && ((x_46_im <= 1.85e-90) || (!(x_46_im <= 1.4e-83) && ((x_46_im <= 1.45e-65) || !((x_46_im <= 1.05e-58) || (!(x_46_im <= 9.6e-57) && ((x_46_im <= 1.15e-49) || (!(x_46_im <= 7.6e-25) && ((x_46_im <= 18.0) || (!(x_46_im <= 1300.0) && ((x_46_im <= 125000000.0) || (!(x_46_im <= 1.9e+75) && (x_46_im <= 5.8e+76))))))))))))))))))))))))))))))))))))))))))))
		tmp = Float64(x_46_im * Float64(-y_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 <= -3.35e-34) || (~((x_46_im <= -5.6e-104)) && ((x_46_im <= -9e-106) || (~((x_46_im <= -8.5e-113)) && ((x_46_im <= -1.4e-114) || (~((x_46_im <= -9.6e-139)) && ((x_46_im <= -7e-139) || (~((x_46_im <= -2.3e-147)) && ((x_46_im <= -1.22e-147) || (~((x_46_im <= -4.2e-161)) && ((x_46_im <= -4.8e-172) || (~((x_46_im <= -4.8e-192)) && ((x_46_im <= -4.7e-192) || (~((x_46_im <= -1.5e-259)) && ((x_46_im <= -8.6e-260) || (~((x_46_im <= -7.8e-271)) && ((x_46_im <= -7.6e-271) || (~((x_46_im <= 1.3e-255)) && ((x_46_im <= 1.35e-255) || (~((x_46_im <= 1.05e-248)) && ((x_46_im <= 5.4e-248) || (~((x_46_im <= 2.4e-196)) && ((x_46_im <= 2.5e-196) || (~((x_46_im <= 5e-187)) && ((x_46_im <= 5.2e-187) || (~((x_46_im <= 2.3e-178)) && ((x_46_im <= 2.35e-178) || (~((x_46_im <= 9.5e-150)) && ((x_46_im <= 1.2e-120) || (~((x_46_im <= 1.55e-105)) && ((x_46_im <= 2.35e-102) || (~((x_46_im <= 7.5e-95)) && ((x_46_im <= 1.85e-90) || (~((x_46_im <= 1.4e-83)) && ((x_46_im <= 1.45e-65) || ~(((x_46_im <= 1.05e-58) || (~((x_46_im <= 9.6e-57)) && ((x_46_im <= 1.15e-49) || (~((x_46_im <= 7.6e-25)) && ((x_46_im <= 18.0) || (~((x_46_im <= 1300.0)) && ((x_46_im <= 125000000.0) || (~((x_46_im <= 1.9e+75)) && (x_46_im <= 5.8e+76)))))))))))))))))))))))))))))))))))))))))))))
		tmp = x_46_im * -y_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[x$46$im, -3.35e-34], And[N[Not[LessEqual[x$46$im, -5.6e-104]], $MachinePrecision], Or[LessEqual[x$46$im, -9e-106], And[N[Not[LessEqual[x$46$im, -8.5e-113]], $MachinePrecision], Or[LessEqual[x$46$im, -1.4e-114], And[N[Not[LessEqual[x$46$im, -9.6e-139]], $MachinePrecision], Or[LessEqual[x$46$im, -7e-139], And[N[Not[LessEqual[x$46$im, -2.3e-147]], $MachinePrecision], Or[LessEqual[x$46$im, -1.22e-147], And[N[Not[LessEqual[x$46$im, -4.2e-161]], $MachinePrecision], Or[LessEqual[x$46$im, -4.8e-172], And[N[Not[LessEqual[x$46$im, -4.8e-192]], $MachinePrecision], Or[LessEqual[x$46$im, -4.7e-192], And[N[Not[LessEqual[x$46$im, -1.5e-259]], $MachinePrecision], Or[LessEqual[x$46$im, -8.6e-260], And[N[Not[LessEqual[x$46$im, -7.8e-271]], $MachinePrecision], Or[LessEqual[x$46$im, -7.6e-271], And[N[Not[LessEqual[x$46$im, 1.3e-255]], $MachinePrecision], Or[LessEqual[x$46$im, 1.35e-255], And[N[Not[LessEqual[x$46$im, 1.05e-248]], $MachinePrecision], Or[LessEqual[x$46$im, 5.4e-248], And[N[Not[LessEqual[x$46$im, 2.4e-196]], $MachinePrecision], Or[LessEqual[x$46$im, 2.5e-196], And[N[Not[LessEqual[x$46$im, 5e-187]], $MachinePrecision], Or[LessEqual[x$46$im, 5.2e-187], And[N[Not[LessEqual[x$46$im, 2.3e-178]], $MachinePrecision], Or[LessEqual[x$46$im, 2.35e-178], And[N[Not[LessEqual[x$46$im, 9.5e-150]], $MachinePrecision], Or[LessEqual[x$46$im, 1.2e-120], And[N[Not[LessEqual[x$46$im, 1.55e-105]], $MachinePrecision], Or[LessEqual[x$46$im, 2.35e-102], And[N[Not[LessEqual[x$46$im, 7.5e-95]], $MachinePrecision], Or[LessEqual[x$46$im, 1.85e-90], And[N[Not[LessEqual[x$46$im, 1.4e-83]], $MachinePrecision], Or[LessEqual[x$46$im, 1.45e-65], N[Not[Or[LessEqual[x$46$im, 1.05e-58], And[N[Not[LessEqual[x$46$im, 9.6e-57]], $MachinePrecision], Or[LessEqual[x$46$im, 1.15e-49], And[N[Not[LessEqual[x$46$im, 7.6e-25]], $MachinePrecision], Or[LessEqual[x$46$im, 18.0], And[N[Not[LessEqual[x$46$im, 1300.0]], $MachinePrecision], Or[LessEqual[x$46$im, 125000000.0], And[N[Not[LessEqual[x$46$im, 1.9e+75]], $MachinePrecision], LessEqual[x$46$im, 5.8e+76]]]]]]]]]], $MachinePrecision]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]], N[(x$46$im * (-y$46$im)), $MachinePrecision], N[(x$46$re * y$46$re), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x.im \leq -3.35 \cdot 10^{-34} \lor \neg \left(x.im \leq -5.6 \cdot 10^{-104}\right) \land \left(x.im \leq -9 \cdot 10^{-106} \lor \neg \left(x.im \leq -8.5 \cdot 10^{-113}\right) \land \left(x.im \leq -1.4 \cdot 10^{-114} \lor \neg \left(x.im \leq -9.6 \cdot 10^{-139}\right) \land \left(x.im \leq -7 \cdot 10^{-139} \lor \neg \left(x.im \leq -2.3 \cdot 10^{-147}\right) \land \left(x.im \leq -1.22 \cdot 10^{-147} \lor \neg \left(x.im \leq -4.2 \cdot 10^{-161}\right) \land \left(x.im \leq -4.8 \cdot 10^{-172} \lor \neg \left(x.im \leq -4.8 \cdot 10^{-192}\right) \land \left(x.im \leq -4.7 \cdot 10^{-192} \lor \neg \left(x.im \leq -1.5 \cdot 10^{-259}\right) \land \left(x.im \leq -8.6 \cdot 10^{-260} \lor \neg \left(x.im \leq -7.8 \cdot 10^{-271}\right) \land \left(x.im \leq -7.6 \cdot 10^{-271} \lor \neg \left(x.im \leq 1.3 \cdot 10^{-255}\right) \land \left(x.im \leq 1.35 \cdot 10^{-255} \lor \neg \left(x.im \leq 1.05 \cdot 10^{-248}\right) \land \left(x.im \leq 5.4 \cdot 10^{-248} \lor \neg \left(x.im \leq 2.4 \cdot 10^{-196}\right) \land \left(x.im \leq 2.5 \cdot 10^{-196} \lor \neg \left(x.im \leq 5 \cdot 10^{-187}\right) \land \left(x.im \leq 5.2 \cdot 10^{-187} \lor \neg \left(x.im \leq 2.3 \cdot 10^{-178}\right) \land \left(x.im \leq 2.35 \cdot 10^{-178} \lor \neg \left(x.im \leq 9.5 \cdot 10^{-150}\right) \land \left(x.im \leq 1.2 \cdot 10^{-120} \lor \neg \left(x.im \leq 1.55 \cdot 10^{-105}\right) \land \left(x.im \leq 2.35 \cdot 10^{-102} \lor \neg \left(x.im \leq 7.5 \cdot 10^{-95}\right) \land \left(x.im \leq 1.85 \cdot 10^{-90} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-83}\right) \land \left(x.im \leq 1.45 \cdot 10^{-65} \lor \neg \left(x.im \leq 1.05 \cdot 10^{-58} \lor \neg \left(x.im \leq 9.6 \cdot 10^{-57}\right) \land \left(x.im \leq 1.15 \cdot 10^{-49} \lor \neg \left(x.im \leq 7.6 \cdot 10^{-25}\right) \land \left(x.im \leq 18 \lor \neg \left(x.im \leq 1300\right) \land \left(x.im \leq 125000000 \lor \neg \left(x.im \leq 1.9 \cdot 10^{+75}\right) \land x.im \leq 5.8 \cdot 10^{+76}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\
\;\;\;\;x.im \cdot \left(-y.im\right)\\

\mathbf{else}:\\
\;\;\;\;x.re \cdot y.re\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x.im < -3.3500000000000002e-34 or -5.6e-104 < x.im < -8.99999999999999911e-106 or -8.4999999999999995e-113 < x.im < -1.4000000000000001e-114 or -9.60000000000000059e-139 < x.im < -7.00000000000000002e-139 or -2.2999999999999999e-147 < x.im < -1.21999999999999995e-147 or -4.2000000000000001e-161 < x.im < -4.8000000000000002e-172 or -4.7999999999999998e-192 < x.im < -4.6999999999999997e-192 or -1.5000000000000001e-259 < x.im < -8.60000000000000043e-260 or -7.79999999999999995e-271 < x.im < -7.60000000000000019e-271 or 1.3000000000000001e-255 < x.im < 1.35000000000000008e-255 or 1.05e-248 < x.im < 5.4000000000000002e-248 or 2.40000000000000021e-196 < x.im < 2.5000000000000002e-196 or 4.9999999999999996e-187 < x.im < 5.1999999999999999e-187 or 2.29999999999999994e-178 < x.im < 2.35e-178 or 9.50000000000000013e-150 < x.im < 1.2e-120 or 1.55000000000000007e-105 < x.im < 2.3500000000000001e-102 or 7.5000000000000003e-95 < x.im < 1.85000000000000009e-90 or 1.4e-83 < x.im < 1.4499999999999999e-65 or 1.04999999999999994e-58 < x.im < 9.60000000000000025e-57 or 1.15e-49 < x.im < 7.5999999999999996e-25 or 18 < x.im < 1300 or 1.25e8 < x.im < 1.9000000000000001e75 or 5.8000000000000003e76 < x.im

    1. Initial program 99.4%

      \[x.re \cdot y.re - x.im \cdot y.im \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around 0 69.3%

      \[\leadsto \color{blue}{-1 \cdot \left(x.im \cdot y.im\right)} \]
    4. Step-by-step derivation
      1. mul-1-neg69.3%

        \[\leadsto \color{blue}{-x.im \cdot y.im} \]
      2. distribute-rgt-neg-out69.3%

        \[\leadsto \color{blue}{x.im \cdot \left(-y.im\right)} \]
    5. Simplified69.3%

      \[\leadsto \color{blue}{x.im \cdot \left(-y.im\right)} \]

    if -3.3500000000000002e-34 < x.im < -5.6e-104 or -8.99999999999999911e-106 < x.im < -8.4999999999999995e-113 or -1.4000000000000001e-114 < x.im < -9.60000000000000059e-139 or -7.00000000000000002e-139 < x.im < -2.2999999999999999e-147 or -1.21999999999999995e-147 < x.im < -4.2000000000000001e-161 or -4.8000000000000002e-172 < x.im < -4.7999999999999998e-192 or -4.6999999999999997e-192 < x.im < -1.5000000000000001e-259 or -8.60000000000000043e-260 < x.im < -7.79999999999999995e-271 or -7.60000000000000019e-271 < x.im < 1.3000000000000001e-255 or 1.35000000000000008e-255 < x.im < 1.05e-248 or 5.4000000000000002e-248 < x.im < 2.40000000000000021e-196 or 2.5000000000000002e-196 < x.im < 4.9999999999999996e-187 or 5.1999999999999999e-187 < x.im < 2.29999999999999994e-178 or 2.35e-178 < x.im < 9.50000000000000013e-150 or 1.2e-120 < x.im < 1.55000000000000007e-105 or 2.3500000000000001e-102 < x.im < 7.5000000000000003e-95 or 1.85000000000000009e-90 < x.im < 1.4e-83 or 1.4499999999999999e-65 < x.im < 1.04999999999999994e-58 or 9.60000000000000025e-57 < x.im < 1.15e-49 or 7.5999999999999996e-25 < x.im < 18 or 1300 < x.im < 1.25e8 or 1.9000000000000001e75 < x.im < 5.8000000000000003e76

    1. Initial program 100.0%

      \[x.re \cdot y.re - x.im \cdot y.im \]
    2. Add Preprocessing
    3. Taylor expanded in x.re around inf 90.0%

      \[\leadsto \color{blue}{x.re \cdot y.re} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x.im \leq -3.35 \cdot 10^{-34} \lor \neg \left(x.im \leq -5.6 \cdot 10^{-104}\right) \land \left(x.im \leq -9 \cdot 10^{-106} \lor \neg \left(x.im \leq -8.5 \cdot 10^{-113}\right) \land \left(x.im \leq -1.4 \cdot 10^{-114} \lor \neg \left(x.im \leq -9.6 \cdot 10^{-139}\right) \land \left(x.im \leq -7 \cdot 10^{-139} \lor \neg \left(x.im \leq -2.3 \cdot 10^{-147}\right) \land \left(x.im \leq -1.22 \cdot 10^{-147} \lor \neg \left(x.im \leq -4.2 \cdot 10^{-161}\right) \land \left(x.im \leq -4.8 \cdot 10^{-172} \lor \neg \left(x.im \leq -4.8 \cdot 10^{-192}\right) \land \left(x.im \leq -4.7 \cdot 10^{-192} \lor \neg \left(x.im \leq -1.5 \cdot 10^{-259}\right) \land \left(x.im \leq -8.6 \cdot 10^{-260} \lor \neg \left(x.im \leq -7.8 \cdot 10^{-271}\right) \land \left(x.im \leq -7.6 \cdot 10^{-271} \lor \neg \left(x.im \leq 1.3 \cdot 10^{-255}\right) \land \left(x.im \leq 1.35 \cdot 10^{-255} \lor \neg \left(x.im \leq 1.05 \cdot 10^{-248}\right) \land \left(x.im \leq 5.4 \cdot 10^{-248} \lor \neg \left(x.im \leq 2.4 \cdot 10^{-196}\right) \land \left(x.im \leq 2.5 \cdot 10^{-196} \lor \neg \left(x.im \leq 5 \cdot 10^{-187}\right) \land \left(x.im \leq 5.2 \cdot 10^{-187} \lor \neg \left(x.im \leq 2.3 \cdot 10^{-178}\right) \land \left(x.im \leq 2.35 \cdot 10^{-178} \lor \neg \left(x.im \leq 9.5 \cdot 10^{-150}\right) \land \left(x.im \leq 1.2 \cdot 10^{-120} \lor \neg \left(x.im \leq 1.55 \cdot 10^{-105}\right) \land \left(x.im \leq 2.35 \cdot 10^{-102} \lor \neg \left(x.im \leq 7.5 \cdot 10^{-95}\right) \land \left(x.im \leq 1.85 \cdot 10^{-90} \lor \neg \left(x.im \leq 1.4 \cdot 10^{-83}\right) \land \left(x.im \leq 1.45 \cdot 10^{-65} \lor \neg \left(x.im \leq 1.05 \cdot 10^{-58} \lor \neg \left(x.im \leq 9.6 \cdot 10^{-57}\right) \land \left(x.im \leq 1.15 \cdot 10^{-49} \lor \neg \left(x.im \leq 7.6 \cdot 10^{-25}\right) \land \left(x.im \leq 18 \lor \neg \left(x.im \leq 1300\right) \land \left(x.im \leq 125000000 \lor \neg \left(x.im \leq 1.9 \cdot 10^{+75}\right) \land x.im \leq 5.8 \cdot 10^{+76}\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right)\right):\\ \;\;\;\;x.im \cdot \left(-y.im\right)\\ \mathbf{else}:\\ \;\;\;\;x.re \cdot y.re\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 51.7% accurate, 2.3× speedup?

\[\begin{array}{l} \\ x.re \cdot y.re \end{array} \]
(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}
Derivation
  1. Initial program 99.6%

    \[x.re \cdot y.re - x.im \cdot y.im \]
  2. Add Preprocessing
  3. Taylor expanded in x.re around inf 54.1%

    \[\leadsto \color{blue}{x.re \cdot y.re} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024096 
(FPCore (x.re x.im y.re y.im)
  :name "_multiplyComplex, real part"
  :precision binary64
  (- (* x.re y.re) (* x.im y.im)))