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

Percentage Accurate: 100.0% → 100.0%
Time: 2.7s
Alternatives: 7
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 7 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: 75.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z + 1\right)\\ \mathbf{if}\;z \leq -6.1 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 27:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+142}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+197}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+234}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+264}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ z 1.0))))
   (if (<= z -6.1e-9)
     t_0
     (if (<= z 27.0)
       (+ x y)
       (if (<= z 2.5e+142)
         t_0
         (if (<= z 3.5e+197)
           (* x z)
           (if (<= z 9e+234) (* y z) (if (<= z 1.8e+264) (* x z) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = y * (z + 1.0);
	double tmp;
	if (z <= -6.1e-9) {
		tmp = t_0;
	} else if (z <= 27.0) {
		tmp = x + y;
	} else if (z <= 2.5e+142) {
		tmp = t_0;
	} else if (z <= 3.5e+197) {
		tmp = x * z;
	} else if (z <= 9e+234) {
		tmp = y * z;
	} else if (z <= 1.8e+264) {
		tmp = x * z;
	} else {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = y * (z + 1.0d0)
    if (z <= (-6.1d-9)) then
        tmp = t_0
    else if (z <= 27.0d0) then
        tmp = x + y
    else if (z <= 2.5d+142) then
        tmp = t_0
    else if (z <= 3.5d+197) then
        tmp = x * z
    else if (z <= 9d+234) then
        tmp = y * z
    else if (z <= 1.8d+264) then
        tmp = x * z
    else
        tmp = t_0
    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 <= -6.1e-9) {
		tmp = t_0;
	} else if (z <= 27.0) {
		tmp = x + y;
	} else if (z <= 2.5e+142) {
		tmp = t_0;
	} else if (z <= 3.5e+197) {
		tmp = x * z;
	} else if (z <= 9e+234) {
		tmp = y * z;
	} else if (z <= 1.8e+264) {
		tmp = x * z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z + 1.0)
	tmp = 0
	if z <= -6.1e-9:
		tmp = t_0
	elif z <= 27.0:
		tmp = x + y
	elif z <= 2.5e+142:
		tmp = t_0
	elif z <= 3.5e+197:
		tmp = x * z
	elif z <= 9e+234:
		tmp = y * z
	elif z <= 1.8e+264:
		tmp = x * z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z + 1.0))
	tmp = 0.0
	if (z <= -6.1e-9)
		tmp = t_0;
	elseif (z <= 27.0)
		tmp = Float64(x + y);
	elseif (z <= 2.5e+142)
		tmp = t_0;
	elseif (z <= 3.5e+197)
		tmp = Float64(x * z);
	elseif (z <= 9e+234)
		tmp = Float64(y * z);
	elseif (z <= 1.8e+264)
		tmp = Float64(x * z);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (z + 1.0);
	tmp = 0.0;
	if (z <= -6.1e-9)
		tmp = t_0;
	elseif (z <= 27.0)
		tmp = x + y;
	elseif (z <= 2.5e+142)
		tmp = t_0;
	elseif (z <= 3.5e+197)
		tmp = x * z;
	elseif (z <= 9e+234)
		tmp = y * z;
	elseif (z <= 1.8e+264)
		tmp = x * z;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.1e-9], t$95$0, If[LessEqual[z, 27.0], N[(x + y), $MachinePrecision], If[LessEqual[z, 2.5e+142], t$95$0, If[LessEqual[z, 3.5e+197], N[(x * z), $MachinePrecision], If[LessEqual[z, 9e+234], N[(y * z), $MachinePrecision], If[LessEqual[z, 1.8e+264], N[(x * z), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq 2.5 \cdot 10^{+142}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+197}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq 9 \cdot 10^{+234}:\\
\;\;\;\;y \cdot z\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -6.1e-9 or 27 < z < 2.5000000000000001e142 or 1.80000000000000006e264 < z

    1. Initial program 100.0%

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

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

    if -6.1e-9 < z < 27

    1. Initial program 100.0%

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

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

    if 2.5000000000000001e142 < z < 3.49999999999999999e197 or 8.99999999999999963e234 < z < 1.80000000000000006e264

    1. Initial program 100.0%

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

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

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

    if 3.49999999999999999e197 < z < 8.99999999999999963e234

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.1 \cdot 10^{-9}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \mathbf{elif}\;z \leq 27:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+142}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+197}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+234}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{+264}:\\ \;\;\;\;x \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \end{array} \]

Alternative 3: 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 96.9%

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

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

    \[\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 4: 74.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;y \cdot z\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 45 < z

    1. Initial program 100.0%

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

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

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

    if -1 < z < 45

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 45:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 5: 63.4% accurate, 1.0× speedup?

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

    1. Initial program 100.0%

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

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

    if -1.1499999999999999e-71 < x

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.15 \cdot 10^{-71}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z + 1\right)\\ \end{array} \]

Alternative 6: 34.0% accurate, 1.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

    if -1.0600000000000001e-57 < x

    1. Initial program 100.0%

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

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

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

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

Alternative 7: 28.1% accurate, 2.3× speedup?

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

\\
y \cdot z
\end{array}
Derivation
  1. Initial program 100.0%

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

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

    \[\leadsto \color{blue}{y \cdot z} \]
  4. Final simplification25.4%

    \[\leadsto y \cdot z \]

Reproduce

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