Numeric.Log:$cexpm1 from log-domain-0.10.2.1, B

Percentage Accurate: 100.0% → 100.0%
Time: 1.4s
Alternatives: 6
Speedup: 1.1×

Specification

?
\[\left(x \cdot y + x\right) + y \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (+ (+ (* x y) x) y))
double code(double x, double y) {
	return ((x * y) + x) + y;
}
real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * y) + x) + y
end function
public static double code(double x, double y) {
	return ((x * y) + x) + y;
}
def code(x, y):
	return ((x * y) + x) + y
function code(x, y)
	return Float64(Float64(Float64(x * y) + x) + y)
end
function tmp = code(x, y)
	tmp = ((x * y) + x) + y;
end
code[x_, y_] := N[(N[(N[(x * y), $MachinePrecision] + x), $MachinePrecision] + y), $MachinePrecision]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	((x * y) + x) + y
END code
\left(x \cdot y + x\right) + y

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 6 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: 100.0% accurate, 1.0× speedup?

\[\left(x \cdot y + x\right) + y \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (+ (+ (* x y) x) y))
double code(double x, double y) {
	return ((x * y) + x) + y;
}
real(8) function code(x, y)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * y) + x) + y
end function
public static double code(double x, double y) {
	return ((x * y) + x) + y;
}
def code(x, y):
	return ((x * y) + x) + y
function code(x, y)
	return Float64(Float64(Float64(x * y) + x) + y)
end
function tmp = code(x, y)
	tmp = ((x * y) + x) + y;
end
code[x_, y_] := N[(N[(N[(x * y), $MachinePrecision] + x), $MachinePrecision] + y), $MachinePrecision]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	((x * y) + x) + y
END code
\left(x \cdot y + x\right) + y

Alternative 1: 100.0% accurate, 1.1× speedup?

\[\mathsf{fma}\left(x, y, x\right) + y \]
(FPCore (x y)
  :precision binary64
  :pre TRUE
  (+ (fma x y x) y))
double code(double x, double y) {
	return fma(x, y, x) + y;
}
function code(x, y)
	return Float64(fma(x, y, x) + y)
end
code[x_, y_] := N[(N[(x * y + x), $MachinePrecision] + y), $MachinePrecision]
f(x, y):
	x in [-inf, +inf],
	y in [-inf, +inf]
code: THEORY
BEGIN
f(x, y: real): real =
	((x * y) + x) + y
END code
\mathsf{fma}\left(x, y, x\right) + y
Derivation
  1. Initial program 100.0%

    \[\left(x \cdot y + x\right) + y \]
  2. Step-by-step derivation
    1. Applied rewrites100.0%

      \[\leadsto \mathsf{fma}\left(x, y, x\right) + y \]
    2. Add Preprocessing

    Alternative 2: 98.1% accurate, 0.2× speedup?

    \[\begin{array}{l} \mathbf{if}\;\left(\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) + \mathsf{min}\left(x, y\right)\right) + \mathsf{max}\left(x, y\right) \leq -5 \cdot 10^{-243}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{min}\left(x, y\right), \mathsf{max}\left(x, y\right), \mathsf{min}\left(x, y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{max}\left(x, y\right), \mathsf{min}\left(x, y\right), \mathsf{max}\left(x, y\right)\right)\\ \end{array} \]
    (FPCore (x y)
      :precision binary64
      :pre TRUE
      (if (<=
         (+ (+ (* (fmin x y) (fmax x y)) (fmin x y)) (fmax x y))
         -5e-243)
      (fma (fmin x y) (fmax x y) (fmin x y))
      (fma (fmax x y) (fmin x y) (fmax x y))))
    double code(double x, double y) {
    	double tmp;
    	if ((((fmin(x, y) * fmax(x, y)) + fmin(x, y)) + fmax(x, y)) <= -5e-243) {
    		tmp = fma(fmin(x, y), fmax(x, y), fmin(x, y));
    	} else {
    		tmp = fma(fmax(x, y), fmin(x, y), fmax(x, y));
    	}
    	return tmp;
    }
    
    function code(x, y)
    	tmp = 0.0
    	if (Float64(Float64(Float64(fmin(x, y) * fmax(x, y)) + fmin(x, y)) + fmax(x, y)) <= -5e-243)
    		tmp = fma(fmin(x, y), fmax(x, y), fmin(x, y));
    	else
    		tmp = fma(fmax(x, y), fmin(x, y), fmax(x, y));
    	end
    	return tmp
    end
    
    code[x_, y_] := If[LessEqual[N[(N[(N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision] + N[Min[x, y], $MachinePrecision]), $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision], -5e-243], N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision] + N[Min[x, y], $MachinePrecision]), $MachinePrecision], N[(N[Max[x, y], $MachinePrecision] * N[Min[x, y], $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision]]
    
    f(x, y):
    	x in [-inf, +inf],
    	y in [-inf, +inf]
    code: THEORY
    BEGIN
    f(x, y: real): real =
    	LET tmp_4 = IF (x < y) THEN x ELSE y ENDIF IN
    	LET tmp_5 = IF (x > y) THEN x ELSE y ENDIF IN
    	LET tmp_6 = IF (x < y) THEN x ELSE y ENDIF IN
    	LET tmp_7 = IF (x > y) THEN x ELSE y ENDIF IN
    	LET tmp_8 = IF (x < y) THEN x ELSE y ENDIF IN
    	LET tmp_9 = IF (x > y) THEN x ELSE y ENDIF IN
    	LET tmp_10 = IF (x < y) THEN x ELSE y ENDIF IN
    	LET tmp_11 = IF (x > y) THEN x ELSE y ENDIF IN
    	LET tmp_12 = IF (x < y) THEN x ELSE y ENDIF IN
    	LET tmp_13 = IF (x > y) THEN x ELSE y ENDIF IN
    	LET tmp_3 = IF ((((tmp_4 * tmp_5) + tmp_6) + tmp_7) <= (-499999999999999984683939913850061721489496590952589773390827798773737713095969188633192627621462316498790691672632378270778722894714282591665081646676534330402059887310135947479208884369292311377477501378209357934919133739094273166755544593266130898595976796117582471603708263244462299937705026182313773996576649739412955028089862877309315791663836061563811213000894375067941494972219497381288478141027142373996815747302928733577169901360013239235730522260790452621052053289221103216668717982290806856659157137617117372787702476621585898098080977451099317342653072129658731181933717380161397159099578857421875e-851)) THEN ((tmp_8 * tmp_9) + tmp_10) ELSE ((tmp_11 * tmp_12) + tmp_13) ENDIF IN
    	tmp_3
    END code
    \begin{array}{l}
    \mathbf{if}\;\left(\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) + \mathsf{min}\left(x, y\right)\right) + \mathsf{max}\left(x, y\right) \leq -5 \cdot 10^{-243}:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{min}\left(x, y\right), \mathsf{max}\left(x, y\right), \mathsf{min}\left(x, y\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(\mathsf{max}\left(x, y\right), \mathsf{min}\left(x, y\right), \mathsf{max}\left(x, y\right)\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (+.f64 (+.f64 (*.f64 x y) x) y) < -4.9999999999999998e-243

      1. Initial program 100.0%

        \[\left(x \cdot y + x\right) + y \]
      2. Taylor expanded in y around inf

        \[\leadsto y \cdot \left(1 + x\right) \]
      3. Step-by-step derivation
        1. Applied rewrites62.5%

          \[\leadsto y \cdot \left(1 + x\right) \]
        2. Taylor expanded in x around inf

          \[\leadsto x \cdot y \]
        3. Step-by-step derivation
          1. Applied rewrites27.0%

            \[\leadsto x \cdot y \]
          2. Taylor expanded in x around inf

            \[\leadsto x \cdot \left(1 + y\right) \]
          3. Step-by-step derivation
            1. Applied rewrites63.5%

              \[\leadsto x \cdot \left(1 + y\right) \]
            2. Step-by-step derivation
              1. Applied rewrites63.6%

                \[\leadsto \mathsf{fma}\left(x, y, x\right) \]

              if -4.9999999999999998e-243 < (+.f64 (+.f64 (*.f64 x y) x) y)

              1. Initial program 100.0%

                \[\left(x \cdot y + x\right) + y \]
              2. Taylor expanded in y around inf

                \[\leadsto y \cdot \left(1 + x\right) \]
              3. Step-by-step derivation
                1. Applied rewrites62.5%

                  \[\leadsto y \cdot \left(1 + x\right) \]
                2. Step-by-step derivation
                  1. Applied rewrites62.5%

                    \[\leadsto \mathsf{fma}\left(y, x, y\right) \]
                3. Recombined 2 regimes into one program.
                4. Add Preprocessing

                Alternative 3: 90.0% accurate, 0.1× speedup?

                \[\begin{array}{l} t_0 := \left(\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) + \mathsf{min}\left(x, y\right)\right) + \mathsf{max}\left(x, y\right)\\ t_1 := \mathsf{fma}\left(\mathsf{min}\left(x, y\right), \mathsf{max}\left(x, y\right), \mathsf{min}\left(x, y\right)\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-243}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+275}:\\ \;\;\;\;\mathsf{max}\left(x, y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
                (FPCore (x y)
                  :precision binary64
                  :pre TRUE
                  (let* ((t_0 (+ (+ (* (fmin x y) (fmax x y)) (fmin x y)) (fmax x y)))
                       (t_1 (fma (fmin x y) (fmax x y) (fmin x y))))
                  (if (<= t_0 -5e-243) t_1 (if (<= t_0 2e+275) (fmax x y) t_1))))
                double code(double x, double y) {
                	double t_0 = ((fmin(x, y) * fmax(x, y)) + fmin(x, y)) + fmax(x, y);
                	double t_1 = fma(fmin(x, y), fmax(x, y), fmin(x, y));
                	double tmp;
                	if (t_0 <= -5e-243) {
                		tmp = t_1;
                	} else if (t_0 <= 2e+275) {
                		tmp = fmax(x, y);
                	} else {
                		tmp = t_1;
                	}
                	return tmp;
                }
                
                function code(x, y)
                	t_0 = Float64(Float64(Float64(fmin(x, y) * fmax(x, y)) + fmin(x, y)) + fmax(x, y))
                	t_1 = fma(fmin(x, y), fmax(x, y), fmin(x, y))
                	tmp = 0.0
                	if (t_0 <= -5e-243)
                		tmp = t_1;
                	elseif (t_0 <= 2e+275)
                		tmp = fmax(x, y);
                	else
                		tmp = t_1;
                	end
                	return tmp
                end
                
                code[x_, y_] := Block[{t$95$0 = N[(N[(N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision] + N[Min[x, y], $MachinePrecision]), $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision] + N[Min[x, y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-243], t$95$1, If[LessEqual[t$95$0, 2e+275], N[Max[x, y], $MachinePrecision], t$95$1]]]]
                
                f(x, y):
                	x in [-inf, +inf],
                	y in [-inf, +inf]
                code: THEORY
                BEGIN
                f(x, y: real): real =
                	LET tmp = IF (x < y) THEN x ELSE y ENDIF IN
                	LET tmp_1 = IF (x > y) THEN x ELSE y ENDIF IN
                	LET tmp_2 = IF (x < y) THEN x ELSE y ENDIF IN
                	LET tmp_3 = IF (x > y) THEN x ELSE y ENDIF IN
                	LET t_0 = (((tmp * tmp_1) + tmp_2) + tmp_3) IN
                		LET tmp_4 = IF (x < y) THEN x ELSE y ENDIF IN
                		LET tmp_5 = IF (x > y) THEN x ELSE y ENDIF IN
                		LET tmp_6 = IF (x < y) THEN x ELSE y ENDIF IN
                		LET t_1 = ((tmp_4 * tmp_5) + tmp_6) IN
                			LET tmp_10 = IF (x > y) THEN x ELSE y ENDIF IN
                			LET tmp_9 = IF (t_0 <= (199999999999999991963354801579539865224719863466643166570237755888153096932896189915818952609920031781613357714761512012614125205154634640267751072327400569037934396194907236465391951327140093092900757315484959343965444154349978513521462377866702261531547814080948494523170816)) THEN tmp_10 ELSE t_1 ENDIF IN
                			LET tmp_7 = IF (t_0 <= (-499999999999999984683939913850061721489496590952589773390827798773737713095969188633192627621462316498790691672632378270778722894714282591665081646676534330402059887310135947479208884369292311377477501378209357934919133739094273166755544593266130898595976796117582471603708263244462299937705026182313773996576649739412955028089862877309315791663836061563811213000894375067941494972219497381288478141027142373996815747302928733577169901360013239235730522260790452621052053289221103216668717982290806856659157137617117372787702476621585898098080977451099317342653072129658731181933717380161397159099578857421875e-851)) THEN t_1 ELSE tmp_9 ENDIF IN
                	tmp_7
                END code
                \begin{array}{l}
                t_0 := \left(\mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right) + \mathsf{min}\left(x, y\right)\right) + \mathsf{max}\left(x, y\right)\\
                t_1 := \mathsf{fma}\left(\mathsf{min}\left(x, y\right), \mathsf{max}\left(x, y\right), \mathsf{min}\left(x, y\right)\right)\\
                \mathbf{if}\;t\_0 \leq -5 \cdot 10^{-243}:\\
                \;\;\;\;t\_1\\
                
                \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+275}:\\
                \;\;\;\;\mathsf{max}\left(x, y\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_1\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if (+.f64 (+.f64 (*.f64 x y) x) y) < -4.9999999999999998e-243 or 1.9999999999999999e275 < (+.f64 (+.f64 (*.f64 x y) x) y)

                  1. Initial program 100.0%

                    \[\left(x \cdot y + x\right) + y \]
                  2. Taylor expanded in y around inf

                    \[\leadsto y \cdot \left(1 + x\right) \]
                  3. Step-by-step derivation
                    1. Applied rewrites62.5%

                      \[\leadsto y \cdot \left(1 + x\right) \]
                    2. Taylor expanded in x around inf

                      \[\leadsto x \cdot y \]
                    3. Step-by-step derivation
                      1. Applied rewrites27.0%

                        \[\leadsto x \cdot y \]
                      2. Taylor expanded in x around inf

                        \[\leadsto x \cdot \left(1 + y\right) \]
                      3. Step-by-step derivation
                        1. Applied rewrites63.5%

                          \[\leadsto x \cdot \left(1 + y\right) \]
                        2. Step-by-step derivation
                          1. Applied rewrites63.6%

                            \[\leadsto \mathsf{fma}\left(x, y, x\right) \]

                          if -4.9999999999999998e-243 < (+.f64 (+.f64 (*.f64 x y) x) y) < 1.9999999999999999e275

                          1. Initial program 100.0%

                            \[\left(x \cdot y + x\right) + y \]
                          2. Taylor expanded in x around 0

                            \[\leadsto y \]
                          3. Step-by-step derivation
                            1. Applied rewrites38.0%

                              \[\leadsto y \]
                          4. Recombined 2 regimes into one program.
                          5. Add Preprocessing

                          Alternative 4: 84.2% accurate, 0.1× speedup?

                          \[\begin{array}{l} t_0 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\ t_1 := \left(t\_0 + \mathsf{min}\left(x, y\right)\right) + \mathsf{max}\left(x, y\right)\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-243}:\\ \;\;\;\;\mathsf{min}\left(x, y\right) \cdot 1\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+275}:\\ \;\;\;\;\mathsf{max}\left(x, y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                          (FPCore (x y)
                            :precision binary64
                            :pre TRUE
                            (let* ((t_0 (* (fmin x y) (fmax x y)))
                                 (t_1 (+ (+ t_0 (fmin x y)) (fmax x y))))
                            (if (<= t_1 (- INFINITY))
                              t_0
                              (if (<= t_1 -5e-243)
                                (* (fmin x y) 1.0)
                                (if (<= t_1 2e+275) (fmax x y) t_0)))))
                          double code(double x, double y) {
                          	double t_0 = fmin(x, y) * fmax(x, y);
                          	double t_1 = (t_0 + fmin(x, y)) + fmax(x, y);
                          	double tmp;
                          	if (t_1 <= -((double) INFINITY)) {
                          		tmp = t_0;
                          	} else if (t_1 <= -5e-243) {
                          		tmp = fmin(x, y) * 1.0;
                          	} else if (t_1 <= 2e+275) {
                          		tmp = fmax(x, y);
                          	} else {
                          		tmp = t_0;
                          	}
                          	return tmp;
                          }
                          
                          public static double code(double x, double y) {
                          	double t_0 = fmin(x, y) * fmax(x, y);
                          	double t_1 = (t_0 + fmin(x, y)) + fmax(x, y);
                          	double tmp;
                          	if (t_1 <= -Double.POSITIVE_INFINITY) {
                          		tmp = t_0;
                          	} else if (t_1 <= -5e-243) {
                          		tmp = fmin(x, y) * 1.0;
                          	} else if (t_1 <= 2e+275) {
                          		tmp = fmax(x, y);
                          	} else {
                          		tmp = t_0;
                          	}
                          	return tmp;
                          }
                          
                          def code(x, y):
                          	t_0 = fmin(x, y) * fmax(x, y)
                          	t_1 = (t_0 + fmin(x, y)) + fmax(x, y)
                          	tmp = 0
                          	if t_1 <= -math.inf:
                          		tmp = t_0
                          	elif t_1 <= -5e-243:
                          		tmp = fmin(x, y) * 1.0
                          	elif t_1 <= 2e+275:
                          		tmp = fmax(x, y)
                          	else:
                          		tmp = t_0
                          	return tmp
                          
                          function code(x, y)
                          	t_0 = Float64(fmin(x, y) * fmax(x, y))
                          	t_1 = Float64(Float64(t_0 + fmin(x, y)) + fmax(x, y))
                          	tmp = 0.0
                          	if (t_1 <= Float64(-Inf))
                          		tmp = t_0;
                          	elseif (t_1 <= -5e-243)
                          		tmp = Float64(fmin(x, y) * 1.0);
                          	elseif (t_1 <= 2e+275)
                          		tmp = fmax(x, y);
                          	else
                          		tmp = t_0;
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(x, y)
                          	t_0 = min(x, y) * max(x, y);
                          	t_1 = (t_0 + min(x, y)) + max(x, y);
                          	tmp = 0.0;
                          	if (t_1 <= -Inf)
                          		tmp = t_0;
                          	elseif (t_1 <= -5e-243)
                          		tmp = min(x, y) * 1.0;
                          	elseif (t_1 <= 2e+275)
                          		tmp = max(x, y);
                          	else
                          		tmp = t_0;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          code[x_, y_] := Block[{t$95$0 = N[(N[Min[x, y], $MachinePrecision] * N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 + N[Min[x, y], $MachinePrecision]), $MachinePrecision] + N[Max[x, y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$0, If[LessEqual[t$95$1, -5e-243], N[(N[Min[x, y], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$1, 2e+275], N[Max[x, y], $MachinePrecision], t$95$0]]]]]
                          
                          \begin{array}{l}
                          t_0 := \mathsf{min}\left(x, y\right) \cdot \mathsf{max}\left(x, y\right)\\
                          t_1 := \left(t\_0 + \mathsf{min}\left(x, y\right)\right) + \mathsf{max}\left(x, y\right)\\
                          \mathbf{if}\;t\_1 \leq -\infty:\\
                          \;\;\;\;t\_0\\
                          
                          \mathbf{elif}\;t\_1 \leq -5 \cdot 10^{-243}:\\
                          \;\;\;\;\mathsf{min}\left(x, y\right) \cdot 1\\
                          
                          \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+275}:\\
                          \;\;\;\;\mathsf{max}\left(x, y\right)\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;t\_0\\
                          
                          
                          \end{array}
                          
                          Derivation
                          1. Split input into 3 regimes
                          2. if (+.f64 (+.f64 (*.f64 x y) x) y) < -inf.0 or 1.9999999999999999e275 < (+.f64 (+.f64 (*.f64 x y) x) y)

                            1. Initial program 100.0%

                              \[\left(x \cdot y + x\right) + y \]
                            2. Taylor expanded in y around inf

                              \[\leadsto y \cdot \left(1 + x\right) \]
                            3. Step-by-step derivation
                              1. Applied rewrites62.5%

                                \[\leadsto y \cdot \left(1 + x\right) \]
                              2. Taylor expanded in x around inf

                                \[\leadsto x \cdot y \]
                              3. Step-by-step derivation
                                1. Applied rewrites27.0%

                                  \[\leadsto x \cdot y \]

                                if -inf.0 < (+.f64 (+.f64 (*.f64 x y) x) y) < -4.9999999999999998e-243

                                1. Initial program 100.0%

                                  \[\left(x \cdot y + x\right) + y \]
                                2. Taylor expanded in y around inf

                                  \[\leadsto y \cdot \left(1 + x\right) \]
                                3. Step-by-step derivation
                                  1. Applied rewrites62.5%

                                    \[\leadsto y \cdot \left(1 + x\right) \]
                                  2. Taylor expanded in x around inf

                                    \[\leadsto x \cdot y \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites27.0%

                                      \[\leadsto x \cdot y \]
                                    2. Taylor expanded in x around inf

                                      \[\leadsto x \cdot \left(1 + y\right) \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites63.5%

                                        \[\leadsto x \cdot \left(1 + y\right) \]
                                      2. Taylor expanded in y around 0

                                        \[\leadsto x \cdot 1 \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites39.0%

                                          \[\leadsto x \cdot 1 \]

                                        if -4.9999999999999998e-243 < (+.f64 (+.f64 (*.f64 x y) x) y) < 1.9999999999999999e275

                                        1. Initial program 100.0%

                                          \[\left(x \cdot y + x\right) + y \]
                                        2. Taylor expanded in x around 0

                                          \[\leadsto y \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites38.0%

                                            \[\leadsto y \]
                                        4. Recombined 3 regimes into one program.
                                        5. Add Preprocessing

                                        Alternative 5: 61.4% accurate, 0.8× speedup?

                                        \[\begin{array}{l} \mathbf{if}\;x \leq -0.3265401055606291:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 497724760173.6331:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
                                        (FPCore (x y)
                                          :precision binary64
                                          :pre TRUE
                                          (if (<= x -0.3265401055606291)
                                          (* x y)
                                          (if (<= x 497724760173.6331) y (* x y))))
                                        double code(double x, double y) {
                                        	double tmp;
                                        	if (x <= -0.3265401055606291) {
                                        		tmp = x * y;
                                        	} else if (x <= 497724760173.6331) {
                                        		tmp = y;
                                        	} else {
                                        		tmp = x * y;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        real(8) function code(x, y)
                                        use fmin_fmax_functions
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            real(8) :: tmp
                                            if (x <= (-0.3265401055606291d0)) then
                                                tmp = x * y
                                            else if (x <= 497724760173.6331d0) then
                                                tmp = y
                                            else
                                                tmp = x * y
                                            end if
                                            code = tmp
                                        end function
                                        
                                        public static double code(double x, double y) {
                                        	double tmp;
                                        	if (x <= -0.3265401055606291) {
                                        		tmp = x * y;
                                        	} else if (x <= 497724760173.6331) {
                                        		tmp = y;
                                        	} else {
                                        		tmp = x * y;
                                        	}
                                        	return tmp;
                                        }
                                        
                                        def code(x, y):
                                        	tmp = 0
                                        	if x <= -0.3265401055606291:
                                        		tmp = x * y
                                        	elif x <= 497724760173.6331:
                                        		tmp = y
                                        	else:
                                        		tmp = x * y
                                        	return tmp
                                        
                                        function code(x, y)
                                        	tmp = 0.0
                                        	if (x <= -0.3265401055606291)
                                        		tmp = Float64(x * y);
                                        	elseif (x <= 497724760173.6331)
                                        		tmp = y;
                                        	else
                                        		tmp = Float64(x * y);
                                        	end
                                        	return tmp
                                        end
                                        
                                        function tmp_2 = code(x, y)
                                        	tmp = 0.0;
                                        	if (x <= -0.3265401055606291)
                                        		tmp = x * y;
                                        	elseif (x <= 497724760173.6331)
                                        		tmp = y;
                                        	else
                                        		tmp = x * y;
                                        	end
                                        	tmp_2 = tmp;
                                        end
                                        
                                        code[x_, y_] := If[LessEqual[x, -0.3265401055606291], N[(x * y), $MachinePrecision], If[LessEqual[x, 497724760173.6331], y, N[(x * y), $MachinePrecision]]]
                                        
                                        f(x, y):
                                        	x in [-inf, +inf],
                                        	y in [-inf, +inf]
                                        code: THEORY
                                        BEGIN
                                        f(x, y: real): real =
                                        	LET tmp_1 = IF (x <= (49772476017363311767578125e-14)) THEN y ELSE (x * y) ENDIF IN
                                        	LET tmp = IF (x <= (-326540105560629123626625869292183779180049896240234375e-54)) THEN (x * y) ELSE tmp_1 ENDIF IN
                                        	tmp
                                        END code
                                        \begin{array}{l}
                                        \mathbf{if}\;x \leq -0.3265401055606291:\\
                                        \;\;\;\;x \cdot y\\
                                        
                                        \mathbf{elif}\;x \leq 497724760173.6331:\\
                                        \;\;\;\;y\\
                                        
                                        \mathbf{else}:\\
                                        \;\;\;\;x \cdot y\\
                                        
                                        
                                        \end{array}
                                        
                                        Derivation
                                        1. Split input into 2 regimes
                                        2. if x < -0.32654010556062912 or 497724760173.63312 < x

                                          1. Initial program 100.0%

                                            \[\left(x \cdot y + x\right) + y \]
                                          2. Taylor expanded in y around inf

                                            \[\leadsto y \cdot \left(1 + x\right) \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites62.5%

                                              \[\leadsto y \cdot \left(1 + x\right) \]
                                            2. Taylor expanded in x around inf

                                              \[\leadsto x \cdot y \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites27.0%

                                                \[\leadsto x \cdot y \]

                                              if -0.32654010556062912 < x < 497724760173.63312

                                              1. Initial program 100.0%

                                                \[\left(x \cdot y + x\right) + y \]
                                              2. Taylor expanded in x around 0

                                                \[\leadsto y \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites38.0%

                                                  \[\leadsto y \]
                                              4. Recombined 2 regimes into one program.
                                              5. Add Preprocessing

                                              Alternative 6: 38.0% accurate, 9.2× speedup?

                                              \[y \]
                                              (FPCore (x y)
                                                :precision binary64
                                                :pre TRUE
                                                y)
                                              double code(double x, double y) {
                                              	return y;
                                              }
                                              
                                              real(8) function code(x, y)
                                              use fmin_fmax_functions
                                                  real(8), intent (in) :: x
                                                  real(8), intent (in) :: y
                                                  code = y
                                              end function
                                              
                                              public static double code(double x, double y) {
                                              	return y;
                                              }
                                              
                                              def code(x, y):
                                              	return y
                                              
                                              function code(x, y)
                                              	return y
                                              end
                                              
                                              function tmp = code(x, y)
                                              	tmp = y;
                                              end
                                              
                                              code[x_, y_] := y
                                              
                                              f(x, y):
                                              	x in [-inf, +inf],
                                              	y in [-inf, +inf]
                                              code: THEORY
                                              BEGIN
                                              f(x, y: real): real =
                                              	y
                                              END code
                                              y
                                              
                                              Derivation
                                              1. Initial program 100.0%

                                                \[\left(x \cdot y + x\right) + y \]
                                              2. Taylor expanded in x around 0

                                                \[\leadsto y \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites38.0%

                                                  \[\leadsto y \]
                                                2. Add Preprocessing

                                                Reproduce

                                                ?
                                                herbie shell --seed 2026092 
                                                (FPCore (x y)
                                                  :name "Numeric.Log:$cexpm1 from log-domain-0.10.2.1, B"
                                                  :precision binary64
                                                  (+ (+ (* x y) x) y))