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

Percentage Accurate: 100.0% → 100.0%
Time: 6.9s
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. Add Preprocessing
  3. Final simplification100.0%

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

Alternative 2: 50.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.22 \cdot 10^{+231}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{+148}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{+72}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -29000000:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-37}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{-113}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq -7.5 \cdot 10^{-226}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-297}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-104}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-40}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00017:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+190}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.22e+231)
   (* y z)
   (if (<= z -2.2e+148)
     (* x z)
     (if (<= z -9.5e+72)
       (* y z)
       (if (<= z -29000000.0)
         (* x z)
         (if (<= z -2.8e-37)
           x
           (if (<= z -4.1e-113)
             y
             (if (<= z -7.5e-226)
               x
               (if (<= z 1.8e-297)
                 y
                 (if (<= z 9.5e-250)
                   x
                   (if (<= z 1.7e-104)
                     y
                     (if (<= z 5.4e-40)
                       x
                       (if (<= z 0.00017)
                         y
                         (if (<= z 5.9e+190) (* x z) (* y z)))))))))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.22e+231) {
		tmp = y * z;
	} else if (z <= -2.2e+148) {
		tmp = x * z;
	} else if (z <= -9.5e+72) {
		tmp = y * z;
	} else if (z <= -29000000.0) {
		tmp = x * z;
	} else if (z <= -2.8e-37) {
		tmp = x;
	} else if (z <= -4.1e-113) {
		tmp = y;
	} else if (z <= -7.5e-226) {
		tmp = x;
	} else if (z <= 1.8e-297) {
		tmp = y;
	} else if (z <= 9.5e-250) {
		tmp = x;
	} else if (z <= 1.7e-104) {
		tmp = y;
	} else if (z <= 5.4e-40) {
		tmp = x;
	} else if (z <= 0.00017) {
		tmp = y;
	} else if (z <= 5.9e+190) {
		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.22d+231)) then
        tmp = y * z
    else if (z <= (-2.2d+148)) then
        tmp = x * z
    else if (z <= (-9.5d+72)) then
        tmp = y * z
    else if (z <= (-29000000.0d0)) then
        tmp = x * z
    else if (z <= (-2.8d-37)) then
        tmp = x
    else if (z <= (-4.1d-113)) then
        tmp = y
    else if (z <= (-7.5d-226)) then
        tmp = x
    else if (z <= 1.8d-297) then
        tmp = y
    else if (z <= 9.5d-250) then
        tmp = x
    else if (z <= 1.7d-104) then
        tmp = y
    else if (z <= 5.4d-40) then
        tmp = x
    else if (z <= 0.00017d0) then
        tmp = y
    else if (z <= 5.9d+190) 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.22e+231) {
		tmp = y * z;
	} else if (z <= -2.2e+148) {
		tmp = x * z;
	} else if (z <= -9.5e+72) {
		tmp = y * z;
	} else if (z <= -29000000.0) {
		tmp = x * z;
	} else if (z <= -2.8e-37) {
		tmp = x;
	} else if (z <= -4.1e-113) {
		tmp = y;
	} else if (z <= -7.5e-226) {
		tmp = x;
	} else if (z <= 1.8e-297) {
		tmp = y;
	} else if (z <= 9.5e-250) {
		tmp = x;
	} else if (z <= 1.7e-104) {
		tmp = y;
	} else if (z <= 5.4e-40) {
		tmp = x;
	} else if (z <= 0.00017) {
		tmp = y;
	} else if (z <= 5.9e+190) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.22e+231:
		tmp = y * z
	elif z <= -2.2e+148:
		tmp = x * z
	elif z <= -9.5e+72:
		tmp = y * z
	elif z <= -29000000.0:
		tmp = x * z
	elif z <= -2.8e-37:
		tmp = x
	elif z <= -4.1e-113:
		tmp = y
	elif z <= -7.5e-226:
		tmp = x
	elif z <= 1.8e-297:
		tmp = y
	elif z <= 9.5e-250:
		tmp = x
	elif z <= 1.7e-104:
		tmp = y
	elif z <= 5.4e-40:
		tmp = x
	elif z <= 0.00017:
		tmp = y
	elif z <= 5.9e+190:
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.22e+231)
		tmp = Float64(y * z);
	elseif (z <= -2.2e+148)
		tmp = Float64(x * z);
	elseif (z <= -9.5e+72)
		tmp = Float64(y * z);
	elseif (z <= -29000000.0)
		tmp = Float64(x * z);
	elseif (z <= -2.8e-37)
		tmp = x;
	elseif (z <= -4.1e-113)
		tmp = y;
	elseif (z <= -7.5e-226)
		tmp = x;
	elseif (z <= 1.8e-297)
		tmp = y;
	elseif (z <= 9.5e-250)
		tmp = x;
	elseif (z <= 1.7e-104)
		tmp = y;
	elseif (z <= 5.4e-40)
		tmp = x;
	elseif (z <= 0.00017)
		tmp = y;
	elseif (z <= 5.9e+190)
		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.22e+231)
		tmp = y * z;
	elseif (z <= -2.2e+148)
		tmp = x * z;
	elseif (z <= -9.5e+72)
		tmp = y * z;
	elseif (z <= -29000000.0)
		tmp = x * z;
	elseif (z <= -2.8e-37)
		tmp = x;
	elseif (z <= -4.1e-113)
		tmp = y;
	elseif (z <= -7.5e-226)
		tmp = x;
	elseif (z <= 1.8e-297)
		tmp = y;
	elseif (z <= 9.5e-250)
		tmp = x;
	elseif (z <= 1.7e-104)
		tmp = y;
	elseif (z <= 5.4e-40)
		tmp = x;
	elseif (z <= 0.00017)
		tmp = y;
	elseif (z <= 5.9e+190)
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1.22e+231], N[(y * z), $MachinePrecision], If[LessEqual[z, -2.2e+148], N[(x * z), $MachinePrecision], If[LessEqual[z, -9.5e+72], N[(y * z), $MachinePrecision], If[LessEqual[z, -29000000.0], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.8e-37], x, If[LessEqual[z, -4.1e-113], y, If[LessEqual[z, -7.5e-226], x, If[LessEqual[z, 1.8e-297], y, If[LessEqual[z, 9.5e-250], x, If[LessEqual[z, 1.7e-104], y, If[LessEqual[z, 5.4e-40], x, If[LessEqual[z, 0.00017], y, If[LessEqual[z, 5.9e+190], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.2 \cdot 10^{+148}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -9.5 \cdot 10^{+72}:\\
\;\;\;\;y \cdot z\\

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

\mathbf{elif}\;z \leq -2.8 \cdot 10^{-37}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq -4.1 \cdot 10^{-113}:\\
\;\;\;\;y\\

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

\mathbf{elif}\;z \leq 1.8 \cdot 10^{-297}:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq 9.5 \cdot 10^{-250}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.7 \cdot 10^{-104}:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq 5.4 \cdot 10^{-40}:\\
\;\;\;\;x\\

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

\mathbf{elif}\;z \leq 5.9 \cdot 10^{+190}:\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.21999999999999998e231 or -2.1999999999999999e148 < z < -9.50000000000000054e72 or 5.89999999999999972e190 < 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 56.7%

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

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

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

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

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

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

    if -1.21999999999999998e231 < z < -2.1999999999999999e148 or -9.50000000000000054e72 < z < -2.9e7 or 1.7e-4 < z < 5.89999999999999972e190

    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 \color{blue}{\left(z + 1\right) \cdot \left(x + y\right)} \]
      2. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(z + 1\right) \cdot y + \left(z + 1\right) \cdot x} \]
      4. fma-def100.0%

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

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

      \[\leadsto \mathsf{fma}\left(z + 1, y, \color{blue}{x \cdot z}\right) \]
    6. Taylor expanded in y around 0 52.9%

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

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

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

    if -2.9e7 < z < -2.8000000000000001e-37 or -4.1e-113 < z < -7.50000000000000044e-226 or 1.79999999999999997e-297 < z < 9.5000000000000002e-250 or 1.70000000000000008e-104 < z < 5.4e-40

    1. Initial program 100.0%

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

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

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

    if -2.8000000000000001e-37 < z < -4.1e-113 or -7.50000000000000044e-226 < z < 1.79999999999999997e-297 or 9.5000000000000002e-250 < z < 1.70000000000000008e-104 or 5.4e-40 < z < 1.7e-4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.22 \cdot 10^{+231}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{+148}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{+72}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -29000000:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.8 \cdot 10^{-37}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4.1 \cdot 10^{-113}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq -7.5 \cdot 10^{-226}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-297}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-104}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{-40}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00017:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 5.9 \cdot 10^{+190}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 51.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.1 \cdot 10^{-7}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-113}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{-224}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-297}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 10^{-103}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 1.24 \cdot 10^{-39}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00017:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -4.1e-7)
   (* y z)
   (if (<= z -4.8e-113)
     y
     (if (<= z -1.4e-224)
       x
       (if (<= z 4.2e-297)
         y
         (if (<= z 6e-250)
           x
           (if (<= z 1e-103)
             y
             (if (<= z 1.24e-39) x (if (<= z 0.00017) y (* y z))))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.1e-7) {
		tmp = y * z;
	} else if (z <= -4.8e-113) {
		tmp = y;
	} else if (z <= -1.4e-224) {
		tmp = x;
	} else if (z <= 4.2e-297) {
		tmp = y;
	} else if (z <= 6e-250) {
		tmp = x;
	} else if (z <= 1e-103) {
		tmp = y;
	} else if (z <= 1.24e-39) {
		tmp = x;
	} else if (z <= 0.00017) {
		tmp = y;
	} 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 <= (-4.1d-7)) then
        tmp = y * z
    else if (z <= (-4.8d-113)) then
        tmp = y
    else if (z <= (-1.4d-224)) then
        tmp = x
    else if (z <= 4.2d-297) then
        tmp = y
    else if (z <= 6d-250) then
        tmp = x
    else if (z <= 1d-103) then
        tmp = y
    else if (z <= 1.24d-39) then
        tmp = x
    else if (z <= 0.00017d0) then
        tmp = y
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.1e-7) {
		tmp = y * z;
	} else if (z <= -4.8e-113) {
		tmp = y;
	} else if (z <= -1.4e-224) {
		tmp = x;
	} else if (z <= 4.2e-297) {
		tmp = y;
	} else if (z <= 6e-250) {
		tmp = x;
	} else if (z <= 1e-103) {
		tmp = y;
	} else if (z <= 1.24e-39) {
		tmp = x;
	} else if (z <= 0.00017) {
		tmp = y;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -4.1e-7:
		tmp = y * z
	elif z <= -4.8e-113:
		tmp = y
	elif z <= -1.4e-224:
		tmp = x
	elif z <= 4.2e-297:
		tmp = y
	elif z <= 6e-250:
		tmp = x
	elif z <= 1e-103:
		tmp = y
	elif z <= 1.24e-39:
		tmp = x
	elif z <= 0.00017:
		tmp = y
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -4.1e-7)
		tmp = Float64(y * z);
	elseif (z <= -4.8e-113)
		tmp = y;
	elseif (z <= -1.4e-224)
		tmp = x;
	elseif (z <= 4.2e-297)
		tmp = y;
	elseif (z <= 6e-250)
		tmp = x;
	elseif (z <= 1e-103)
		tmp = y;
	elseif (z <= 1.24e-39)
		tmp = x;
	elseif (z <= 0.00017)
		tmp = y;
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -4.1e-7)
		tmp = y * z;
	elseif (z <= -4.8e-113)
		tmp = y;
	elseif (z <= -1.4e-224)
		tmp = x;
	elseif (z <= 4.2e-297)
		tmp = y;
	elseif (z <= 6e-250)
		tmp = x;
	elseif (z <= 1e-103)
		tmp = y;
	elseif (z <= 1.24e-39)
		tmp = x;
	elseif (z <= 0.00017)
		tmp = y;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -4.1e-7], N[(y * z), $MachinePrecision], If[LessEqual[z, -4.8e-113], y, If[LessEqual[z, -1.4e-224], x, If[LessEqual[z, 4.2e-297], y, If[LessEqual[z, 6e-250], x, If[LessEqual[z, 1e-103], y, If[LessEqual[z, 1.24e-39], x, If[LessEqual[z, 0.00017], y, N[(y * z), $MachinePrecision]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -4.8 \cdot 10^{-113}:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq -1.4 \cdot 10^{-224}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 4.2 \cdot 10^{-297}:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq 6 \cdot 10^{-250}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 10^{-103}:\\
\;\;\;\;y\\

\mathbf{elif}\;z \leq 1.24 \cdot 10^{-39}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.0999999999999999e-7 or 1.7e-4 < 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 51.5%

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

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

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

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

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

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

    if -4.0999999999999999e-7 < z < -4.80000000000000024e-113 or -1.3999999999999999e-224 < z < 4.20000000000000027e-297 or 6.00000000000000032e-250 < z < 9.99999999999999958e-104 or 1.24000000000000004e-39 < z < 1.7e-4

    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 53.6%

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

    if -4.80000000000000024e-113 < z < -1.3999999999999999e-224 or 4.20000000000000027e-297 < z < 6.00000000000000032e-250 or 9.99999999999999958e-104 < z < 1.24000000000000004e-39

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.1 \cdot 10^{-7}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-113}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{-224}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-297}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-250}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 10^{-103}:\\ \;\;\;\;y\\ \mathbf{elif}\;z \leq 1.24 \cdot 10^{-39}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 0.00017:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.1% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{+231}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{+148}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -6 \cdot 10^{+72}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -98000000000000:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 550:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+191}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -2.5e+231)
   (* y z)
   (if (<= z -1.45e+148)
     (* x z)
     (if (<= z -6e+72)
       (* y z)
       (if (<= z -98000000000000.0)
         (* x z)
         (if (<= z -1.0)
           (* y z)
           (if (<= z 550.0) (+ x y) (if (<= z 2.2e+191) (* x z) (* y z)))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.5e+231) {
		tmp = y * z;
	} else if (z <= -1.45e+148) {
		tmp = x * z;
	} else if (z <= -6e+72) {
		tmp = y * z;
	} else if (z <= -98000000000000.0) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 550.0) {
		tmp = x + y;
	} else if (z <= 2.2e+191) {
		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 <= (-2.5d+231)) then
        tmp = y * z
    else if (z <= (-1.45d+148)) then
        tmp = x * z
    else if (z <= (-6d+72)) then
        tmp = y * z
    else if (z <= (-98000000000000.0d0)) then
        tmp = x * z
    else if (z <= (-1.0d0)) then
        tmp = y * z
    else if (z <= 550.0d0) then
        tmp = x + y
    else if (z <= 2.2d+191) 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 <= -2.5e+231) {
		tmp = y * z;
	} else if (z <= -1.45e+148) {
		tmp = x * z;
	} else if (z <= -6e+72) {
		tmp = y * z;
	} else if (z <= -98000000000000.0) {
		tmp = x * z;
	} else if (z <= -1.0) {
		tmp = y * z;
	} else if (z <= 550.0) {
		tmp = x + y;
	} else if (z <= 2.2e+191) {
		tmp = x * z;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -2.5e+231:
		tmp = y * z
	elif z <= -1.45e+148:
		tmp = x * z
	elif z <= -6e+72:
		tmp = y * z
	elif z <= -98000000000000.0:
		tmp = x * z
	elif z <= -1.0:
		tmp = y * z
	elif z <= 550.0:
		tmp = x + y
	elif z <= 2.2e+191:
		tmp = x * z
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -2.5e+231)
		tmp = Float64(y * z);
	elseif (z <= -1.45e+148)
		tmp = Float64(x * z);
	elseif (z <= -6e+72)
		tmp = Float64(y * z);
	elseif (z <= -98000000000000.0)
		tmp = Float64(x * z);
	elseif (z <= -1.0)
		tmp = Float64(y * z);
	elseif (z <= 550.0)
		tmp = Float64(x + y);
	elseif (z <= 2.2e+191)
		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 <= -2.5e+231)
		tmp = y * z;
	elseif (z <= -1.45e+148)
		tmp = x * z;
	elseif (z <= -6e+72)
		tmp = y * z;
	elseif (z <= -98000000000000.0)
		tmp = x * z;
	elseif (z <= -1.0)
		tmp = y * z;
	elseif (z <= 550.0)
		tmp = x + y;
	elseif (z <= 2.2e+191)
		tmp = x * z;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -2.5e+231], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.45e+148], N[(x * z), $MachinePrecision], If[LessEqual[z, -6e+72], N[(y * z), $MachinePrecision], If[LessEqual[z, -98000000000000.0], N[(x * z), $MachinePrecision], If[LessEqual[z, -1.0], N[(y * z), $MachinePrecision], If[LessEqual[z, 550.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 2.2e+191], N[(x * z), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -1.45 \cdot 10^{+148}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -6 \cdot 10^{+72}:\\
\;\;\;\;y \cdot z\\

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

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

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

\mathbf{elif}\;z \leq 2.2 \cdot 10^{+191}:\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.50000000000000014e231 or -1.45e148 < z < -6.00000000000000006e72 or -9.8e13 < z < -1 or 2.2e191 < 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 58.2%

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

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

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

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

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

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

    if -2.50000000000000014e231 < z < -1.45e148 or -6.00000000000000006e72 < z < -9.8e13 or 550 < z < 2.2e191

    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 \color{blue}{\left(z + 1\right) \cdot \left(x + y\right)} \]
      2. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(z + 1\right) \cdot y + \left(z + 1\right) \cdot x} \]
      4. fma-def100.0%

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

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

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

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

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

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

    if -1 < z < 550

    1. Initial program 100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{+231}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{+148}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -6 \cdot 10^{+72}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -98000000000000:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 550:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+191}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z + 1\right)\\ \mathbf{if}\;z \leq -6.5 \cdot 10^{+232}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{+148}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{+72}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-9}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-6}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 8.4 \cdot 10^{+190}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (+ z 1.0))))
   (if (<= z -6.5e+232)
     (* y z)
     (if (<= z -1.8e+148)
       (* x z)
       (if (<= z -4.6e+72)
         (* y z)
         (if (<= z -1.75e-9)
           t_0
           (if (<= z 3.2e-6) (+ x y) (if (<= z 8.4e+190) t_0 (* y z)))))))))
double code(double x, double y, double z) {
	double t_0 = x * (z + 1.0);
	double tmp;
	if (z <= -6.5e+232) {
		tmp = y * z;
	} else if (z <= -1.8e+148) {
		tmp = x * z;
	} else if (z <= -4.6e+72) {
		tmp = y * z;
	} else if (z <= -1.75e-9) {
		tmp = t_0;
	} else if (z <= 3.2e-6) {
		tmp = x + y;
	} else if (z <= 8.4e+190) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = x * (z + 1.0d0)
    if (z <= (-6.5d+232)) then
        tmp = y * z
    else if (z <= (-1.8d+148)) then
        tmp = x * z
    else if (z <= (-4.6d+72)) then
        tmp = y * z
    else if (z <= (-1.75d-9)) then
        tmp = t_0
    else if (z <= 3.2d-6) then
        tmp = x + y
    else if (z <= 8.4d+190) then
        tmp = t_0
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (z + 1.0);
	double tmp;
	if (z <= -6.5e+232) {
		tmp = y * z;
	} else if (z <= -1.8e+148) {
		tmp = x * z;
	} else if (z <= -4.6e+72) {
		tmp = y * z;
	} else if (z <= -1.75e-9) {
		tmp = t_0;
	} else if (z <= 3.2e-6) {
		tmp = x + y;
	} else if (z <= 8.4e+190) {
		tmp = t_0;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (z + 1.0)
	tmp = 0
	if z <= -6.5e+232:
		tmp = y * z
	elif z <= -1.8e+148:
		tmp = x * z
	elif z <= -4.6e+72:
		tmp = y * z
	elif z <= -1.75e-9:
		tmp = t_0
	elif z <= 3.2e-6:
		tmp = x + y
	elif z <= 8.4e+190:
		tmp = t_0
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(z + 1.0))
	tmp = 0.0
	if (z <= -6.5e+232)
		tmp = Float64(y * z);
	elseif (z <= -1.8e+148)
		tmp = Float64(x * z);
	elseif (z <= -4.6e+72)
		tmp = Float64(y * z);
	elseif (z <= -1.75e-9)
		tmp = t_0;
	elseif (z <= 3.2e-6)
		tmp = Float64(x + y);
	elseif (z <= 8.4e+190)
		tmp = t_0;
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (z + 1.0);
	tmp = 0.0;
	if (z <= -6.5e+232)
		tmp = y * z;
	elseif (z <= -1.8e+148)
		tmp = x * z;
	elseif (z <= -4.6e+72)
		tmp = y * z;
	elseif (z <= -1.75e-9)
		tmp = t_0;
	elseif (z <= 3.2e-6)
		tmp = x + y;
	elseif (z <= 8.4e+190)
		tmp = t_0;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.5e+232], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.8e+148], N[(x * z), $MachinePrecision], If[LessEqual[z, -4.6e+72], N[(y * z), $MachinePrecision], If[LessEqual[z, -1.75e-9], t$95$0, If[LessEqual[z, 3.2e-6], N[(x + y), $MachinePrecision], If[LessEqual[z, 8.4e+190], t$95$0, N[(y * z), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -1.8 \cdot 10^{+148}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -4.6 \cdot 10^{+72}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;z \leq -1.75 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;z \leq 8.4 \cdot 10^{+190}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -6.50000000000000016e232 or -1.80000000000000003e148 < z < -4.6e72 or 8.4000000000000003e190 < 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 56.7%

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

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

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

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

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

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

    if -6.50000000000000016e232 < z < -1.80000000000000003e148

    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 \color{blue}{\left(z + 1\right) \cdot \left(x + y\right)} \]
      2. +-commutative100.0%

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

        \[\leadsto \color{blue}{\left(z + 1\right) \cdot y + \left(z + 1\right) \cdot x} \]
      4. fma-def100.0%

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

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

      \[\leadsto \mathsf{fma}\left(z + 1, y, \color{blue}{x \cdot z}\right) \]
    6. Taylor expanded in y around 0 63.2%

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

        \[\leadsto \color{blue}{z \cdot x} \]
    8. Simplified63.2%

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

    if -4.6e72 < z < -1.75e-9 or 3.1999999999999999e-6 < z < 8.4000000000000003e190

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

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

    if -1.75e-9 < z < 3.1999999999999999e-6

    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} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification76.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.5 \cdot 10^{+232}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{+148}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{+72}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-6}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 8.4 \cdot 10^{+190}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.0% 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 97.2%

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

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

      \[\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 97.8%

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

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

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

    \[\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: 62.9% accurate, 0.7× speedup?

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

    1. Initial program 100.0%

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

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

    if 1.3599999999999999e-86 < 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 66.5%

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

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

Alternative 8: 32.2% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if 1.14999999999999999e-77 < y

    1. Initial program 99.9%

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

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

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

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

Alternative 9: 26.9% 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 53.8%

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification28.4%

    \[\leadsto x \]
  6. Add Preprocessing

Reproduce

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