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

Percentage Accurate: 100.0% → 100.0%
Time: 4.9s
Alternatives: 10
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 10 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, 0.8× speedup?

\[\begin{array}{l} \\ \left(x + y\right) + z \cdot \left(x + y\right) \end{array} \]
(FPCore (x y z) :precision binary64 (+ (+ x y) (* z (+ x y))))
double code(double x, double y, double z) {
	return (x + y) + (z * (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 = (x + y) + (z * (x + y))
end function
public static double code(double x, double y, double z) {
	return (x + y) + (z * (x + y));
}
def code(x, y, z):
	return (x + y) + (z * (x + y))
function code(x, y, z)
	return Float64(Float64(x + y) + Float64(z * Float64(x + y)))
end
function tmp = code(x, y, z)
	tmp = (x + y) + (z * (x + y));
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] + N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x + y\right) + z \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. 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. Final simplification100.0%

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

Alternative 2: 50.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+244}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.05 \cdot 10^{+164}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{+91}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-211}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-307}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 950000:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+200}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.65e+244)
   (* x z)
   (if (<= z -2.05e+164)
     (* y z)
     (if (<= z -8.5e+91)
       (* x z)
       (if (<= z -1.0)
         (* y z)
         (if (<= z -5.2e-211)
           x
           (if (<= z -6.8e-307)
             y
             (if (<= z 950000.0) x (if (<= z 1.1e+200) (* x z) (* y z))))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.65e+244) {
		tmp = x * z;
	} else if (z <= -2.05e+164) {
		tmp = y * z;
	} else if (z <= -8.5e+91) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= -5.2e-211) {
		tmp = x;
	} else if (z <= -6.8e-307) {
		tmp = y;
	} else if (z <= 950000.0) {
		tmp = x;
	} else if (z <= 1.1e+200) {
		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 <= (-1.65d+244)) then
        tmp = x * z
    else if (z <= (-2.05d+164)) then
        tmp = y * z
    else if (z <= (-8.5d+91)) then
        tmp = x * z
    else if (z <= (-1.0d0)) then
        tmp = y * z
    else if (z <= (-5.2d-211)) then
        tmp = x
    else if (z <= (-6.8d-307)) then
        tmp = y
    else if (z <= 950000.0d0) then
        tmp = x
    else if (z <= 1.1d+200) 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 <= -1.65e+244) {
		tmp = x * z;
	} else if (z <= -2.05e+164) {
		tmp = y * z;
	} else if (z <= -8.5e+91) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= -5.2e-211) {
		tmp = x;
	} else if (z <= -6.8e-307) {
		tmp = y;
	} else if (z <= 950000.0) {
		tmp = x;
	} else if (z <= 1.1e+200) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.65e+244:
		tmp = x * z
	elif z <= -2.05e+164:
		tmp = y * z
	elif z <= -8.5e+91:
		tmp = x * z
	elif z <= -1.0:
		tmp = y * z
	elif z <= -5.2e-211:
		tmp = x
	elif z <= -6.8e-307:
		tmp = y
	elif z <= 950000.0:
		tmp = x
	elif z <= 1.1e+200:
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.65e+244)
		tmp = Float64(x * z);
	elseif (z <= -2.05e+164)
		tmp = Float64(y * z);
	elseif (z <= -8.5e+91)
		tmp = Float64(x * z);
	elseif (z <= -1.0)
		tmp = Float64(y * z);
	elseif (z <= -5.2e-211)
		tmp = x;
	elseif (z <= -6.8e-307)
		tmp = y;
	elseif (z <= 950000.0)
		tmp = x;
	elseif (z <= 1.1e+200)
		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 <= -1.65e+244)
		tmp = x * z;
	elseif (z <= -2.05e+164)
		tmp = y * z;
	elseif (z <= -8.5e+91)
		tmp = x * z;
	elseif (z <= -1.0)
		tmp = y * z;
	elseif (z <= -5.2e-211)
		tmp = x;
	elseif (z <= -6.8e-307)
		tmp = y;
	elseif (z <= 950000.0)
		tmp = x;
	elseif (z <= 1.1e+200)
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1.65e+244], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.05e+164], N[(y * z), $MachinePrecision], If[LessEqual[z, -8.5e+91], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, -5.2e-211], x, If[LessEqual[z, -6.8e-307], y, If[LessEqual[z, 950000.0], x, If[LessEqual[z, 1.1e+200], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+244}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -2.05 \cdot 10^{+164}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq -8.5 \cdot 10^{+91}:\\
\;\;\;\;x \cdot z\\

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

\mathbf{elif}\;z \leq -5.2 \cdot 10^{-211}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq -6.8 \cdot 10^{-307}:\\
\;\;\;\;y\\

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

\mathbf{elif}\;z \leq 1.1 \cdot 10^{+200}:\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.6499999999999999e244 or -2.05000000000000008e164 < z < -8.4999999999999995e91 or 9.5e5 < z < 1.1e200

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot z + x \cdot 1} \]
      3. *-rgt-identity54.4%

        \[\leadsto x \cdot z + \color{blue}{x} \]
    5. Applied egg-rr54.4%

      \[\leadsto \color{blue}{x \cdot z + x} \]
    6. Taylor expanded in z around inf 53.8%

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

    if -1.6499999999999999e244 < z < -2.05000000000000008e164 or -8.4999999999999995e91 < z < -1 or 1.1e200 < z

    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.5%

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

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

        \[\leadsto \color{blue}{y \cdot z + y \cdot 1} \]
      3. *-rgt-identity53.5%

        \[\leadsto y \cdot z + \color{blue}{y} \]
    5. Applied egg-rr53.5%

      \[\leadsto \color{blue}{y \cdot z + y} \]
    6. Taylor expanded in z around inf 53.5%

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

        \[\leadsto \color{blue}{z \cdot y} \]
    8. Simplified53.5%

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

    if -1 < z < -5.2e-211 or -6.79999999999999978e-307 < z < 9.5e5

    1. Initial program 100.0%

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

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

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

    if -5.2e-211 < z < -6.79999999999999978e-307

    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.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+244}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.05 \cdot 10^{+164}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{+91}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-211}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-307}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 950000:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+200}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.3% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+245}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -8 \cdot 10^{+166}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -8.6 \cdot 10^{+95}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-8}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+201}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -7.8e+245)
   (* x z)
   (if (<= z -8e+166)
     (* y z)
     (if (<= z -8.6e+95)
       (* x z)
       (if (<= z -1.0)
         (* y z)
         (if (<= z 3e-8)
           (+ x y)
           (if (<= z 2.3e+201) (* x (+ z 1.0)) (* y z))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.8e+245) {
		tmp = x * z;
	} else if (z <= -8e+166) {
		tmp = y * z;
	} else if (z <= -8.6e+95) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 3e-8) {
		tmp = x + y;
	} else if (z <= 2.3e+201) {
		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 <= (-7.8d+245)) then
        tmp = x * z
    else if (z <= (-8d+166)) then
        tmp = y * z
    else if (z <= (-8.6d+95)) then
        tmp = x * z
    else if (z <= (-1.0d0)) then
        tmp = y * z
    else if (z <= 3d-8) then
        tmp = x + y
    else if (z <= 2.3d+201) 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 <= -7.8e+245) {
		tmp = x * z;
	} else if (z <= -8e+166) {
		tmp = y * z;
	} else if (z <= -8.6e+95) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 3e-8) {
		tmp = x + y;
	} else if (z <= 2.3e+201) {
		tmp = x * (z + 1.0);
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -7.8e+245:
		tmp = x * z
	elif z <= -8e+166:
		tmp = y * z
	elif z <= -8.6e+95:
		tmp = x * z
	elif z <= -1.0:
		tmp = y * z
	elif z <= 3e-8:
		tmp = x + y
	elif z <= 2.3e+201:
		tmp = x * (z + 1.0)
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -7.8e+245)
		tmp = Float64(x * z);
	elseif (z <= -8e+166)
		tmp = Float64(y * z);
	elseif (z <= -8.6e+95)
		tmp = Float64(x * z);
	elseif (z <= -1.0)
		tmp = Float64(y * z);
	elseif (z <= 3e-8)
		tmp = Float64(x + y);
	elseif (z <= 2.3e+201)
		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 <= -7.8e+245)
		tmp = x * z;
	elseif (z <= -8e+166)
		tmp = y * z;
	elseif (z <= -8.6e+95)
		tmp = x * z;
	elseif (z <= -1.0)
		tmp = y * z;
	elseif (z <= 3e-8)
		tmp = x + y;
	elseif (z <= 2.3e+201)
		tmp = x * (z + 1.0);
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -7.8e+245], N[(x * z), $MachinePrecision], If[LessEqual[z, -8e+166], N[(y * z), $MachinePrecision], If[LessEqual[z, -8.6e+95], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 3e-8], N[(x + y), $MachinePrecision], If[LessEqual[z, 2.3e+201], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.8 \cdot 10^{+245}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -8 \cdot 10^{+166}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq -8.6 \cdot 10^{+95}:\\
\;\;\;\;x \cdot z\\

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

\mathbf{elif}\;z \leq 3 \cdot 10^{-8}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;z \leq 2.3 \cdot 10^{+201}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -7.7999999999999996e245 or -7.99999999999999952e166 < z < -8.6e95

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot z + x \cdot 1} \]
      3. *-rgt-identity44.9%

        \[\leadsto x \cdot z + \color{blue}{x} \]
    5. Applied egg-rr44.9%

      \[\leadsto \color{blue}{x \cdot z + x} \]
    6. Taylor expanded in z around inf 44.9%

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

    if -7.7999999999999996e245 < z < -7.99999999999999952e166 or -8.6e95 < z < -1 or 2.3000000000000001e201 < z

    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.5%

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

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

        \[\leadsto \color{blue}{y \cdot z + y \cdot 1} \]
      3. *-rgt-identity53.5%

        \[\leadsto y \cdot z + \color{blue}{y} \]
    5. Applied egg-rr53.5%

      \[\leadsto \color{blue}{y \cdot z + y} \]
    6. Taylor expanded in z around inf 53.5%

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

        \[\leadsto \color{blue}{z \cdot y} \]
    8. Simplified53.5%

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

    if -1 < z < 2.99999999999999973e-8

    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.5%

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

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

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

    if 2.99999999999999973e-8 < z < 2.3000000000000001e201

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+245}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -8 \cdot 10^{+166}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -8.6 \cdot 10^{+95}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-8}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+201}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+246}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{+164}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -6.2 \cdot 10^{+95}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 78000000:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+202}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -7.5e+246)
   (* x z)
   (if (<= z -2.6e+164)
     (* y z)
     (if (<= z -6.2e+95)
       (* x z)
       (if (<= z -1.0)
         (* y z)
         (if (<= z 78000000.0)
           (+ x y)
           (if (<= z 7.2e+202) (* x z) (* y z))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.5e+246) {
		tmp = x * z;
	} else if (z <= -2.6e+164) {
		tmp = y * z;
	} else if (z <= -6.2e+95) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 78000000.0) {
		tmp = x + y;
	} else if (z <= 7.2e+202) {
		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 <= (-7.5d+246)) then
        tmp = x * z
    else if (z <= (-2.6d+164)) then
        tmp = y * z
    else if (z <= (-6.2d+95)) then
        tmp = x * z
    else if (z <= (-1.0d0)) then
        tmp = y * z
    else if (z <= 78000000.0d0) then
        tmp = x + y
    else if (z <= 7.2d+202) 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 <= -7.5e+246) {
		tmp = x * z;
	} else if (z <= -2.6e+164) {
		tmp = y * z;
	} else if (z <= -6.2e+95) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 78000000.0) {
		tmp = x + y;
	} else if (z <= 7.2e+202) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -7.5e+246:
		tmp = x * z
	elif z <= -2.6e+164:
		tmp = y * z
	elif z <= -6.2e+95:
		tmp = x * z
	elif z <= -1.0:
		tmp = y * z
	elif z <= 78000000.0:
		tmp = x + y
	elif z <= 7.2e+202:
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -7.5e+246)
		tmp = Float64(x * z);
	elseif (z <= -2.6e+164)
		tmp = Float64(y * z);
	elseif (z <= -6.2e+95)
		tmp = Float64(x * z);
	elseif (z <= -1.0)
		tmp = Float64(y * z);
	elseif (z <= 78000000.0)
		tmp = Float64(x + y);
	elseif (z <= 7.2e+202)
		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 <= -7.5e+246)
		tmp = x * z;
	elseif (z <= -2.6e+164)
		tmp = y * z;
	elseif (z <= -6.2e+95)
		tmp = x * z;
	elseif (z <= -1.0)
		tmp = y * z;
	elseif (z <= 78000000.0)
		tmp = x + y;
	elseif (z <= 7.2e+202)
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -7.5e+246], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.6e+164], N[(y * z), $MachinePrecision], If[LessEqual[z, -6.2e+95], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 78000000.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 7.2e+202], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+246}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -2.6 \cdot 10^{+164}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq -6.2 \cdot 10^{+95}:\\
\;\;\;\;x \cdot z\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.5e246 or -2.5999999999999999e164 < z < -6.2000000000000006e95 or 7.8e7 < z < 7.20000000000000016e202

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot z + x \cdot 1} \]
      3. *-rgt-identity53.8%

        \[\leadsto x \cdot z + \color{blue}{x} \]
    5. Applied egg-rr53.8%

      \[\leadsto \color{blue}{x \cdot z + x} \]
    6. Taylor expanded in z around inf 53.2%

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

    if -7.5e246 < z < -2.5999999999999999e164 or -6.2000000000000006e95 < z < -1 or 7.20000000000000016e202 < z

    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.5%

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

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

        \[\leadsto \color{blue}{y \cdot z + y \cdot 1} \]
      3. *-rgt-identity53.5%

        \[\leadsto y \cdot z + \color{blue}{y} \]
    5. Applied egg-rr53.5%

      \[\leadsto \color{blue}{y \cdot z + y} \]
    6. Taylor expanded in z around inf 53.5%

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

        \[\leadsto \color{blue}{z \cdot y} \]
    8. Simplified53.5%

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

    if -1 < z < 7.8e7

    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.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+246}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{+164}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -6.2 \cdot 10^{+95}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 78000000:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+202}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 49.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{+29}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-211}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-308}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 950000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.5e+29)
   (* x z)
   (if (<= z -4.5e-211)
     x
     (if (<= z -5e-308) y (if (<= z 950000.0) x (* x z))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.5e+29) {
		tmp = x * z;
	} else if (z <= -4.5e-211) {
		tmp = x;
	} else if (z <= -5e-308) {
		tmp = y;
	} else if (z <= 950000.0) {
		tmp = x;
	} 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 <= (-1.5d+29)) then
        tmp = x * z
    else if (z <= (-4.5d-211)) then
        tmp = x
    else if (z <= (-5d-308)) then
        tmp = y
    else if (z <= 950000.0d0) then
        tmp = x
    else
        tmp = x * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.5e+29) {
		tmp = x * z;
	} else if (z <= -4.5e-211) {
		tmp = x;
	} else if (z <= -5e-308) {
		tmp = y;
	} else if (z <= 950000.0) {
		tmp = x;
	} else {
		tmp = x * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.5e+29:
		tmp = x * z
	elif z <= -4.5e-211:
		tmp = x
	elif z <= -5e-308:
		tmp = y
	elif z <= 950000.0:
		tmp = x
	else:
		tmp = x * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.5e+29)
		tmp = Float64(x * z);
	elseif (z <= -4.5e-211)
		tmp = x;
	elseif (z <= -5e-308)
		tmp = y;
	elseif (z <= 950000.0)
		tmp = x;
	else
		tmp = Float64(x * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.5e+29)
		tmp = x * z;
	elseif (z <= -4.5e-211)
		tmp = x;
	elseif (z <= -5e-308)
		tmp = y;
	elseif (z <= 950000.0)
		tmp = x;
	else
		tmp = x * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1.5e+29], N[(x * z), $MachinePrecision], If[LessEqual[z, -4.5e-211], x, If[LessEqual[z, -5e-308], y, If[LessEqual[z, 950000.0], x, N[(x * z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+29}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -4.5 \cdot 10^{-211}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq -5 \cdot 10^{-308}:\\
\;\;\;\;y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.5e29 or 9.5e5 < z

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{x \cdot z + x \cdot 1} \]
      3. *-rgt-identity54.0%

        \[\leadsto x \cdot z + \color{blue}{x} \]
    5. Applied egg-rr54.0%

      \[\leadsto \color{blue}{x \cdot z + x} \]
    6. Taylor expanded in z around inf 53.7%

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

    if -1.5e29 < z < -4.4999999999999999e-211 or -4.99999999999999955e-308 < z < 9.5e5

    1. Initial program 100.0%

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

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

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

    if -4.4999999999999999e-211 < z < -4.99999999999999955e-308

    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 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 97.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\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) (not (<= z 1.0))) (* z (+ x y)) (+ x y)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.0) || !(z <= 1.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)) .or. (.not. (z <= 1.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) || !(z <= 1.0)) {
		tmp = z * (x + y);
	} else {
		tmp = x + y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.0) or not (z <= 1.0):
		tmp = z * (x + y)
	else:
		tmp = x + y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.0) || !(z <= 1.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) || ~((z <= 1.0)))
		tmp = z * (x + y);
	else
		tmp = x + y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 1 < 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 98.3%

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

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

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

    if -1 < z < 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 98.5%

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

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

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

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

Alternative 7: 63.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 2.8 \cdot 10^{-51}:\\ \;\;\;\;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 (<= y 2.8e-51) (* x (+ z 1.0)) (* y (+ z 1.0))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 2.8e-51) {
		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 (y <= 2.8d-51) 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 (y <= 2.8e-51) {
		tmp = x * (z + 1.0);
	} else {
		tmp = y * (z + 1.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 2.8e-51:
		tmp = x * (z + 1.0)
	else:
		tmp = y * (z + 1.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 2.8e-51)
		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 (y <= 2.8e-51)
		tmp = x * (z + 1.0);
	else
		tmp = y * (z + 1.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 2.8e-51], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{-51}:\\
\;\;\;\;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 y < 2.8e-51

    1. Initial program 100.0%

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

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

    if 2.8e-51 < y

    1. Initial program 100.0%

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

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

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

Alternative 8: 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}
Derivation
  1. Initial program 100.0%

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

Alternative 9: 32.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq 4.5 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \end{array} \]
(FPCore (x y z) :precision binary64 (if (<= y 4.5e-51) x y))
double code(double x, double y, double z) {
	double tmp;
	if (y <= 4.5e-51) {
		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 (y <= 4.5d-51) 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 (y <= 4.5e-51) {
		tmp = x;
	} else {
		tmp = y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= 4.5e-51:
		tmp = x
	else:
		tmp = y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= 4.5e-51)
		tmp = x;
	else
		tmp = y;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 4.5e-51)
		tmp = x;
	else
		tmp = y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, 4.5e-51], x, y]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{-51}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.49999999999999974e-51

    1. Initial program 100.0%

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

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

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

    if 4.49999999999999974e-51 < y

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 26.4% 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. Taylor expanded in x around inf 52.7%

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

    \[\leadsto \color{blue}{x} \]
  5. Add Preprocessing

Reproduce

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