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

Percentage Accurate: 99.9% → 100.0%
Time: 4.6s
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} \\ \mathsf{fma}\left(x, 3, \mathsf{fma}\left(y, 2, z\right)\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma x 3.0 (fma y 2.0 z)))
double code(double x, double y, double z) {
	return fma(x, 3.0, fma(y, 2.0, z));
}
function code(x, y, z)
	return fma(x, 3.0, fma(y, 2.0, z))
end
code[x_, y_, z_] := N[(x * 3.0 + N[(y * 2.0 + z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(x, 3, \mathsf{fma}\left(y, 2, z\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. +-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 100.0% accurate, 0.1× speedup?

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

\\
z + \mathsf{fma}\left(x, 3, y \cdot 2\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. +-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 52.1% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;z \leq -1.1 \cdot 10^{-217}:\\
\;\;\;\;y \cdot 2\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{-233}:\\
\;\;\;\;x \cdot 3\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{-188}:\\
\;\;\;\;y \cdot 2\\

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

\mathbf{elif}\;z \leq 3.4 \cdot 10^{+110}:\\
\;\;\;\;y \cdot 2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.06000000000000006e36 or 3.4000000000000001e110 < 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}{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 77.0%

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

    if -2.06000000000000006e36 < z < -1.09999999999999991e-217 or 1.35e-233 < z < 6.2000000000000004e-188 or 2.7999999999999999e-57 < z < 3.4000000000000001e110

    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 y around inf 50.2%

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

    if -1.09999999999999991e-217 < z < 1.35e-233 or 6.2000000000000004e-188 < z < 2.7999999999999999e-57

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.06 \cdot 10^{+36}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-217}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-233}:\\ \;\;\;\;x \cdot 3\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-188}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-57}:\\ \;\;\;\;x \cdot 3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+110}:\\ \;\;\;\;y \cdot 2\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]

Alternative 4: 79.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq -1.05 \cdot 10^{+49} \lor \neg \left(x \leq -4.7 \cdot 10^{+36}\right) \land x \leq 2.9 \cdot 10^{+154}:\\
\;\;\;\;z + y \cdot 2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.04999999999999988e125 or -1.05000000000000005e49 < x < -4.69999999999999989e36 or 2.89999999999999979e154 < x

    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 x around inf 85.2%

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

    if -3.04999999999999988e125 < x < -1.05000000000000005e49 or -4.69999999999999989e36 < x < 2.89999999999999979e154

    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 x around 0 84.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.05 \cdot 10^{+125}:\\ \;\;\;\;x \cdot 3\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{+49} \lor \neg \left(x \leq -4.7 \cdot 10^{+36}\right) \land x \leq 2.9 \cdot 10^{+154}:\\ \;\;\;\;z + y \cdot 2\\ \mathbf{else}:\\ \;\;\;\;x \cdot 3\\ \end{array} \]

Alternative 5: 85.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+62} \lor \neg \left(y \leq 1.56 \cdot 10^{+37}\right):\\
\;\;\;\;z + y \cdot 2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.19999999999999984e62 or 1.56000000000000008e37 < y

    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 x around 0 86.9%

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

    if -3.19999999999999984e62 < y < 1.56000000000000008e37

    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 y around 0 91.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{+62} \lor \neg \left(y \leq 1.56 \cdot 10^{+37}\right):\\ \;\;\;\;z + y \cdot 2\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(x + z\right)\\ \end{array} \]

Alternative 6: 85.8% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+58} \lor \neg \left(y \leq 7.8 \cdot 10^{+38}\right):\\
\;\;\;\;z + y \cdot 2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.2e58 or 7.80000000000000047e38 < y

    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 x around 0 86.9%

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

    if -8.2e58 < y < 7.80000000000000047e38

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 99.9% accurate, 1.2× speedup?

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

\\
x + \left(z + 2 \cdot \left(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. +-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(x + y\right)\right) \]

Alternative 8: 52.0% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+116}:\\
\;\;\;\;y \cdot 2\\

\mathbf{elif}\;y \leq 1.45 \cdot 10^{+39}:\\
\;\;\;\;z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.00000000000000002e116 or 1.45000000000000015e39 < y

    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 y around inf 71.6%

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

    if -1.00000000000000002e116 < y < 1.45000000000000015e39

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+116}:\\ \;\;\;\;y \cdot 2\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{+39}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot 2\\ \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}{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 36.3%

    \[\leadsto \color{blue}{z} \]
  5. Final simplification36.3%

    \[\leadsto z \]

Reproduce

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