Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4

Percentage Accurate: 99.9% → 100.0%
Time: 3.9s
Alternatives: 9
Speedup: 1.2×

Specification

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

\\
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x
\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: 99.9% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.1× speedup?

\[\begin{array}{l} \\ z + \mathsf{fma}\left(x, 3, 2 \cdot y\right) \end{array} \]
(FPCore (x y z) :precision binary64 (+ z (fma x 3.0 (* 2.0 y))))
double code(double x, double y, double z) {
	return z + fma(x, 3.0, (2.0 * y));
}
function code(x, y, z)
	return Float64(z + fma(x, 3.0, Float64(2.0 * y)))
end
code[x_, y_, z_] := N[(z + N[(x * 3.0 + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
z + \mathsf{fma}\left(x, 3, 2 \cdot y\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
  2. Step-by-step derivation
    1. +-commutative99.9%

      \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
    2. associate-+l+99.9%

      \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
    3. remove-double-neg99.9%

      \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
    4. distribute-neg-in99.9%

      \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
    5. distribute-neg-in99.9%

      \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
    6. remove-double-neg99.9%

      \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
    7. sub-neg99.9%

      \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
    8. +-commutative99.9%

      \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
    9. +-commutative99.9%

      \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
    10. associate-+r+99.9%

      \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
    11. associate-+r+99.9%

      \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
    12. associate--l+99.9%

      \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
    13. count-299.9%

      \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
    14. *-commutative99.9%

      \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
    15. fma-def99.9%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
    16. count-299.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
    17. neg-mul-199.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
    18. distribute-rgt-out--99.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
    19. metadata-eval99.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
  4. Taylor expanded in y around 0 99.9%

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

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

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

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

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, y \cdot 2\right)} \]
    5. *-commutative100.0%

      \[\leadsto z + \mathsf{fma}\left(x, 3, \color{blue}{2 \cdot y}\right) \]
  6. Simplified100.0%

    \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, 2 \cdot y\right)} \]
  7. Final simplification100.0%

    \[\leadsto z + \mathsf{fma}\left(x, 3, 2 \cdot y\right) \]

Alternative 2: 50.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+103}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-63}:\\ \;\;\;\;x \cdot 3\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{-269}:\\ \;\;\;\;2 \cdot y\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-103}:\\ \;\;\;\;x \cdot 3\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{+79}:\\ \;\;\;\;2 \cdot y\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+126}:\\ \;\;\;\;x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -7.8e+103)
   z
   (if (<= z -2.25e-63)
     (* x 3.0)
     (if (<= z -2.9e-269)
       (* 2.0 y)
       (if (<= z 2.1e-103)
         (* x 3.0)
         (if (<= z 8.8e+79) (* 2.0 y) (if (<= z 5.2e+126) (* x 3.0) z)))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.8e+103) {
		tmp = z;
	} else if (z <= -2.25e-63) {
		tmp = x * 3.0;
	} else if (z <= -2.9e-269) {
		tmp = 2.0 * y;
	} else if (z <= 2.1e-103) {
		tmp = x * 3.0;
	} else if (z <= 8.8e+79) {
		tmp = 2.0 * y;
	} else if (z <= 5.2e+126) {
		tmp = x * 3.0;
	} else {
		tmp = 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+103)) then
        tmp = z
    else if (z <= (-2.25d-63)) then
        tmp = x * 3.0d0
    else if (z <= (-2.9d-269)) then
        tmp = 2.0d0 * y
    else if (z <= 2.1d-103) then
        tmp = x * 3.0d0
    else if (z <= 8.8d+79) then
        tmp = 2.0d0 * y
    else if (z <= 5.2d+126) then
        tmp = x * 3.0d0
    else
        tmp = z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.8e+103) {
		tmp = z;
	} else if (z <= -2.25e-63) {
		tmp = x * 3.0;
	} else if (z <= -2.9e-269) {
		tmp = 2.0 * y;
	} else if (z <= 2.1e-103) {
		tmp = x * 3.0;
	} else if (z <= 8.8e+79) {
		tmp = 2.0 * y;
	} else if (z <= 5.2e+126) {
		tmp = x * 3.0;
	} else {
		tmp = z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -7.8e+103:
		tmp = z
	elif z <= -2.25e-63:
		tmp = x * 3.0
	elif z <= -2.9e-269:
		tmp = 2.0 * y
	elif z <= 2.1e-103:
		tmp = x * 3.0
	elif z <= 8.8e+79:
		tmp = 2.0 * y
	elif z <= 5.2e+126:
		tmp = x * 3.0
	else:
		tmp = z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -7.8e+103)
		tmp = z;
	elseif (z <= -2.25e-63)
		tmp = Float64(x * 3.0);
	elseif (z <= -2.9e-269)
		tmp = Float64(2.0 * y);
	elseif (z <= 2.1e-103)
		tmp = Float64(x * 3.0);
	elseif (z <= 8.8e+79)
		tmp = Float64(2.0 * y);
	elseif (z <= 5.2e+126)
		tmp = Float64(x * 3.0);
	else
		tmp = z;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -7.8e+103)
		tmp = z;
	elseif (z <= -2.25e-63)
		tmp = x * 3.0;
	elseif (z <= -2.9e-269)
		tmp = 2.0 * y;
	elseif (z <= 2.1e-103)
		tmp = x * 3.0;
	elseif (z <= 8.8e+79)
		tmp = 2.0 * y;
	elseif (z <= 5.2e+126)
		tmp = x * 3.0;
	else
		tmp = z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -7.8e+103], z, If[LessEqual[z, -2.25e-63], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, -2.9e-269], N[(2.0 * y), $MachinePrecision], If[LessEqual[z, 2.1e-103], N[(x * 3.0), $MachinePrecision], If[LessEqual[z, 8.8e+79], N[(2.0 * y), $MachinePrecision], If[LessEqual[z, 5.2e+126], N[(x * 3.0), $MachinePrecision], z]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.25 \cdot 10^{-63}:\\
\;\;\;\;x \cdot 3\\

\mathbf{elif}\;z \leq -2.9 \cdot 10^{-269}:\\
\;\;\;\;2 \cdot y\\

\mathbf{elif}\;z \leq 2.1 \cdot 10^{-103}:\\
\;\;\;\;x \cdot 3\\

\mathbf{elif}\;z \leq 8.8 \cdot 10^{+79}:\\
\;\;\;\;2 \cdot y\\

\mathbf{elif}\;z \leq 5.2 \cdot 10^{+126}:\\
\;\;\;\;x \cdot 3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.7999999999999997e103 or 5.1999999999999999e126 < z

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+100.0%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg100.0%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in100.0%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in100.0%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg100.0%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+100.0%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-2100.0%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative100.0%

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-2100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-1100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in z around inf 80.6%

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

    if -7.7999999999999997e103 < z < -2.25e-63 or -2.9000000000000001e-269 < z < 2.10000000000000005e-103 or 8.7999999999999996e79 < z < 5.1999999999999999e126

    1. Initial program 99.8%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.8%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.8%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.8%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.8%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.8%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.8%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.8%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.8%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.8%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.8%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 99.8%

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

        \[\leadsto z + \color{blue}{\left(3 \cdot x + 2 \cdot y\right)} \]
      2. *-commutative99.8%

        \[\leadsto z + \left(\color{blue}{x \cdot 3} + 2 \cdot y\right) \]
      3. *-commutative99.8%

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, y \cdot 2\right)} \]
      5. *-commutative100.0%

        \[\leadsto z + \mathsf{fma}\left(x, 3, \color{blue}{2 \cdot y}\right) \]
    6. Simplified100.0%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, 2 \cdot y\right)} \]
    7. Taylor expanded in x around inf 56.9%

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

    if -2.25e-63 < z < -2.9000000000000001e-269 or 2.10000000000000005e-103 < z < 8.7999999999999996e79

    1. Initial program 99.9%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.9%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.9%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.9%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.9%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.9%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.9%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.9%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.9%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.9%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 99.9%

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

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

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

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, y \cdot 2\right)} \]
      5. *-commutative100.0%

        \[\leadsto z + \mathsf{fma}\left(x, 3, \color{blue}{2 \cdot y}\right) \]
    6. Simplified100.0%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, 2 \cdot y\right)} \]
    7. Taylor expanded in y around inf 59.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+103}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-63}:\\ \;\;\;\;x \cdot 3\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{-269}:\\ \;\;\;\;2 \cdot y\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-103}:\\ \;\;\;\;x \cdot 3\\ \mathbf{elif}\;z \leq 8.8 \cdot 10^{+79}:\\ \;\;\;\;2 \cdot y\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+126}:\\ \;\;\;\;x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]

Alternative 3: 84.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.06 \cdot 10^{+102}:\\ \;\;\;\;z + 2 \cdot y\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+69}:\\ \;\;\;\;x + 2 \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 3\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -2.06e+102)
   (+ z (* 2.0 y))
   (if (<= z 1.9e+69) (+ x (* 2.0 (+ x y))) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.06e+102) {
		tmp = z + (2.0 * y);
	} else if (z <= 1.9e+69) {
		tmp = x + (2.0 * (x + y));
	} else {
		tmp = z + (x * 3.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 (z <= (-2.06d+102)) then
        tmp = z + (2.0d0 * y)
    else if (z <= 1.9d+69) then
        tmp = x + (2.0d0 * (x + y))
    else
        tmp = z + (x * 3.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.06e+102) {
		tmp = z + (2.0 * y);
	} else if (z <= 1.9e+69) {
		tmp = x + (2.0 * (x + y));
	} else {
		tmp = z + (x * 3.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -2.06e+102:
		tmp = z + (2.0 * y)
	elif z <= 1.9e+69:
		tmp = x + (2.0 * (x + y))
	else:
		tmp = z + (x * 3.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -2.06e+102)
		tmp = Float64(z + Float64(2.0 * y));
	elseif (z <= 1.9e+69)
		tmp = Float64(x + Float64(2.0 * Float64(x + y)));
	else
		tmp = Float64(z + Float64(x * 3.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -2.06e+102)
		tmp = z + (2.0 * y);
	elseif (z <= 1.9e+69)
		tmp = x + (2.0 * (x + y));
	else
		tmp = z + (x * 3.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -2.06e+102], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.9e+69], N[(x + N[(2.0 * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.06 \cdot 10^{+102}:\\
\;\;\;\;z + 2 \cdot y\\

\mathbf{elif}\;z \leq 1.9 \cdot 10^{+69}:\\
\;\;\;\;x + 2 \cdot \left(x + y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.05999999999999999e102

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+100.0%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg100.0%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in100.0%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in100.0%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg100.0%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+100.0%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-2100.0%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative100.0%

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-2100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-1100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around inf 93.3%

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

    if -2.05999999999999999e102 < z < 1.90000000000000014e69

    1. Initial program 99.8%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. associate-+l+99.8%

        \[\leadsto \color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right) + \left(z + x\right)} \]
      2. +-commutative99.8%

        \[\leadsto \left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) + \left(z + x\right) \]
      3. associate-+r+99.8%

        \[\leadsto \color{blue}{\left(\left(y + x\right) + \left(y + x\right)\right)} + \left(z + x\right) \]
      4. count-299.8%

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

        \[\leadsto 2 \cdot \color{blue}{\left(x + y\right)} + \left(z + x\right) \]
      6. +-commutative99.8%

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

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

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

    if 1.90000000000000014e69 < z

    1. Initial program 99.9%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.9%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.9%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.9%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.9%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.9%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.9%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.9%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.9%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.9%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 93.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.06 \cdot 10^{+102}:\\ \;\;\;\;z + 2 \cdot y\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+69}:\\ \;\;\;\;x + 2 \cdot \left(x + y\right)\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 3\\ \end{array} \]

Alternative 4: 84.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+103}:\\ \;\;\;\;z + 2 \cdot y\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+64}:\\ \;\;\;\;2 \cdot y + x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 3\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -7.5e+103)
   (+ z (* 2.0 y))
   (if (<= z 6.5e+64) (+ (* 2.0 y) (* x 3.0)) (+ z (* x 3.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.5e+103) {
		tmp = z + (2.0 * y);
	} else if (z <= 6.5e+64) {
		tmp = (2.0 * y) + (x * 3.0);
	} else {
		tmp = z + (x * 3.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 (z <= (-7.5d+103)) then
        tmp = z + (2.0d0 * y)
    else if (z <= 6.5d+64) then
        tmp = (2.0d0 * y) + (x * 3.0d0)
    else
        tmp = z + (x * 3.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.5e+103) {
		tmp = z + (2.0 * y);
	} else if (z <= 6.5e+64) {
		tmp = (2.0 * y) + (x * 3.0);
	} else {
		tmp = z + (x * 3.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -7.5e+103:
		tmp = z + (2.0 * y)
	elif z <= 6.5e+64:
		tmp = (2.0 * y) + (x * 3.0)
	else:
		tmp = z + (x * 3.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -7.5e+103)
		tmp = Float64(z + Float64(2.0 * y));
	elseif (z <= 6.5e+64)
		tmp = Float64(Float64(2.0 * y) + Float64(x * 3.0));
	else
		tmp = Float64(z + Float64(x * 3.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -7.5e+103)
		tmp = z + (2.0 * y);
	elseif (z <= 6.5e+64)
		tmp = (2.0 * y) + (x * 3.0);
	else
		tmp = z + (x * 3.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -7.5e+103], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+64], N[(N[(2.0 * y), $MachinePrecision] + N[(x * 3.0), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+103}:\\
\;\;\;\;z + 2 \cdot y\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{+64}:\\
\;\;\;\;2 \cdot y + x \cdot 3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.49999999999999922e103

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+100.0%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg100.0%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in100.0%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in100.0%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg100.0%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+100.0%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-2100.0%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative100.0%

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-2100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-1100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around inf 93.3%

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

    if -7.49999999999999922e103 < z < 6.50000000000000007e64

    1. Initial program 99.8%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.8%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.8%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.8%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.8%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.8%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.8%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.9%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.9%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.9%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 99.9%

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

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

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

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, y \cdot 2\right)} \]
      5. *-commutative100.0%

        \[\leadsto z + \mathsf{fma}\left(x, 3, \color{blue}{2 \cdot y}\right) \]
    6. Simplified100.0%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, 2 \cdot y\right)} \]
    7. Taylor expanded in z around 0 89.1%

      \[\leadsto \color{blue}{2 \cdot y + 3 \cdot x} \]

    if 6.50000000000000007e64 < z

    1. Initial program 99.9%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.9%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.9%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.9%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.9%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.9%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.9%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.9%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.9%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.9%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 93.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+103}:\\ \;\;\;\;z + 2 \cdot y\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+64}:\\ \;\;\;\;2 \cdot y + x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 3\\ \end{array} \]

Alternative 5: 79.6% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.28 \cdot 10^{+82} \lor \neg \left(x \leq 7.2 \cdot 10^{+168}\right):\\ \;\;\;\;x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;z + 2 \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.28e+82) (not (<= x 7.2e+168))) (* x 3.0) (+ z (* 2.0 y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.28e+82) || !(x <= 7.2e+168)) {
		tmp = x * 3.0;
	} else {
		tmp = z + (2.0 * 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.28d+82)) .or. (.not. (x <= 7.2d+168))) then
        tmp = x * 3.0d0
    else
        tmp = z + (2.0d0 * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.28e+82) || !(x <= 7.2e+168)) {
		tmp = x * 3.0;
	} else {
		tmp = z + (2.0 * y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -1.28e+82) or not (x <= 7.2e+168):
		tmp = x * 3.0
	else:
		tmp = z + (2.0 * y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.28e+82) || !(x <= 7.2e+168))
		tmp = Float64(x * 3.0);
	else
		tmp = Float64(z + Float64(2.0 * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.28e+82) || ~((x <= 7.2e+168)))
		tmp = x * 3.0;
	else
		tmp = z + (2.0 * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.28e+82], N[Not[LessEqual[x, 7.2e+168]], $MachinePrecision]], N[(x * 3.0), $MachinePrecision], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.28 \cdot 10^{+82} \lor \neg \left(x \leq 7.2 \cdot 10^{+168}\right):\\
\;\;\;\;x \cdot 3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.28e82 or 7.1999999999999999e168 < x

    1. Initial program 99.8%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.8%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.8%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.8%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.8%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.8%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.8%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.7%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.8%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.8%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.8%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.8%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.8%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.8%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 99.8%

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

        \[\leadsto z + \color{blue}{\left(3 \cdot x + 2 \cdot y\right)} \]
      2. *-commutative99.8%

        \[\leadsto z + \left(\color{blue}{x \cdot 3} + 2 \cdot y\right) \]
      3. *-commutative99.8%

        \[\leadsto z + \left(x \cdot 3 + \color{blue}{y \cdot 2}\right) \]
      4. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, y \cdot 2\right)} \]
      5. *-commutative99.9%

        \[\leadsto z + \mathsf{fma}\left(x, 3, \color{blue}{2 \cdot y}\right) \]
    6. Simplified99.9%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, 2 \cdot y\right)} \]
    7. Taylor expanded in x around inf 68.9%

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

    if -1.28e82 < x < 7.1999999999999999e168

    1. Initial program 99.9%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.9%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.9%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.9%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.9%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.9%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.9%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+100.0%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-2100.0%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative100.0%

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-2100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-1100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around inf 84.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.28 \cdot 10^{+82} \lor \neg \left(x \leq 7.2 \cdot 10^{+168}\right):\\ \;\;\;\;x \cdot 3\\ \mathbf{else}:\\ \;\;\;\;z + 2 \cdot y\\ \end{array} \]

Alternative 6: 83.6% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+152} \lor \neg \left(y \leq 1.7 \cdot 10^{+73}\right):\\ \;\;\;\;z + 2 \cdot y\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 3\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -5.2e+152) (not (<= y 1.7e+73)))
   (+ z (* 2.0 y))
   (+ z (* x 3.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5.2e+152) || !(y <= 1.7e+73)) {
		tmp = z + (2.0 * y);
	} else {
		tmp = z + (x * 3.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 <= (-5.2d+152)) .or. (.not. (y <= 1.7d+73))) then
        tmp = z + (2.0d0 * y)
    else
        tmp = z + (x * 3.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5.2e+152) || !(y <= 1.7e+73)) {
		tmp = z + (2.0 * y);
	} else {
		tmp = z + (x * 3.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -5.2e+152) or not (y <= 1.7e+73):
		tmp = z + (2.0 * y)
	else:
		tmp = z + (x * 3.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -5.2e+152) || !(y <= 1.7e+73))
		tmp = Float64(z + Float64(2.0 * y));
	else
		tmp = Float64(z + Float64(x * 3.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -5.2e+152) || ~((y <= 1.7e+73)))
		tmp = z + (2.0 * y);
	else
		tmp = z + (x * 3.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.2e+152], N[Not[LessEqual[y, 1.7e+73]], $MachinePrecision]], N[(z + N[(2.0 * y), $MachinePrecision]), $MachinePrecision], N[(z + N[(x * 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+152} \lor \neg \left(y \leq 1.7 \cdot 10^{+73}\right):\\
\;\;\;\;z + 2 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.2000000000000001e152 or 1.7000000000000001e73 < y

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+100.0%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg100.0%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in100.0%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in100.0%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg100.0%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.9%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.9%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.9%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.9%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around inf 86.0%

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

    if -5.2000000000000001e152 < y < 1.7000000000000001e73

    1. Initial program 99.8%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.8%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.8%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.8%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.8%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.8%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.8%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.9%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.9%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.9%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.9%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 87.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+152} \lor \neg \left(y \leq 1.7 \cdot 10^{+73}\right):\\ \;\;\;\;z + 2 \cdot y\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot 3\\ \end{array} \]

Alternative 7: 99.9% accurate, 1.2× speedup?

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

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

    \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
  2. Step-by-step derivation
    1. +-commutative99.9%

      \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
    2. associate-+l+99.9%

      \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
    3. remove-double-neg99.9%

      \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
    4. distribute-neg-in99.9%

      \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
    5. distribute-neg-in99.9%

      \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
    6. remove-double-neg99.9%

      \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
    7. sub-neg99.9%

      \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
    8. +-commutative99.9%

      \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
    9. +-commutative99.9%

      \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
    10. associate-+r+99.9%

      \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
    11. associate-+r+99.9%

      \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
    12. associate--l+99.9%

      \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
    13. count-299.9%

      \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
    14. *-commutative99.9%

      \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
    15. fma-def99.9%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
    16. count-299.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
    17. neg-mul-199.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
    18. distribute-rgt-out--99.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
    19. metadata-eval99.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
  4. Step-by-step derivation
    1. fma-udef99.9%

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

    \[\leadsto z + \color{blue}{\left(y \cdot 2 + x \cdot 3\right)} \]
  6. Final simplification99.9%

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

Alternative 8: 51.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+101}:\\
\;\;\;\;z\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{+66}:\\
\;\;\;\;2 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.2e101 or 1.55000000000000009e66 < z

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+100.0%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg100.0%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in100.0%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in100.0%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg100.0%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative100.0%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+100.0%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+100.0%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+100.0%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-2100.0%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative100.0%

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-2100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-1100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval100.0%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in z around inf 75.1%

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

    if -4.2e101 < z < 1.55000000000000009e66

    1. Initial program 99.8%

      \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
    2. Step-by-step derivation
      1. +-commutative99.8%

        \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
      2. associate-+l+99.8%

        \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
      3. remove-double-neg99.8%

        \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
      4. distribute-neg-in99.8%

        \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
      5. distribute-neg-in99.8%

        \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
      6. remove-double-neg99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
      7. sub-neg99.8%

        \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
      8. +-commutative99.8%

        \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
      9. +-commutative99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
      10. associate-+r+99.8%

        \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
      11. associate-+r+99.8%

        \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
      12. associate--l+99.9%

        \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
      13. count-299.9%

        \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      14. *-commutative99.9%

        \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
      15. fma-def99.9%

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
      16. count-299.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
      17. neg-mul-199.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
      18. distribute-rgt-out--99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
      19. metadata-eval99.9%

        \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
    4. Taylor expanded in y around 0 99.9%

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

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

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

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

        \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, y \cdot 2\right)} \]
      5. *-commutative100.0%

        \[\leadsto z + \mathsf{fma}\left(x, 3, \color{blue}{2 \cdot y}\right) \]
    6. Simplified100.0%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(x, 3, 2 \cdot y\right)} \]
    7. Taylor expanded in y around inf 47.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+101}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{+66}:\\ \;\;\;\;2 \cdot y\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]

Alternative 9: 34.0% accurate, 11.0× speedup?

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

\\
z
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
  2. Step-by-step derivation
    1. +-commutative99.9%

      \[\leadsto \color{blue}{\left(z + \left(\left(\left(x + y\right) + y\right) + x\right)\right)} + x \]
    2. associate-+l+99.9%

      \[\leadsto \color{blue}{z + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)} \]
    3. remove-double-neg99.9%

      \[\leadsto z + \color{blue}{\left(-\left(-\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right)\right)\right)} \]
    4. distribute-neg-in99.9%

      \[\leadsto z + \left(-\color{blue}{\left(\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right) + \left(-x\right)\right)}\right) \]
    5. distribute-neg-in99.9%

      \[\leadsto z + \color{blue}{\left(\left(-\left(-\left(\left(\left(x + y\right) + y\right) + x\right)\right)\right) + \left(-\left(-x\right)\right)\right)} \]
    6. remove-double-neg99.9%

      \[\leadsto z + \left(\color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right)} + \left(-\left(-x\right)\right)\right) \]
    7. sub-neg99.9%

      \[\leadsto z + \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(-x\right)\right)} \]
    8. +-commutative99.9%

      \[\leadsto z + \left(\left(\left(\color{blue}{\left(y + x\right)} + y\right) + x\right) - \left(-x\right)\right) \]
    9. +-commutative99.9%

      \[\leadsto z + \left(\left(\color{blue}{\left(y + \left(y + x\right)\right)} + x\right) - \left(-x\right)\right) \]
    10. associate-+r+99.9%

      \[\leadsto z + \left(\left(\color{blue}{\left(\left(y + y\right) + x\right)} + x\right) - \left(-x\right)\right) \]
    11. associate-+r+99.9%

      \[\leadsto z + \left(\color{blue}{\left(\left(y + y\right) + \left(x + x\right)\right)} - \left(-x\right)\right) \]
    12. associate--l+99.9%

      \[\leadsto z + \color{blue}{\left(\left(y + y\right) + \left(\left(x + x\right) - \left(-x\right)\right)\right)} \]
    13. count-299.9%

      \[\leadsto z + \left(\color{blue}{2 \cdot y} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
    14. *-commutative99.9%

      \[\leadsto z + \left(\color{blue}{y \cdot 2} + \left(\left(x + x\right) - \left(-x\right)\right)\right) \]
    15. fma-def99.9%

      \[\leadsto z + \color{blue}{\mathsf{fma}\left(y, 2, \left(x + x\right) - \left(-x\right)\right)} \]
    16. count-299.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{2 \cdot x} - \left(-x\right)\right) \]
    17. neg-mul-199.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, 2 \cdot x - \color{blue}{-1 \cdot x}\right) \]
    18. distribute-rgt-out--99.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, \color{blue}{x \cdot \left(2 - -1\right)}\right) \]
    19. metadata-eval99.9%

      \[\leadsto z + \mathsf{fma}\left(y, 2, x \cdot \color{blue}{3}\right) \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{z + \mathsf{fma}\left(y, 2, x \cdot 3\right)} \]
  4. Taylor expanded in z around inf 37.0%

    \[\leadsto \color{blue}{z} \]
  5. Final simplification37.0%

    \[\leadsto z \]

Reproduce

?
herbie shell --seed 2023312 
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
  :precision binary64
  (+ (+ (+ (+ (+ x y) y) x) z) x))