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

Percentage Accurate: 99.9% → 99.9%
Time: 9.6s
Alternatives: 12
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 12 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: 99.9% accurate, 0.1× speedup?

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

\\
y + \left(z + \mathsf{fma}\left(3, x, y\right)\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. associate-+l+99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{y + \left(z + \mathsf{fma}\left(3, x, y\right)\right)} \]
  4. Final simplification99.9%

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

Alternative 2: 56.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y + 3 \cdot x\\ \mathbf{if}\;x \leq -3.8 \cdot 10^{+38}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-193}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-236}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-176}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+42}:\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ y (* 3.0 x))))
   (if (<= x -3.8e+38)
     t_0
     (if (<= x -1.05e-193)
       (+ y z)
       (if (<= x -8.5e-236)
         (+ y y)
         (if (<= x 5.4e-176) (+ y z) (if (<= x 1.1e+42) (+ y y) t_0)))))))
double code(double x, double y, double z) {
	double t_0 = y + (3.0 * x);
	double tmp;
	if (x <= -3.8e+38) {
		tmp = t_0;
	} else if (x <= -1.05e-193) {
		tmp = y + z;
	} else if (x <= -8.5e-236) {
		tmp = y + y;
	} else if (x <= 5.4e-176) {
		tmp = y + z;
	} else if (x <= 1.1e+42) {
		tmp = y + y;
	} 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 + (3.0d0 * x)
    if (x <= (-3.8d+38)) then
        tmp = t_0
    else if (x <= (-1.05d-193)) then
        tmp = y + z
    else if (x <= (-8.5d-236)) then
        tmp = y + y
    else if (x <= 5.4d-176) then
        tmp = y + z
    else if (x <= 1.1d+42) then
        tmp = y + y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y + (3.0 * x);
	double tmp;
	if (x <= -3.8e+38) {
		tmp = t_0;
	} else if (x <= -1.05e-193) {
		tmp = y + z;
	} else if (x <= -8.5e-236) {
		tmp = y + y;
	} else if (x <= 5.4e-176) {
		tmp = y + z;
	} else if (x <= 1.1e+42) {
		tmp = y + y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y + (3.0 * x)
	tmp = 0
	if x <= -3.8e+38:
		tmp = t_0
	elif x <= -1.05e-193:
		tmp = y + z
	elif x <= -8.5e-236:
		tmp = y + y
	elif x <= 5.4e-176:
		tmp = y + z
	elif x <= 1.1e+42:
		tmp = y + y
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y + Float64(3.0 * x))
	tmp = 0.0
	if (x <= -3.8e+38)
		tmp = t_0;
	elseif (x <= -1.05e-193)
		tmp = Float64(y + z);
	elseif (x <= -8.5e-236)
		tmp = Float64(y + y);
	elseif (x <= 5.4e-176)
		tmp = Float64(y + z);
	elseif (x <= 1.1e+42)
		tmp = Float64(y + y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y + (3.0 * x);
	tmp = 0.0;
	if (x <= -3.8e+38)
		tmp = t_0;
	elseif (x <= -1.05e-193)
		tmp = y + z;
	elseif (x <= -8.5e-236)
		tmp = y + y;
	elseif (x <= 5.4e-176)
		tmp = y + z;
	elseif (x <= 1.1e+42)
		tmp = y + y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(3.0 * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.8e+38], t$95$0, If[LessEqual[x, -1.05e-193], N[(y + z), $MachinePrecision], If[LessEqual[x, -8.5e-236], N[(y + y), $MachinePrecision], If[LessEqual[x, 5.4e-176], N[(y + z), $MachinePrecision], If[LessEqual[x, 1.1e+42], N[(y + y), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y + 3 \cdot x\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{+38}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq -8.5 \cdot 10^{-236}:\\
\;\;\;\;y + y\\

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

\mathbf{elif}\;x \leq 1.1 \cdot 10^{+42}:\\
\;\;\;\;y + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.7999999999999998e38 or 1.1000000000000001e42 < 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. associate-+l+99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.7999999999999998e38 < x < -1.05e-193 or -8.49999999999999929e-236 < x < 5.3999999999999997e-176

    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. associate-+l+100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
    6. Simplified68.7%

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

      \[\leadsto \color{blue}{y + z} \]
    8. Step-by-step derivation
      1. +-commutative64.3%

        \[\leadsto \color{blue}{z + y} \]
    9. Simplified64.3%

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

    if -1.05e-193 < x < -8.49999999999999929e-236 or 5.3999999999999997e-176 < x < 1.1000000000000001e42

    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. associate-+l+100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{+38}:\\ \;\;\;\;y + 3 \cdot x\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-193}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-236}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-176}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+42}:\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;y + 3 \cdot x\\ \end{array} \]

Alternative 3: 55.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{+38}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{-190}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-238}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-177}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+109}:\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.25e+38)
   (* 3.0 x)
   (if (<= x -1.6e-190)
     (+ y z)
     (if (<= x -9.5e-238)
       (+ y y)
       (if (<= x 1.8e-177) (+ y z) (if (<= x 1.75e+109) (+ y y) (* 3.0 x)))))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.25e+38) {
		tmp = 3.0 * x;
	} else if (x <= -1.6e-190) {
		tmp = y + z;
	} else if (x <= -9.5e-238) {
		tmp = y + y;
	} else if (x <= 1.8e-177) {
		tmp = y + z;
	} else if (x <= 1.75e+109) {
		tmp = y + y;
	} else {
		tmp = 3.0 * x;
	}
	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.25d+38)) then
        tmp = 3.0d0 * x
    else if (x <= (-1.6d-190)) then
        tmp = y + z
    else if (x <= (-9.5d-238)) then
        tmp = y + y
    else if (x <= 1.8d-177) then
        tmp = y + z
    else if (x <= 1.75d+109) then
        tmp = y + y
    else
        tmp = 3.0d0 * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.25e+38) {
		tmp = 3.0 * x;
	} else if (x <= -1.6e-190) {
		tmp = y + z;
	} else if (x <= -9.5e-238) {
		tmp = y + y;
	} else if (x <= 1.8e-177) {
		tmp = y + z;
	} else if (x <= 1.75e+109) {
		tmp = y + y;
	} else {
		tmp = 3.0 * x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1.25e+38:
		tmp = 3.0 * x
	elif x <= -1.6e-190:
		tmp = y + z
	elif x <= -9.5e-238:
		tmp = y + y
	elif x <= 1.8e-177:
		tmp = y + z
	elif x <= 1.75e+109:
		tmp = y + y
	else:
		tmp = 3.0 * x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.25e+38)
		tmp = Float64(3.0 * x);
	elseif (x <= -1.6e-190)
		tmp = Float64(y + z);
	elseif (x <= -9.5e-238)
		tmp = Float64(y + y);
	elseif (x <= 1.8e-177)
		tmp = Float64(y + z);
	elseif (x <= 1.75e+109)
		tmp = Float64(y + y);
	else
		tmp = Float64(3.0 * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1.25e+38)
		tmp = 3.0 * x;
	elseif (x <= -1.6e-190)
		tmp = y + z;
	elseif (x <= -9.5e-238)
		tmp = y + y;
	elseif (x <= 1.8e-177)
		tmp = y + z;
	elseif (x <= 1.75e+109)
		tmp = y + y;
	else
		tmp = 3.0 * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1.25e+38], N[(3.0 * x), $MachinePrecision], If[LessEqual[x, -1.6e-190], N[(y + z), $MachinePrecision], If[LessEqual[x, -9.5e-238], N[(y + y), $MachinePrecision], If[LessEqual[x, 1.8e-177], N[(y + z), $MachinePrecision], If[LessEqual[x, 1.75e+109], N[(y + y), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+38}:\\
\;\;\;\;3 \cdot x\\

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

\mathbf{elif}\;x \leq -9.5 \cdot 10^{-238}:\\
\;\;\;\;y + y\\

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

\mathbf{elif}\;x \leq 1.75 \cdot 10^{+109}:\\
\;\;\;\;y + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.24999999999999992e38 or 1.74999999999999992e109 < 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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+99.8%

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

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

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

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

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

    if -1.24999999999999992e38 < x < -1.6e-190 or -9.50000000000000059e-238 < x < 1.79999999999999991e-177

    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. associate-+l+100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
    6. Simplified68.7%

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

      \[\leadsto \color{blue}{y + z} \]
    8. Step-by-step derivation
      1. +-commutative64.3%

        \[\leadsto \color{blue}{z + y} \]
    9. Simplified64.3%

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

    if -1.6e-190 < x < -9.50000000000000059e-238 or 1.79999999999999991e-177 < x < 1.74999999999999992e109

    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. associate-+l+99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{+38}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{-190}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-238}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-177}:\\ \;\;\;\;y + z\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+109}:\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \]

Alternative 4: 85.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{+71}:\\
\;\;\;\;z + 3 \cdot x\\

\mathbf{elif}\;x \leq 5 \cdot 10^{+39}:\\
\;\;\;\;z + y \cdot 2\\

\mathbf{else}:\\
\;\;\;\;x + 2 \cdot \left(y + x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.0000000000000001e71

    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) + \left(x + z\right)\right)} + x \]
      2. associate-+l+99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
    6. Simplified89.7%

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

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

    if -2.0000000000000001e71 < x < 5.00000000000000015e39

    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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+100.0%

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

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

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

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

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

    if 5.00000000000000015e39 < x

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

Alternative 5: 85.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \cdot 10^{+71}:\\
\;\;\;\;y + \left(z + 3 \cdot x\right)\\

\mathbf{elif}\;x \leq 3.8 \cdot 10^{+39}:\\
\;\;\;\;z + y \cdot 2\\

\mathbf{else}:\\
\;\;\;\;x + 2 \cdot \left(y + x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.09999999999999997e71

    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) + \left(x + z\right)\right)} + x \]
      2. associate-+l+99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.09999999999999997e71 < x < 3.7999999999999998e39

    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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+100.0%

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

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

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

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

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

    if 3.7999999999999998e39 < x

    1. Initial program 99.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+71}:\\ \;\;\;\;y + \left(z + 3 \cdot x\right)\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+39}:\\ \;\;\;\;z + y \cdot 2\\ \mathbf{else}:\\ \;\;\;\;x + 2 \cdot \left(y + x\right)\\ \end{array} \]

Alternative 6: 52.2% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{+36}:\\
\;\;\;\;3 \cdot x\\

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

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+109}:\\
\;\;\;\;y + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.70000000000000029e36 or 2.1999999999999999e109 < 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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+99.8%

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

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

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

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

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

    if -3.70000000000000029e36 < x < -5.19999999999999972e-191

    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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+100.0%

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

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

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

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

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

    if -5.19999999999999972e-191 < x < 2.1999999999999999e109

    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. associate-+l+99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.7 \cdot 10^{+36}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{-191}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+109}:\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \]

Alternative 7: 80.0% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+72} \lor \neg \left(x \leq 7.3 \cdot 10^{+146}\right):\\
\;\;\;\;y + 3 \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.19999999999999926e72 or 7.30000000000000034e146 < x

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto y + \left(z + \left(\left(x + \color{blue}{2 \cdot x}\right) + y\right)\right) \]
      15. distribute-rgt1-in99.7%

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

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

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

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

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

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

        \[\leadsto y + \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
    6. Simplified87.5%

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

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

    if -8.19999999999999926e72 < x < 7.30000000000000034e146

    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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+100.0%

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

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

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

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

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

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

Alternative 8: 84.6% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+71} \lor \neg \left(x \leq 4.8 \cdot 10^{+109}\right):\\
\;\;\;\;z + 3 \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.3000000000000002e71 or 4.79999999999999975e109 < 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. associate-+l+99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.3000000000000002e71 < x < 4.79999999999999975e109

    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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+100.0%

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

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

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

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

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

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

Alternative 9: 99.9% accurate, 1.2× speedup?

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

\\
x + \left(z + 2 \cdot \left(y + x\right)\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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
    2. associate-+l+99.9%

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

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

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

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

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

Alternative 10: 52.8% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+36}:\\
\;\;\;\;3 \cdot x\\

\mathbf{elif}\;x \leq 4.6 \cdot 10^{+38}:\\
\;\;\;\;z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.5999999999999997e36 or 4.6000000000000002e38 < 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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+99.8%

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

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

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

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

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

    if -3.5999999999999997e36 < x < 4.6000000000000002e38

    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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
      2. associate-+l+100.0%

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

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

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

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

      \[\leadsto \color{blue}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+36}:\\ \;\;\;\;3 \cdot x\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+38}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \]

Alternative 11: 8.3% accurate, 11.0× speedup?

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

\\
y
\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. associate-+l+99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{y} \]
  8. Final simplification8.4%

    \[\leadsto y \]

Alternative 12: 34.9% 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}{x + \left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right)} \]
    2. associate-+l+99.9%

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

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

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

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

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

    \[\leadsto z \]

Reproduce

?
herbie shell --seed 2023297 
(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))