Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G

Percentage Accurate: 100.0% → 100.0%
Time: 7.4s
Alternatives: 9
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left(x + y\right) \cdot \left(z + 1\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
double code(double x, double y, double z) {
	return (x + y) * (z + 1.0);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x + y) * (z + 1.0d0)
end function
public static double code(double x, double y, double z) {
	return (x + y) * (z + 1.0);
}
def code(x, y, z):
	return (x + y) * (z + 1.0)
function code(x, y, z)
	return Float64(Float64(x + y) * Float64(z + 1.0))
end
function tmp = code(x, y, z)
	tmp = (x + y) * (z + 1.0);
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x + y\right) \cdot \left(z + 1\right)
\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 9 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?

\[\begin{array}{l} \\ \left(x + y\right) \cdot \left(z + 1\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* (+ x y) (+ z 1.0)))
double code(double x, double y, double z) {
	return (x + y) * (z + 1.0);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x + y) * (z + 1.0d0)
end function
public static double code(double x, double y, double z) {
	return (x + y) * (z + 1.0);
}
def code(x, y, z):
	return (x + y) * (z + 1.0)
function code(x, y, z)
	return Float64(Float64(x + y) * Float64(z + 1.0))
end
function tmp = code(x, y, z)
	tmp = (x + y) * (z + 1.0);
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x + y\right) \cdot \left(z + 1\right)
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(z + 1\right) \cdot \left(x + y\right) \end{array} \]
(FPCore (x y z) :precision binary64 (* (+ z 1.0) (+ x y)))
double code(double x, double y, double z) {
	return (z + 1.0) * (x + y);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (z + 1.0d0) * (x + y)
end function
public static double code(double x, double y, double z) {
	return (z + 1.0) * (x + y);
}
def code(x, y, z):
	return (z + 1.0) * (x + y)
function code(x, y, z)
	return Float64(Float64(z + 1.0) * Float64(x + y))
end
function tmp = code(x, y, z)
	tmp = (z + 1.0) * (x + y);
end
code[x_, y_, z_] := N[(N[(z + 1.0), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(z + 1\right) \cdot \left(x + y\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(x + y\right) \cdot \left(z + 1\right) \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto \left(z + 1\right) \cdot \left(x + y\right) \]
  4. Add Preprocessing

Alternative 2: 49.3% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+96}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{+64}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-241}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-53}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 0.55:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 880000 \lor \neg \left(z \leq 9.8 \cdot 10^{+70}\right) \land z \leq 1.45 \cdot 10^{+135}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.6e+96)
   (* y z)
   (if (<= z -7.2e+64)
     (* x z)
     (if (<= z -1.0)
       (* y z)
       (if (<= z 2.5e-241)
         x
         (if (<= z 1.1e-53)
           y
           (if (<= z 0.55)
             x
             (if (or (<= z 880000.0)
                     (and (not (<= z 9.8e+70)) (<= z 1.45e+135)))
               (* y z)
               (* x z)))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.6e+96) {
		tmp = y * z;
	} else if (z <= -7.2e+64) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 2.5e-241) {
		tmp = x;
	} else if (z <= 1.1e-53) {
		tmp = y;
	} else if (z <= 0.55) {
		tmp = x;
	} else if ((z <= 880000.0) || (!(z <= 9.8e+70) && (z <= 1.45e+135))) {
		tmp = y * z;
	} else {
		tmp = x * z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-5.6d+96)) then
        tmp = y * z
    else if (z <= (-7.2d+64)) then
        tmp = x * z
    else if (z <= (-1.0d0)) then
        tmp = y * z
    else if (z <= 2.5d-241) then
        tmp = x
    else if (z <= 1.1d-53) then
        tmp = y
    else if (z <= 0.55d0) then
        tmp = x
    else if ((z <= 880000.0d0) .or. (.not. (z <= 9.8d+70)) .and. (z <= 1.45d+135)) then
        tmp = y * z
    else
        tmp = x * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.6e+96) {
		tmp = y * z;
	} else if (z <= -7.2e+64) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 2.5e-241) {
		tmp = x;
	} else if (z <= 1.1e-53) {
		tmp = y;
	} else if (z <= 0.55) {
		tmp = x;
	} else if ((z <= 880000.0) || (!(z <= 9.8e+70) && (z <= 1.45e+135))) {
		tmp = y * z;
	} else {
		tmp = x * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -5.6e+96:
		tmp = y * z
	elif z <= -7.2e+64:
		tmp = x * z
	elif z <= -1.0:
		tmp = y * z
	elif z <= 2.5e-241:
		tmp = x
	elif z <= 1.1e-53:
		tmp = y
	elif z <= 0.55:
		tmp = x
	elif (z <= 880000.0) or (not (z <= 9.8e+70) and (z <= 1.45e+135)):
		tmp = y * z
	else:
		tmp = x * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.6e+96)
		tmp = Float64(y * z);
	elseif (z <= -7.2e+64)
		tmp = Float64(x * z);
	elseif (z <= -1.0)
		tmp = Float64(y * z);
	elseif (z <= 2.5e-241)
		tmp = x;
	elseif (z <= 1.1e-53)
		tmp = y;
	elseif (z <= 0.55)
		tmp = x;
	elseif ((z <= 880000.0) || (!(z <= 9.8e+70) && (z <= 1.45e+135)))
		tmp = Float64(y * z);
	else
		tmp = Float64(x * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -5.6e+96)
		tmp = y * z;
	elseif (z <= -7.2e+64)
		tmp = x * z;
	elseif (z <= -1.0)
		tmp = y * z;
	elseif (z <= 2.5e-241)
		tmp = x;
	elseif (z <= 1.1e-53)
		tmp = y;
	elseif (z <= 0.55)
		tmp = x;
	elseif ((z <= 880000.0) || (~((z <= 9.8e+70)) && (z <= 1.45e+135)))
		tmp = y * z;
	else
		tmp = x * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -5.6e+96], N[(y * z), $MachinePrecision], If[LessEqual[z, -7.2e+64], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 2.5e-241], x, If[LessEqual[z, 1.1e-53], y, If[LessEqual[z, 0.55], x, If[Or[LessEqual[z, 880000.0], And[N[Not[LessEqual[z, 9.8e+70]], $MachinePrecision], LessEqual[z, 1.45e+135]]], N[(y * z), $MachinePrecision], N[(x * z), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{+96}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq -7.2 \cdot 10^{+64}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -1:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq 2.5 \cdot 10^{-241}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-53}:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 880000 \lor \neg \left(z \leq 9.8 \cdot 10^{+70}\right) \land z \leq 1.45 \cdot 10^{+135}:\\
\;\;\;\;y \cdot z\\

\mathbf{else}:\\
\;\;\;\;x \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -5.59999999999999999e96 or -7.20000000000000027e64 < z < -1 or 0.55000000000000004 < z < 8.8e5 or 9.80000000000000056e70 < z < 1.4499999999999999e135

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 86.0%

      \[\leadsto \color{blue}{y \cdot \left(1 + \left(z + \frac{x \cdot \left(1 + z\right)}{y}\right)\right)} \]
    4. Taylor expanded in z around inf 85.2%

      \[\leadsto \color{blue}{y \cdot \left(z \cdot \left(1 + \frac{x}{y}\right)\right)} \]
    5. Taylor expanded in y around inf 46.6%

      \[\leadsto \color{blue}{y \cdot z} \]
    6. Step-by-step derivation
      1. *-commutative46.6%

        \[\leadsto \color{blue}{z \cdot y} \]
    7. Simplified46.6%

      \[\leadsto \color{blue}{z \cdot y} \]

    if -5.59999999999999999e96 < z < -7.20000000000000027e64 or 8.8e5 < z < 9.80000000000000056e70 or 1.4499999999999999e135 < z

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 97.7%

      \[\leadsto \color{blue}{z \cdot \left(x + y\right)} \]
    4. Step-by-step derivation
      1. +-commutative97.7%

        \[\leadsto z \cdot \color{blue}{\left(y + x\right)} \]
    5. Simplified97.7%

      \[\leadsto \color{blue}{z \cdot \left(y + x\right)} \]
    6. Taylor expanded in x around inf 83.9%

      \[\leadsto \color{blue}{x \cdot \left(z + \frac{y \cdot z}{x}\right)} \]
    7. Taylor expanded in x around inf 60.4%

      \[\leadsto \color{blue}{x \cdot z} \]
    8. Step-by-step derivation
      1. *-commutative60.4%

        \[\leadsto \color{blue}{z \cdot x} \]
    9. Simplified60.4%

      \[\leadsto \color{blue}{z \cdot x} \]

    if -1 < z < 2.4999999999999999e-241 or 1.10000000000000009e-53 < z < 0.55000000000000004

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(1 + z\right)} \]
      2. distribute-lft-in100.0%

        \[\leadsto \color{blue}{\left(x + y\right) \cdot 1 + \left(x + y\right) \cdot z} \]
      3. *-rgt-identity100.0%

        \[\leadsto \color{blue}{\left(x + y\right)} + \left(x + y\right) \cdot z \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(x + y\right) + \left(x + y\right) \cdot z} \]
    5. Taylor expanded in x around inf 50.1%

      \[\leadsto \color{blue}{x \cdot \left(1 + z\right)} \]
    6. Step-by-step derivation
      1. +-commutative50.1%

        \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
    7. Simplified50.1%

      \[\leadsto \color{blue}{x \cdot \left(z + 1\right)} \]
    8. Taylor expanded in z around 0 46.7%

      \[\leadsto \color{blue}{x} \]

    if 2.4999999999999999e-241 < z < 1.10000000000000009e-53

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 54.4%

      \[\leadsto \color{blue}{y \cdot \left(1 + z\right)} \]
    4. Taylor expanded in z around 0 54.4%

      \[\leadsto \color{blue}{y} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification51.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+96}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{+64}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-241}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-53}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 0.55:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 880000 \lor \neg \left(z \leq 9.8 \cdot 10^{+70}\right) \land z \leq 1.45 \cdot 10^{+135}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z + 1 \leq -5 \cdot 10^{+97}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z + 1 \leq -5 \cdot 10^{+69}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z + 1 \leq -4:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z + 1 \leq 1:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z + 1 \leq 10^{+70} \lor \neg \left(z + 1 \leq 2 \cdot 10^{+131}\right):\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (+ z 1.0) -5e+97)
   (* y z)
   (if (<= (+ z 1.0) -5e+69)
     (* x z)
     (if (<= (+ z 1.0) -4.0)
       (* y z)
       (if (<= (+ z 1.0) 1.0)
         (+ x y)
         (if (or (<= (+ z 1.0) 1e+70) (not (<= (+ z 1.0) 2e+131)))
           (* x (+ z 1.0))
           (* y z)))))))
double code(double x, double y, double z) {
	double tmp;
	if ((z + 1.0) <= -5e+97) {
		tmp = y * z;
	} else if ((z + 1.0) <= -5e+69) {
		tmp = x * z;
	} else if ((z + 1.0) <= -4.0) {
		tmp = y * z;
	} else if ((z + 1.0) <= 1.0) {
		tmp = x + y;
	} else if (((z + 1.0) <= 1e+70) || !((z + 1.0) <= 2e+131)) {
		tmp = x * (z + 1.0);
	} else {
		tmp = y * z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z + 1.0d0) <= (-5d+97)) then
        tmp = y * z
    else if ((z + 1.0d0) <= (-5d+69)) then
        tmp = x * z
    else if ((z + 1.0d0) <= (-4.0d0)) then
        tmp = y * z
    else if ((z + 1.0d0) <= 1.0d0) then
        tmp = x + y
    else if (((z + 1.0d0) <= 1d+70) .or. (.not. ((z + 1.0d0) <= 2d+131))) then
        tmp = x * (z + 1.0d0)
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z + 1.0) <= -5e+97) {
		tmp = y * z;
	} else if ((z + 1.0) <= -5e+69) {
		tmp = x * z;
	} else if ((z + 1.0) <= -4.0) {
		tmp = y * z;
	} else if ((z + 1.0) <= 1.0) {
		tmp = x + y;
	} else if (((z + 1.0) <= 1e+70) || !((z + 1.0) <= 2e+131)) {
		tmp = x * (z + 1.0);
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z + 1.0) <= -5e+97:
		tmp = y * z
	elif (z + 1.0) <= -5e+69:
		tmp = x * z
	elif (z + 1.0) <= -4.0:
		tmp = y * z
	elif (z + 1.0) <= 1.0:
		tmp = x + y
	elif ((z + 1.0) <= 1e+70) or not ((z + 1.0) <= 2e+131):
		tmp = x * (z + 1.0)
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(z + 1.0) <= -5e+97)
		tmp = Float64(y * z);
	elseif (Float64(z + 1.0) <= -5e+69)
		tmp = Float64(x * z);
	elseif (Float64(z + 1.0) <= -4.0)
		tmp = Float64(y * z);
	elseif (Float64(z + 1.0) <= 1.0)
		tmp = Float64(x + y);
	elseif ((Float64(z + 1.0) <= 1e+70) || !(Float64(z + 1.0) <= 2e+131))
		tmp = Float64(x * Float64(z + 1.0));
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z + 1.0) <= -5e+97)
		tmp = y * z;
	elseif ((z + 1.0) <= -5e+69)
		tmp = x * z;
	elseif ((z + 1.0) <= -4.0)
		tmp = y * z;
	elseif ((z + 1.0) <= 1.0)
		tmp = x + y;
	elseif (((z + 1.0) <= 1e+70) || ~(((z + 1.0) <= 2e+131)))
		tmp = x * (z + 1.0);
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(z + 1.0), $MachinePrecision], -5e+97], N[(y * z), $MachinePrecision], If[LessEqual[N[(z + 1.0), $MachinePrecision], -5e+69], N[(x * z), $MachinePrecision], If[LessEqual[N[(z + 1.0), $MachinePrecision], -4.0], N[(y * z), $MachinePrecision], If[LessEqual[N[(z + 1.0), $MachinePrecision], 1.0], N[(x + y), $MachinePrecision], If[Or[LessEqual[N[(z + 1.0), $MachinePrecision], 1e+70], N[Not[LessEqual[N[(z + 1.0), $MachinePrecision], 2e+131]], $MachinePrecision]], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z + 1 \leq -5 \cdot 10^{+97}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z + 1 \leq -5 \cdot 10^{+69}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z + 1 \leq -4:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z + 1 \leq 1:\\
\;\;\;\;x + y\\

\mathbf{elif}\;z + 1 \leq 10^{+70} \lor \neg \left(z + 1 \leq 2 \cdot 10^{+131}\right):\\
\;\;\;\;x \cdot \left(z + 1\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (+.f64 z #s(literal 1 binary64)) < -4.99999999999999999e97 or -5.00000000000000036e69 < (+.f64 z #s(literal 1 binary64)) < -4 or 1.00000000000000007e70 < (+.f64 z #s(literal 1 binary64)) < 1.9999999999999998e131

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 85.8%

      \[\leadsto \color{blue}{y \cdot \left(1 + \left(z + \frac{x \cdot \left(1 + z\right)}{y}\right)\right)} \]
    4. Taylor expanded in z around inf 85.8%

      \[\leadsto \color{blue}{y \cdot \left(z \cdot \left(1 + \frac{x}{y}\right)\right)} \]
    5. Taylor expanded in y around inf 47.3%

      \[\leadsto \color{blue}{y \cdot z} \]
    6. Step-by-step derivation
      1. *-commutative47.3%

        \[\leadsto \color{blue}{z \cdot y} \]
    7. Simplified47.3%

      \[\leadsto \color{blue}{z \cdot y} \]

    if -4.99999999999999999e97 < (+.f64 z #s(literal 1 binary64)) < -5.00000000000000036e69

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 100.0%

      \[\leadsto \color{blue}{z \cdot \left(x + y\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto z \cdot \color{blue}{\left(y + x\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{z \cdot \left(y + x\right)} \]
    6. Taylor expanded in x around inf 84.9%

      \[\leadsto \color{blue}{x \cdot \left(z + \frac{y \cdot z}{x}\right)} \]
    7. Taylor expanded in x around inf 66.8%

      \[\leadsto \color{blue}{x \cdot z} \]
    8. Step-by-step derivation
      1. *-commutative66.8%

        \[\leadsto \color{blue}{z \cdot x} \]
    9. Simplified66.8%

      \[\leadsto \color{blue}{z \cdot x} \]

    if -4 < (+.f64 z #s(literal 1 binary64)) < 1

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 99.0%

      \[\leadsto \color{blue}{x + y} \]
    4. Step-by-step derivation
      1. +-commutative99.0%

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified99.0%

      \[\leadsto \color{blue}{y + x} \]

    if 1 < (+.f64 z #s(literal 1 binary64)) < 1.00000000000000007e70 or 1.9999999999999998e131 < (+.f64 z #s(literal 1 binary64))

    1. Initial program 99.9%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 65.2%

      \[\leadsto \color{blue}{x \cdot \left(1 + z\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification77.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z + 1 \leq -5 \cdot 10^{+97}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z + 1 \leq -5 \cdot 10^{+69}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z + 1 \leq -4:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z + 1 \leq 1:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z + 1 \leq 10^{+70} \lor \neg \left(z + 1 \leq 2 \cdot 10^{+131}\right):\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.9 \cdot 10^{+94}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{+66}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 440000:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+70} \lor \neg \left(z \leq 6.8 \cdot 10^{+133}\right):\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.9e+94)
   (* y z)
   (if (<= z -3.7e+66)
     (* x z)
     (if (<= z -1.0)
       (* y z)
       (if (<= z 440000.0)
         (+ x y)
         (if (or (<= z 1.55e+70) (not (<= z 6.8e+133))) (* x z) (* y z)))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.9e+94) {
		tmp = y * z;
	} else if (z <= -3.7e+66) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 440000.0) {
		tmp = x + y;
	} else if ((z <= 1.55e+70) || !(z <= 6.8e+133)) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-5.9d+94)) then
        tmp = y * z
    else if (z <= (-3.7d+66)) then
        tmp = x * z
    else if (z <= (-1.0d0)) then
        tmp = y * z
    else if (z <= 440000.0d0) then
        tmp = x + y
    else if ((z <= 1.55d+70) .or. (.not. (z <= 6.8d+133))) then
        tmp = x * z
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.9e+94) {
		tmp = y * z;
	} else if (z <= -3.7e+66) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 440000.0) {
		tmp = x + y;
	} else if ((z <= 1.55e+70) || !(z <= 6.8e+133)) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -5.9e+94:
		tmp = y * z
	elif z <= -3.7e+66:
		tmp = x * z
	elif z <= -1.0:
		tmp = y * z
	elif z <= 440000.0:
		tmp = x + y
	elif (z <= 1.55e+70) or not (z <= 6.8e+133):
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.9e+94)
		tmp = Float64(y * z);
	elseif (z <= -3.7e+66)
		tmp = Float64(x * z);
	elseif (z <= -1.0)
		tmp = Float64(y * z);
	elseif (z <= 440000.0)
		tmp = Float64(x + y);
	elseif ((z <= 1.55e+70) || !(z <= 6.8e+133))
		tmp = Float64(x * z);
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -5.9e+94)
		tmp = y * z;
	elseif (z <= -3.7e+66)
		tmp = x * z;
	elseif (z <= -1.0)
		tmp = y * z;
	elseif (z <= 440000.0)
		tmp = x + y;
	elseif ((z <= 1.55e+70) || ~((z <= 6.8e+133)))
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -5.9e+94], N[(y * z), $MachinePrecision], If[LessEqual[z, -3.7e+66], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 440000.0], N[(x + y), $MachinePrecision], If[Or[LessEqual[z, 1.55e+70], N[Not[LessEqual[z, 6.8e+133]], $MachinePrecision]], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{+94}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq -3.7 \cdot 10^{+66}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -1:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq 440000:\\
\;\;\;\;x + y\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{+70} \lor \neg \left(z \leq 6.8 \cdot 10^{+133}\right):\\
\;\;\;\;x \cdot z\\

\mathbf{else}:\\
\;\;\;\;y \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.8999999999999999e94 or -3.7e66 < z < -1 or 1.55000000000000015e70 < z < 6.79999999999999975e133

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 85.8%

      \[\leadsto \color{blue}{y \cdot \left(1 + \left(z + \frac{x \cdot \left(1 + z\right)}{y}\right)\right)} \]
    4. Taylor expanded in z around inf 85.8%

      \[\leadsto \color{blue}{y \cdot \left(z \cdot \left(1 + \frac{x}{y}\right)\right)} \]
    5. Taylor expanded in y around inf 47.3%

      \[\leadsto \color{blue}{y \cdot z} \]
    6. Step-by-step derivation
      1. *-commutative47.3%

        \[\leadsto \color{blue}{z \cdot y} \]
    7. Simplified47.3%

      \[\leadsto \color{blue}{z \cdot y} \]

    if -5.8999999999999999e94 < z < -3.7e66 or 4.4e5 < z < 1.55000000000000015e70 or 6.79999999999999975e133 < z

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 97.7%

      \[\leadsto \color{blue}{z \cdot \left(x + y\right)} \]
    4. Step-by-step derivation
      1. +-commutative97.7%

        \[\leadsto z \cdot \color{blue}{\left(y + x\right)} \]
    5. Simplified97.7%

      \[\leadsto \color{blue}{z \cdot \left(y + x\right)} \]
    6. Taylor expanded in x around inf 83.9%

      \[\leadsto \color{blue}{x \cdot \left(z + \frac{y \cdot z}{x}\right)} \]
    7. Taylor expanded in x around inf 60.4%

      \[\leadsto \color{blue}{x \cdot z} \]
    8. Step-by-step derivation
      1. *-commutative60.4%

        \[\leadsto \color{blue}{z \cdot x} \]
    9. Simplified60.4%

      \[\leadsto \color{blue}{z \cdot x} \]

    if -1 < z < 4.4e5

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 95.7%

      \[\leadsto \color{blue}{x + y} \]
    4. Step-by-step derivation
      1. +-commutative95.7%

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified95.7%

      \[\leadsto \color{blue}{y + x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.9 \cdot 10^{+94}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{+66}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 440000:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+70} \lor \neg \left(z \leq 6.8 \cdot 10^{+133}\right):\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 49.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.3 \cdot 10^{-33}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-242}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-53}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.28:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -5.3e-33)
   (* x z)
   (if (<= z 7.2e-242)
     x
     (if (<= z 3.1e-53) y (if (<= z 7.5e-5) x (if (<= z 0.28) y (* x z)))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.3e-33) {
		tmp = x * z;
	} else if (z <= 7.2e-242) {
		tmp = x;
	} else if (z <= 3.1e-53) {
		tmp = y;
	} else if (z <= 7.5e-5) {
		tmp = x;
	} else if (z <= 0.28) {
		tmp = y;
	} else {
		tmp = x * z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-5.3d-33)) then
        tmp = x * z
    else if (z <= 7.2d-242) then
        tmp = x
    else if (z <= 3.1d-53) then
        tmp = y
    else if (z <= 7.5d-5) then
        tmp = x
    else if (z <= 0.28d0) then
        tmp = y
    else
        tmp = x * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -5.3e-33) {
		tmp = x * z;
	} else if (z <= 7.2e-242) {
		tmp = x;
	} else if (z <= 3.1e-53) {
		tmp = y;
	} else if (z <= 7.5e-5) {
		tmp = x;
	} else if (z <= 0.28) {
		tmp = y;
	} else {
		tmp = x * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -5.3e-33:
		tmp = x * z
	elif z <= 7.2e-242:
		tmp = x
	elif z <= 3.1e-53:
		tmp = y
	elif z <= 7.5e-5:
		tmp = x
	elif z <= 0.28:
		tmp = y
	else:
		tmp = x * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -5.3e-33)
		tmp = Float64(x * z);
	elseif (z <= 7.2e-242)
		tmp = x;
	elseif (z <= 3.1e-53)
		tmp = y;
	elseif (z <= 7.5e-5)
		tmp = x;
	elseif (z <= 0.28)
		tmp = y;
	else
		tmp = Float64(x * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -5.3e-33)
		tmp = x * z;
	elseif (z <= 7.2e-242)
		tmp = x;
	elseif (z <= 3.1e-53)
		tmp = y;
	elseif (z <= 7.5e-5)
		tmp = x;
	elseif (z <= 0.28)
		tmp = y;
	else
		tmp = x * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -5.3e-33], N[(x * z), $MachinePrecision], If[LessEqual[z, 7.2e-242], x, If[LessEqual[z, 3.1e-53], y, If[LessEqual[z, 7.5e-5], x, If[LessEqual[z, 0.28], y, N[(x * z), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.3 \cdot 10^{-33}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq 7.2 \cdot 10^{-242}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 3.1 \cdot 10^{-53}:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq 7.5 \cdot 10^{-5}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 0.28:\\
\;\;\;\;y\\

\mathbf{else}:\\
\;\;\;\;x \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.29999999999999968e-33 or 0.28000000000000003 < z

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 94.0%

      \[\leadsto \color{blue}{z \cdot \left(x + y\right)} \]
    4. Step-by-step derivation
      1. +-commutative94.0%

        \[\leadsto z \cdot \color{blue}{\left(y + x\right)} \]
    5. Simplified94.0%

      \[\leadsto \color{blue}{z \cdot \left(y + x\right)} \]
    6. Taylor expanded in x around inf 84.5%

      \[\leadsto \color{blue}{x \cdot \left(z + \frac{y \cdot z}{x}\right)} \]
    7. Taylor expanded in x around inf 54.9%

      \[\leadsto \color{blue}{x \cdot z} \]
    8. Step-by-step derivation
      1. *-commutative54.9%

        \[\leadsto \color{blue}{z \cdot x} \]
    9. Simplified54.9%

      \[\leadsto \color{blue}{z \cdot x} \]

    if -5.29999999999999968e-33 < z < 7.20000000000000028e-242 or 3.10000000000000015e-53 < z < 7.49999999999999934e-5

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(1 + z\right)} \]
      2. distribute-lft-in100.0%

        \[\leadsto \color{blue}{\left(x + y\right) \cdot 1 + \left(x + y\right) \cdot z} \]
      3. *-rgt-identity100.0%

        \[\leadsto \color{blue}{\left(x + y\right)} + \left(x + y\right) \cdot z \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left(x + y\right) + \left(x + y\right) \cdot z} \]
    5. Taylor expanded in x around inf 49.4%

      \[\leadsto \color{blue}{x \cdot \left(1 + z\right)} \]
    6. Step-by-step derivation
      1. +-commutative49.4%

        \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
    7. Simplified49.4%

      \[\leadsto \color{blue}{x \cdot \left(z + 1\right)} \]
    8. Taylor expanded in z around 0 47.6%

      \[\leadsto \color{blue}{x} \]

    if 7.20000000000000028e-242 < z < 3.10000000000000015e-53 or 7.49999999999999934e-5 < z < 0.28000000000000003

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 53.3%

      \[\leadsto \color{blue}{y \cdot \left(1 + z\right)} \]
    4. Taylor expanded in z around 0 53.3%

      \[\leadsto \color{blue}{y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.3 \cdot 10^{-33}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{-242}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-53}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.28:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z + 1 \leq -4 \lor \neg \left(z + 1 \leq 2\right):\\ \;\;\;\;z \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (+ z 1.0) -4.0) (not (<= (+ z 1.0) 2.0))) (* z (+ x y)) (+ x y)))
double code(double x, double y, double z) {
	double tmp;
	if (((z + 1.0) <= -4.0) || !((z + 1.0) <= 2.0)) {
		tmp = z * (x + y);
	} else {
		tmp = x + y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (((z + 1.0d0) <= (-4.0d0)) .or. (.not. ((z + 1.0d0) <= 2.0d0))) then
        tmp = z * (x + y)
    else
        tmp = x + y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (((z + 1.0) <= -4.0) || !((z + 1.0) <= 2.0)) {
		tmp = z * (x + y);
	} else {
		tmp = x + y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((z + 1.0) <= -4.0) or not ((z + 1.0) <= 2.0):
		tmp = z * (x + y)
	else:
		tmp = x + y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(z + 1.0) <= -4.0) || !(Float64(z + 1.0) <= 2.0))
		tmp = Float64(z * Float64(x + y));
	else
		tmp = Float64(x + y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((z + 1.0) <= -4.0) || ~(((z + 1.0) <= 2.0)))
		tmp = z * (x + y);
	else
		tmp = x + y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(z + 1.0), $MachinePrecision], -4.0], N[Not[LessEqual[N[(z + 1.0), $MachinePrecision], 2.0]], $MachinePrecision]], N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z + 1 \leq -4 \lor \neg \left(z + 1 \leq 2\right):\\
\;\;\;\;z \cdot \left(x + y\right)\\

\mathbf{else}:\\
\;\;\;\;x + y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 z #s(literal 1 binary64)) < -4 or 2 < (+.f64 z #s(literal 1 binary64))

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 96.9%

      \[\leadsto \color{blue}{z \cdot \left(x + y\right)} \]
    4. Step-by-step derivation
      1. +-commutative96.9%

        \[\leadsto z \cdot \color{blue}{\left(y + x\right)} \]
    5. Simplified96.9%

      \[\leadsto \color{blue}{z \cdot \left(y + x\right)} \]

    if -4 < (+.f64 z #s(literal 1 binary64)) < 2

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 96.4%

      \[\leadsto \color{blue}{x + y} \]
    4. Step-by-step derivation
      1. +-commutative96.4%

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified96.4%

      \[\leadsto \color{blue}{y + x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z + 1 \leq -4 \lor \neg \left(z + 1 \leq 2\right):\\ \;\;\;\;z \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 64.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7.4 \cdot 10^{-47}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -7.4e-47) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -7.4e-47) {
		tmp = x * (z + 1.0);
	} else {
		tmp = y * (z + 1.0);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-7.4d-47)) then
        tmp = x * (z + 1.0d0)
    else
        tmp = y * (z + 1.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -7.4e-47) {
		tmp = x * (z + 1.0);
	} else {
		tmp = y * (z + 1.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -7.4e-47:
		tmp = x * (z + 1.0)
	else:
		tmp = y * (z + 1.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -7.4e-47)
		tmp = Float64(x * Float64(z + 1.0));
	else
		tmp = Float64(y * Float64(z + 1.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -7.4e-47)
		tmp = x * (z + 1.0);
	else
		tmp = y * (z + 1.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -7.4e-47], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{-47}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(z + 1\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.4000000000000001e-47

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 79.6%

      \[\leadsto \color{blue}{x \cdot \left(1 + z\right)} \]

    if -7.4000000000000001e-47 < x

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 59.3%

      \[\leadsto \color{blue}{y \cdot \left(1 + z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.4 \cdot 10^{-47}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 32.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-48}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
(FPCore (x y z) :precision binary64 (if (<= x -5.5e-48) x y))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.5e-48) {
		tmp = x;
	} else {
		tmp = y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-5.5d-48)) then
        tmp = x
    else
        tmp = y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.5e-48) {
		tmp = x;
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -5.5e-48:
		tmp = x
	else:
		tmp = y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -5.5e-48)
		tmp = x;
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -5.5e-48)
		tmp = x;
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -5.5e-48], x, y]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{-48}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.50000000000000047e-48

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(1 + z\right)} \]
      2. distribute-lft-in99.9%

        \[\leadsto \color{blue}{\left(x + y\right) \cdot 1 + \left(x + y\right) \cdot z} \]
      3. *-rgt-identity99.9%

        \[\leadsto \color{blue}{\left(x + y\right)} + \left(x + y\right) \cdot z \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(x + y\right) + \left(x + y\right) \cdot z} \]
    5. Taylor expanded in x around inf 78.6%

      \[\leadsto \color{blue}{x \cdot \left(1 + z\right)} \]
    6. Step-by-step derivation
      1. +-commutative78.6%

        \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
    7. Simplified78.6%

      \[\leadsto \color{blue}{x \cdot \left(z + 1\right)} \]
    8. Taylor expanded in z around 0 33.7%

      \[\leadsto \color{blue}{x} \]

    if -5.50000000000000047e-48 < x

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 59.0%

      \[\leadsto \color{blue}{y \cdot \left(1 + z\right)} \]
    4. Taylor expanded in z around 0 33.6%

      \[\leadsto \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification33.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{-48}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 26.1% accurate, 7.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x
end function
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(x + y\right) \cdot \left(z + 1\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. +-commutative100.0%

      \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(1 + z\right)} \]
    2. distribute-lft-in100.0%

      \[\leadsto \color{blue}{\left(x + y\right) \cdot 1 + \left(x + y\right) \cdot z} \]
    3. *-rgt-identity100.0%

      \[\leadsto \color{blue}{\left(x + y\right)} + \left(x + y\right) \cdot z \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(x + y\right) + \left(x + y\right) \cdot z} \]
  5. Taylor expanded in x around inf 54.0%

    \[\leadsto \color{blue}{x \cdot \left(1 + z\right)} \]
  6. Step-by-step derivation
    1. +-commutative54.0%

      \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
  7. Simplified54.0%

    \[\leadsto \color{blue}{x \cdot \left(z + 1\right)} \]
  8. Taylor expanded in z around 0 25.6%

    \[\leadsto \color{blue}{x} \]
  9. Final simplification25.6%

    \[\leadsto x \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024059 
(FPCore (x y z)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, G"
  :precision binary64
  (* (+ x y) (+ z 1.0)))