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

Percentage Accurate: 100.0% → 100.0%
Time: 5.7s
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(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. Final simplification100.0%

    \[\leadsto \left(x + y\right) \cdot \left(z + 1\right) \]

Alternative 2: 50.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.2 \cdot 10^{+175}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -4.9 \cdot 10^{+151}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 2.95 \cdot 10^{-205}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 0.22:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+46}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+79}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -7.2e+175)
   (* x z)
   (if (<= z -4.9e+151)
     (* y z)
     (if (<= z -1.0)
       (* x z)
       (if (<= z 2.95e-205)
         y
         (if (<= z 0.22)
           x
           (if (<= z 1.05e+46)
             (* y z)
             (if (<= z 3.8e+79) (* x z) (* y z)))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.2e+175) {
		tmp = x * z;
	} else if (z <= -4.9e+151) {
		tmp = y * z;
	} else if (z <= -1.0) {
		tmp = x * z;
	} else if (z <= 2.95e-205) {
		tmp = y;
	} else if (z <= 0.22) {
		tmp = x;
	} else if (z <= 1.05e+46) {
		tmp = y * z;
	} else if (z <= 3.8e+79) {
		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.2d+175)) then
        tmp = x * z
    else if (z <= (-4.9d+151)) then
        tmp = y * z
    else if (z <= (-1.0d0)) then
        tmp = x * z
    else if (z <= 2.95d-205) then
        tmp = y
    else if (z <= 0.22d0) then
        tmp = x
    else if (z <= 1.05d+46) then
        tmp = y * z
    else if (z <= 3.8d+79) 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.2e+175) {
		tmp = x * z;
	} else if (z <= -4.9e+151) {
		tmp = y * z;
	} else if (z <= -1.0) {
		tmp = x * z;
	} else if (z <= 2.95e-205) {
		tmp = y;
	} else if (z <= 0.22) {
		tmp = x;
	} else if (z <= 1.05e+46) {
		tmp = y * z;
	} else if (z <= 3.8e+79) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -7.2e+175:
		tmp = x * z
	elif z <= -4.9e+151:
		tmp = y * z
	elif z <= -1.0:
		tmp = x * z
	elif z <= 2.95e-205:
		tmp = y
	elif z <= 0.22:
		tmp = x
	elif z <= 1.05e+46:
		tmp = y * z
	elif z <= 3.8e+79:
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -7.2e+175)
		tmp = Float64(x * z);
	elseif (z <= -4.9e+151)
		tmp = Float64(y * z);
	elseif (z <= -1.0)
		tmp = Float64(x * z);
	elseif (z <= 2.95e-205)
		tmp = y;
	elseif (z <= 0.22)
		tmp = x;
	elseif (z <= 1.05e+46)
		tmp = Float64(y * z);
	elseif (z <= 3.8e+79)
		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.2e+175)
		tmp = x * z;
	elseif (z <= -4.9e+151)
		tmp = y * z;
	elseif (z <= -1.0)
		tmp = x * z;
	elseif (z <= 2.95e-205)
		tmp = y;
	elseif (z <= 0.22)
		tmp = x;
	elseif (z <= 1.05e+46)
		tmp = y * z;
	elseif (z <= 3.8e+79)
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -7.2e+175], N[(x * z), $MachinePrecision], If[LessEqual[z, -4.9e+151], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(x * z), $MachinePrecision], If[LessEqual[z, 2.95e-205], y, If[LessEqual[z, 0.22], x, If[LessEqual[z, 1.05e+46], N[(y * z), $MachinePrecision], If[LessEqual[z, 3.8e+79], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -4.9 \cdot 10^{+151}:\\
\;\;\;\;y \cdot z\\

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

\mathbf{elif}\;z \leq 2.95 \cdot 10^{-205}:\\
\;\;\;\;y\\

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

\mathbf{elif}\;z \leq 1.05 \cdot 10^{+46}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq 3.8 \cdot 10^{+79}:\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -7.20000000000000067e175 or -4.8999999999999999e151 < z < -1 or 1.05e46 < z < 3.8000000000000002e79

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. 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 \]
    3. Applied egg-rr99.9%

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

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

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

    if -7.20000000000000067e175 < z < -4.8999999999999999e151 or 0.220000000000000001 < z < 1.05e46 or 3.8000000000000002e79 < z

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + z\right) \cdot y} \]
      2. flip-+46.0%

        \[\leadsto \color{blue}{\frac{1 \cdot 1 - z \cdot z}{1 - z}} \cdot y \]
      3. associate-*l/43.2%

        \[\leadsto \color{blue}{\frac{\left(1 \cdot 1 - z \cdot z\right) \cdot y}{1 - z}} \]
      4. metadata-eval43.2%

        \[\leadsto \frac{\left(\color{blue}{1} - z \cdot z\right) \cdot y}{1 - z} \]
    4. Applied egg-rr43.2%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(y \cdot {z}^{2}\right)}}{1 - z} \]
    6. Step-by-step derivation
      1. unpow241.7%

        \[\leadsto \frac{-1 \cdot \left(y \cdot \color{blue}{\left(z \cdot z\right)}\right)}{1 - z} \]
      2. associate-*r*41.7%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
      3. mul-1-neg41.7%

        \[\leadsto \frac{\color{blue}{\left(-y\right)} \cdot \left(z \cdot z\right)}{1 - z} \]
    7. Simplified41.7%

      \[\leadsto \frac{\color{blue}{\left(-y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
    8. Taylor expanded in z around inf 52.2%

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

    if -1 < z < 2.94999999999999987e-205

    1. Initial program 100.0%

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

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

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

    if 2.94999999999999987e-205 < z < 0.220000000000000001

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.2 \cdot 10^{+175}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -4.9 \cdot 10^{+151}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 2.95 \cdot 10^{-205}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 0.22:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+46}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{+79}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 3: 75.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z + 1\right)\\ \mathbf{if}\;z \leq -6 \cdot 10^{+179}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.75 \cdot 10^{+150}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{+46}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -0.00024:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 0.062:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+82}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ z 1.0))))
   (if (<= z -6e+179)
     (* x z)
     (if (<= z -2.75e+150)
       (* y z)
       (if (<= z -3.6e+46)
         (* x z)
         (if (<= z -0.00024)
           t_0
           (if (<= z 0.062)
             (+ x y)
             (if (<= z 1.4e+38) t_0 (if (<= z 5e+82) (* x z) (* y z))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (z + 1.0);
	double tmp;
	if (z <= -6e+179) {
		tmp = x * z;
	} else if (z <= -2.75e+150) {
		tmp = y * z;
	} else if (z <= -3.6e+46) {
		tmp = x * z;
	} else if (z <= -0.00024) {
		tmp = t_0;
	} else if (z <= 0.062) {
		tmp = x + y;
	} else if (z <= 1.4e+38) {
		tmp = t_0;
	} else if (z <= 5e+82) {
		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) :: t_0
    real(8) :: tmp
    t_0 = y * (z + 1.0d0)
    if (z <= (-6d+179)) then
        tmp = x * z
    else if (z <= (-2.75d+150)) then
        tmp = y * z
    else if (z <= (-3.6d+46)) then
        tmp = x * z
    else if (z <= (-0.00024d0)) then
        tmp = t_0
    else if (z <= 0.062d0) then
        tmp = x + y
    else if (z <= 1.4d+38) then
        tmp = t_0
    else if (z <= 5d+82) 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 t_0 = y * (z + 1.0);
	double tmp;
	if (z <= -6e+179) {
		tmp = x * z;
	} else if (z <= -2.75e+150) {
		tmp = y * z;
	} else if (z <= -3.6e+46) {
		tmp = x * z;
	} else if (z <= -0.00024) {
		tmp = t_0;
	} else if (z <= 0.062) {
		tmp = x + y;
	} else if (z <= 1.4e+38) {
		tmp = t_0;
	} else if (z <= 5e+82) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z + 1.0)
	tmp = 0
	if z <= -6e+179:
		tmp = x * z
	elif z <= -2.75e+150:
		tmp = y * z
	elif z <= -3.6e+46:
		tmp = x * z
	elif z <= -0.00024:
		tmp = t_0
	elif z <= 0.062:
		tmp = x + y
	elif z <= 1.4e+38:
		tmp = t_0
	elif z <= 5e+82:
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z + 1.0))
	tmp = 0.0
	if (z <= -6e+179)
		tmp = Float64(x * z);
	elseif (z <= -2.75e+150)
		tmp = Float64(y * z);
	elseif (z <= -3.6e+46)
		tmp = Float64(x * z);
	elseif (z <= -0.00024)
		tmp = t_0;
	elseif (z <= 0.062)
		tmp = Float64(x + y);
	elseif (z <= 1.4e+38)
		tmp = t_0;
	elseif (z <= 5e+82)
		tmp = Float64(x * z);
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (z + 1.0);
	tmp = 0.0;
	if (z <= -6e+179)
		tmp = x * z;
	elseif (z <= -2.75e+150)
		tmp = y * z;
	elseif (z <= -3.6e+46)
		tmp = x * z;
	elseif (z <= -0.00024)
		tmp = t_0;
	elseif (z <= 0.062)
		tmp = x + y;
	elseif (z <= 1.4e+38)
		tmp = t_0;
	elseif (z <= 5e+82)
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6e+179], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.75e+150], N[(y * z), $MachinePrecision], If[LessEqual[z, -3.6e+46], N[(x * z), $MachinePrecision], If[LessEqual[z, -0.00024], t$95$0, If[LessEqual[z, 0.062], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.4e+38], t$95$0, If[LessEqual[z, 5e+82], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(z + 1\right)\\
\mathbf{if}\;z \leq -6 \cdot 10^{+179}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -2.75 \cdot 10^{+150}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq -3.6 \cdot 10^{+46}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -0.00024:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq 1.4 \cdot 10^{+38}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 5 \cdot 10^{+82}:\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -5.9999999999999996e179 or -2.75000000000000008e150 < z < -3.5999999999999999e46 or 1.4e38 < z < 5.00000000000000015e82

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. 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 \]
    3. Applied egg-rr100.0%

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

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

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

    if -5.9999999999999996e179 < z < -2.75000000000000008e150 or 5.00000000000000015e82 < z

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + z\right) \cdot y} \]
      2. flip-+46.7%

        \[\leadsto \color{blue}{\frac{1 \cdot 1 - z \cdot z}{1 - z}} \cdot y \]
      3. associate-*l/45.0%

        \[\leadsto \color{blue}{\frac{\left(1 \cdot 1 - z \cdot z\right) \cdot y}{1 - z}} \]
      4. metadata-eval45.0%

        \[\leadsto \frac{\left(\color{blue}{1} - z \cdot z\right) \cdot y}{1 - z} \]
    4. Applied egg-rr45.0%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(y \cdot {z}^{2}\right)}}{1 - z} \]
    6. Step-by-step derivation
      1. unpow245.0%

        \[\leadsto \frac{-1 \cdot \left(y \cdot \color{blue}{\left(z \cdot z\right)}\right)}{1 - z} \]
      2. associate-*r*45.0%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
      3. mul-1-neg45.0%

        \[\leadsto \frac{\color{blue}{\left(-y\right)} \cdot \left(z \cdot z\right)}{1 - z} \]
    7. Simplified45.0%

      \[\leadsto \frac{\color{blue}{\left(-y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
    8. Taylor expanded in z around inf 55.6%

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

    if -3.5999999999999999e46 < z < -2.40000000000000006e-4 or 0.062 < z < 1.4e38

    1. Initial program 99.9%

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

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

    if -2.40000000000000006e-4 < z < 0.062

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+179}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.75 \cdot 10^{+150}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{+46}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -0.00024:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \mathbf{elif}\;z \leq 0.062:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+38}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+82}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 4: 75.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+178}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.75 \cdot 10^{+156}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 29:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+44}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+82}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -9e+178)
   (* x z)
   (if (<= z -2.75e+156)
     (* y z)
     (if (<= z -1.0)
       (* x z)
       (if (<= z 29.0)
         (+ x y)
         (if (<= z 1.15e+44) (* y z) (if (<= z 2.3e+82) (* x z) (* y z))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -9e+178) {
		tmp = x * z;
	} else if (z <= -2.75e+156) {
		tmp = y * z;
	} else if (z <= -1.0) {
		tmp = x * z;
	} else if (z <= 29.0) {
		tmp = x + y;
	} else if (z <= 1.15e+44) {
		tmp = y * z;
	} else if (z <= 2.3e+82) {
		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 <= (-9d+178)) then
        tmp = x * z
    else if (z <= (-2.75d+156)) then
        tmp = y * z
    else if (z <= (-1.0d0)) then
        tmp = x * z
    else if (z <= 29.0d0) then
        tmp = x + y
    else if (z <= 1.15d+44) then
        tmp = y * z
    else if (z <= 2.3d+82) 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 <= -9e+178) {
		tmp = x * z;
	} else if (z <= -2.75e+156) {
		tmp = y * z;
	} else if (z <= -1.0) {
		tmp = x * z;
	} else if (z <= 29.0) {
		tmp = x + y;
	} else if (z <= 1.15e+44) {
		tmp = y * z;
	} else if (z <= 2.3e+82) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -9e+178:
		tmp = x * z
	elif z <= -2.75e+156:
		tmp = y * z
	elif z <= -1.0:
		tmp = x * z
	elif z <= 29.0:
		tmp = x + y
	elif z <= 1.15e+44:
		tmp = y * z
	elif z <= 2.3e+82:
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -9e+178)
		tmp = Float64(x * z);
	elseif (z <= -2.75e+156)
		tmp = Float64(y * z);
	elseif (z <= -1.0)
		tmp = Float64(x * z);
	elseif (z <= 29.0)
		tmp = Float64(x + y);
	elseif (z <= 1.15e+44)
		tmp = Float64(y * z);
	elseif (z <= 2.3e+82)
		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 <= -9e+178)
		tmp = x * z;
	elseif (z <= -2.75e+156)
		tmp = y * z;
	elseif (z <= -1.0)
		tmp = x * z;
	elseif (z <= 29.0)
		tmp = x + y;
	elseif (z <= 1.15e+44)
		tmp = y * z;
	elseif (z <= 2.3e+82)
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -9e+178], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.75e+156], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(x * z), $MachinePrecision], If[LessEqual[z, 29.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 1.15e+44], N[(y * z), $MachinePrecision], If[LessEqual[z, 2.3e+82], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.75 \cdot 10^{+156}:\\
\;\;\;\;y \cdot z\\

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

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

\mathbf{elif}\;z \leq 1.15 \cdot 10^{+44}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq 2.3 \cdot 10^{+82}:\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.9999999999999994e178 or -2.7500000000000001e156 < z < -1 or 1.15000000000000002e44 < z < 2.29999999999999988e82

    1. Initial program 100.0%

      \[\left(x + y\right) \cdot \left(z + 1\right) \]
    2. 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 \]
    3. Applied egg-rr99.9%

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

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

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

    if -8.9999999999999994e178 < z < -2.7500000000000001e156 or 29 < z < 1.15000000000000002e44 or 2.29999999999999988e82 < z

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + z\right) \cdot y} \]
      2. flip-+45.2%

        \[\leadsto \color{blue}{\frac{1 \cdot 1 - z \cdot z}{1 - z}} \cdot y \]
      3. associate-*l/42.3%

        \[\leadsto \color{blue}{\frac{\left(1 \cdot 1 - z \cdot z\right) \cdot y}{1 - z}} \]
      4. metadata-eval42.3%

        \[\leadsto \frac{\left(\color{blue}{1} - z \cdot z\right) \cdot y}{1 - z} \]
    4. Applied egg-rr42.3%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(y \cdot {z}^{2}\right)}}{1 - z} \]
    6. Step-by-step derivation
      1. unpow242.3%

        \[\leadsto \frac{-1 \cdot \left(y \cdot \color{blue}{\left(z \cdot z\right)}\right)}{1 - z} \]
      2. associate-*r*42.3%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
      3. mul-1-neg42.3%

        \[\leadsto \frac{\color{blue}{\left(-y\right)} \cdot \left(z \cdot z\right)}{1 - z} \]
    7. Simplified42.3%

      \[\leadsto \frac{\color{blue}{\left(-y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
    8. Taylor expanded in z around inf 52.8%

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

    if -1 < z < 29

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+178}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.75 \cdot 10^{+156}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 29:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+44}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+82}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 5: 62.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-59} \lor \neg \left(x \leq -1.15 \cdot 10^{-88}\right) \land x \leq -2.3 \cdot 10^{-117}:\\ \;\;\;\;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 (or (<= x -2.6e-59) (and (not (<= x -1.15e-88)) (<= x -2.3e-117)))
   (* x (+ z 1.0))
   (* y (+ z 1.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -2.6e-59) || (!(x <= -1.15e-88) && (x <= -2.3e-117))) {
		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 <= (-2.6d-59)) .or. (.not. (x <= (-1.15d-88))) .and. (x <= (-2.3d-117))) 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 <= -2.6e-59) || (!(x <= -1.15e-88) && (x <= -2.3e-117))) {
		tmp = x * (z + 1.0);
	} else {
		tmp = y * (z + 1.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -2.6e-59) or (not (x <= -1.15e-88) and (x <= -2.3e-117)):
		tmp = x * (z + 1.0)
	else:
		tmp = y * (z + 1.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -2.6e-59) || (!(x <= -1.15e-88) && (x <= -2.3e-117)))
		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 <= -2.6e-59) || (~((x <= -1.15e-88)) && (x <= -2.3e-117)))
		tmp = x * (z + 1.0);
	else
		tmp = y * (z + 1.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.6e-59], And[N[Not[LessEqual[x, -1.15e-88]], $MachinePrecision], LessEqual[x, -2.3e-117]]], 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 -2.6 \cdot 10^{-59} \lor \neg \left(x \leq -1.15 \cdot 10^{-88}\right) \land x \leq -2.3 \cdot 10^{-117}:\\
\;\;\;\;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 < -2.59999999999999998e-59 or -1.14999999999999993e-88 < x < -2.29999999999999994e-117

    1. Initial program 99.9%

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

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

    if -2.59999999999999998e-59 < x < -1.14999999999999993e-88 or -2.29999999999999994e-117 < x

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-59} \lor \neg \left(x \leq -1.15 \cdot 10^{-88}\right) \land x \leq -2.3 \cdot 10^{-117}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \end{array} \]

Alternative 6: 50.0% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \leq 3.15 \cdot 10^{-204}:\\
\;\;\;\;y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.7999999999999999e-10 or 0.35999999999999999 < z

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{\left(1 + z\right) \cdot y} \]
      2. flip-+45.2%

        \[\leadsto \color{blue}{\frac{1 \cdot 1 - z \cdot z}{1 - z}} \cdot y \]
      3. associate-*l/40.5%

        \[\leadsto \color{blue}{\frac{\left(1 \cdot 1 - z \cdot z\right) \cdot y}{1 - z}} \]
      4. metadata-eval40.5%

        \[\leadsto \frac{\left(\color{blue}{1} - z \cdot z\right) \cdot y}{1 - z} \]
    4. Applied egg-rr40.5%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(y \cdot {z}^{2}\right)}}{1 - z} \]
    6. Step-by-step derivation
      1. unpow239.9%

        \[\leadsto \frac{-1 \cdot \left(y \cdot \color{blue}{\left(z \cdot z\right)}\right)}{1 - z} \]
      2. associate-*r*39.9%

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
      3. mul-1-neg39.9%

        \[\leadsto \frac{\color{blue}{\left(-y\right)} \cdot \left(z \cdot z\right)}{1 - z} \]
    7. Simplified39.9%

      \[\leadsto \frac{\color{blue}{\left(-y\right) \cdot \left(z \cdot z\right)}}{1 - z} \]
    8. Taylor expanded in z around inf 47.9%

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

    if -7.7999999999999999e-10 < z < 3.14999999999999996e-204

    1. Initial program 100.0%

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

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

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

    if 3.14999999999999996e-204 < z < 0.35999999999999999

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification50.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{-10}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{-204}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 0.36:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 7: 98.0% accurate, 0.8× 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. Taylor expanded in z around inf 99.0%

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

    if -1 < z < 1

    1. Initial program 100.0%

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

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

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

Alternative 8: 31.2% accurate, 2.3× speedup?

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

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

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


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

    1. Initial program 99.9%

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

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

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

    if -1.8e-129 < x

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{-129}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]

Alternative 9: 27.0% 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. Taylor expanded in x around inf 52.8%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification21.0%

    \[\leadsto x \]

Reproduce

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