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

Percentage Accurate: 99.9% → 100.0%
Time: 6.3s
Alternatives: 6
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 6 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, 1.2× speedup?

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

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

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

    \[\leadsto \color{blue}{x + \left(z + \left(2 \cdot x + 2 \cdot y\right)\right)} \]
  4. Step-by-step derivation
    1. associate-+r+N/A

      \[\leadsto x + \color{blue}{\left(\left(z + 2 \cdot x\right) + 2 \cdot y\right)} \]
    2. associate-+r+N/A

      \[\leadsto \color{blue}{\left(x + \left(z + 2 \cdot x\right)\right) + 2 \cdot y} \]
    3. +-commutativeN/A

      \[\leadsto \color{blue}{2 \cdot y + \left(x + \left(z + 2 \cdot x\right)\right)} \]
    4. *-commutativeN/A

      \[\leadsto \color{blue}{y \cdot 2} + \left(x + \left(z + 2 \cdot x\right)\right) \]
    5. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, 2, x + \left(z + 2 \cdot x\right)\right)} \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(y, 2, x + \color{blue}{\left(2 \cdot x + z\right)}\right) \]
    7. associate-+r+N/A

      \[\leadsto \mathsf{fma}\left(y, 2, \color{blue}{\left(x + 2 \cdot x\right) + z}\right) \]
    8. distribute-rgt1-inN/A

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

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

      \[\leadsto \mathsf{fma}\left(y, 2, \color{blue}{\mathsf{fma}\left(3, x, z\right)}\right) \]
  5. Applied rewrites99.9%

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

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

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

    Alternative 2: 85.5% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.95 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\ \mathbf{elif}\;z \leq 1.62 \cdot 10^{+40}:\\ \;\;\;\;\mathsf{fma}\left(x, 3, y + y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= z -1.95e+89)
       (fma y 2.0 z)
       (if (<= z 1.62e+40) (fma x 3.0 (+ y y)) (fma 3.0 x z))))
    double code(double x, double y, double z) {
    	double tmp;
    	if (z <= -1.95e+89) {
    		tmp = fma(y, 2.0, z);
    	} else if (z <= 1.62e+40) {
    		tmp = fma(x, 3.0, (y + y));
    	} else {
    		tmp = fma(3.0, x, z);
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	tmp = 0.0
    	if (z <= -1.95e+89)
    		tmp = fma(y, 2.0, z);
    	elseif (z <= 1.62e+40)
    		tmp = fma(x, 3.0, Float64(y + y));
    	else
    		tmp = fma(3.0, x, z);
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := If[LessEqual[z, -1.95e+89], N[(y * 2.0 + z), $MachinePrecision], If[LessEqual[z, 1.62e+40], N[(x * 3.0 + N[(y + y), $MachinePrecision]), $MachinePrecision], N[(3.0 * x + z), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z \leq -1.95 \cdot 10^{+89}:\\
    \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
    
    \mathbf{elif}\;z \leq 1.62 \cdot 10^{+40}:\\
    \;\;\;\;\mathsf{fma}\left(x, 3, y + y\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if z < -1.95000000000000005e89

      1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z + 2 \cdot y} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{2 \cdot y + z} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{y \cdot 2} + z \]
        3. lower-fma.f6493.4

          \[\leadsto \color{blue}{\mathsf{fma}\left(y, 2, z\right)} \]
      5. Applied rewrites93.4%

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

      if -1.95000000000000005e89 < z < 1.62e40

      1. Initial program 99.8%

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

        \[\leadsto \color{blue}{x + \left(z + \left(2 \cdot x + 2 \cdot y\right)\right)} \]
      4. Step-by-step derivation
        1. associate-+r+N/A

          \[\leadsto x + \color{blue}{\left(\left(z + 2 \cdot x\right) + 2 \cdot y\right)} \]
        2. associate-+r+N/A

          \[\leadsto \color{blue}{\left(x + \left(z + 2 \cdot x\right)\right) + 2 \cdot y} \]
        3. +-commutativeN/A

          \[\leadsto \color{blue}{2 \cdot y + \left(x + \left(z + 2 \cdot x\right)\right)} \]
        4. *-commutativeN/A

          \[\leadsto \color{blue}{y \cdot 2} + \left(x + \left(z + 2 \cdot x\right)\right) \]
        5. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(y, 2, x + \left(z + 2 \cdot x\right)\right)} \]
        6. +-commutativeN/A

          \[\leadsto \mathsf{fma}\left(y, 2, x + \color{blue}{\left(2 \cdot x + z\right)}\right) \]
        7. associate-+r+N/A

          \[\leadsto \mathsf{fma}\left(y, 2, \color{blue}{\left(x + 2 \cdot x\right) + z}\right) \]
        8. distribute-rgt1-inN/A

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

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

          \[\leadsto \mathsf{fma}\left(y, 2, \color{blue}{\mathsf{fma}\left(3, x, z\right)}\right) \]
      5. Applied rewrites99.9%

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

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

          \[\leadsto \mathsf{fma}\left(x, 3, 2 \cdot y\right) \]
        3. Step-by-step derivation
          1. Applied rewrites90.5%

            \[\leadsto \mathsf{fma}\left(x, 3, y \cdot 2\right) \]
          2. Step-by-step derivation
            1. Applied rewrites90.5%

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

            if 1.62e40 < z

            1. Initial program 99.9%

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

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

                \[\leadsto x + \color{blue}{\left(2 \cdot x + z\right)} \]
              2. associate-+r+N/A

                \[\leadsto \color{blue}{\left(x + 2 \cdot x\right) + z} \]
              3. distribute-rgt1-inN/A

                \[\leadsto \color{blue}{\left(2 + 1\right) \cdot x} + z \]
              4. metadata-evalN/A

                \[\leadsto \color{blue}{3} \cdot x + z \]
              5. lower-fma.f6486.8

                \[\leadsto \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
            5. Applied rewrites86.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
          3. Recombined 3 regimes into one program.
          4. Add Preprocessing

          Alternative 3: 85.3% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+24}:\\ \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+84}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= y -7e+24)
             (fma y 2.0 z)
             (if (<= y 1.4e+84) (fma 3.0 x z) (fma y 2.0 z))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= -7e+24) {
          		tmp = fma(y, 2.0, z);
          	} else if (y <= 1.4e+84) {
          		tmp = fma(3.0, x, z);
          	} else {
          		tmp = fma(y, 2.0, z);
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= -7e+24)
          		tmp = fma(y, 2.0, z);
          	elseif (y <= 1.4e+84)
          		tmp = fma(3.0, x, z);
          	else
          		tmp = fma(y, 2.0, z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[LessEqual[y, -7e+24], N[(y * 2.0 + z), $MachinePrecision], If[LessEqual[y, 1.4e+84], N[(3.0 * x + z), $MachinePrecision], N[(y * 2.0 + z), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -7 \cdot 10^{+24}:\\
          \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
          
          \mathbf{elif}\;y \leq 1.4 \cdot 10^{+84}:\\
          \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -7.0000000000000004e24 or 1.39999999999999991e84 < y

            1. Initial program 99.9%

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

              \[\leadsto \color{blue}{z + 2 \cdot y} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \color{blue}{2 \cdot y + z} \]
              2. *-commutativeN/A

                \[\leadsto \color{blue}{y \cdot 2} + z \]
              3. lower-fma.f6486.9

                \[\leadsto \color{blue}{\mathsf{fma}\left(y, 2, z\right)} \]
            5. Applied rewrites86.9%

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

            if -7.0000000000000004e24 < y < 1.39999999999999991e84

            1. Initial program 99.8%

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

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

                \[\leadsto x + \color{blue}{\left(2 \cdot x + z\right)} \]
              2. associate-+r+N/A

                \[\leadsto \color{blue}{\left(x + 2 \cdot x\right) + z} \]
              3. distribute-rgt1-inN/A

                \[\leadsto \color{blue}{\left(2 + 1\right) \cdot x} + z \]
              4. metadata-evalN/A

                \[\leadsto \color{blue}{3} \cdot x + z \]
              5. lower-fma.f6489.7

                \[\leadsto \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
            5. Applied rewrites89.7%

              \[\leadsto \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
          3. Recombined 2 regimes into one program.
          4. Add Preprocessing

          Alternative 4: 79.8% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+127}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;y \leq 5.3 \cdot 10^{+113}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= y -8.2e+127) (+ y y) (if (<= y 5.3e+113) (fma 3.0 x z) (+ y y))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= -8.2e+127) {
          		tmp = y + y;
          	} else if (y <= 5.3e+113) {
          		tmp = fma(3.0, x, z);
          	} else {
          		tmp = y + y;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= -8.2e+127)
          		tmp = Float64(y + y);
          	elseif (y <= 5.3e+113)
          		tmp = fma(3.0, x, z);
          	else
          		tmp = Float64(y + y);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[LessEqual[y, -8.2e+127], N[(y + y), $MachinePrecision], If[LessEqual[y, 5.3e+113], N[(3.0 * x + z), $MachinePrecision], N[(y + y), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -8.2 \cdot 10^{+127}:\\
          \;\;\;\;y + y\\
          
          \mathbf{elif}\;y \leq 5.3 \cdot 10^{+113}:\\
          \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;y + y\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -8.19999999999999965e127 or 5.29999999999999967e113 < y

            1. Initial program 100.0%

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

              \[\leadsto \color{blue}{2 \cdot y} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{y \cdot 2} \]
              2. lower-*.f6475.1

                \[\leadsto \color{blue}{y \cdot 2} \]
            5. Applied rewrites75.1%

              \[\leadsto \color{blue}{y \cdot 2} \]
            6. Step-by-step derivation
              1. Applied rewrites75.1%

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

              if -8.19999999999999965e127 < y < 5.29999999999999967e113

              1. Initial program 99.8%

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

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

                  \[\leadsto x + \color{blue}{\left(2 \cdot x + z\right)} \]
                2. associate-+r+N/A

                  \[\leadsto \color{blue}{\left(x + 2 \cdot x\right) + z} \]
                3. distribute-rgt1-inN/A

                  \[\leadsto \color{blue}{\left(2 + 1\right) \cdot x} + z \]
                4. metadata-evalN/A

                  \[\leadsto \color{blue}{3} \cdot x + z \]
                5. lower-fma.f6487.2

                  \[\leadsto \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
              5. Applied rewrites87.2%

                \[\leadsto \color{blue}{\mathsf{fma}\left(3, x, z\right)} \]
            7. Recombined 2 regimes into one program.
            8. Add Preprocessing

            Alternative 5: 52.1% accurate, 0.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.45 \cdot 10^{+56}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+109}:\\ \;\;\;\;3 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (<= y -3.45e+56) (+ y y) (if (<= y 4.2e+109) (* 3.0 x) (+ y y))))
            double code(double x, double y, double z) {
            	double tmp;
            	if (y <= -3.45e+56) {
            		tmp = y + y;
            	} else if (y <= 4.2e+109) {
            		tmp = 3.0 * x;
            	} else {
            		tmp = y + y;
            	}
            	return tmp;
            }
            
            real(8) function code(x, y, z)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8) :: tmp
                if (y <= (-3.45d+56)) then
                    tmp = y + y
                else if (y <= 4.2d+109) then
                    tmp = 3.0d0 * x
                else
                    tmp = y + y
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z) {
            	double tmp;
            	if (y <= -3.45e+56) {
            		tmp = y + y;
            	} else if (y <= 4.2e+109) {
            		tmp = 3.0 * x;
            	} else {
            		tmp = y + y;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	tmp = 0
            	if y <= -3.45e+56:
            		tmp = y + y
            	elif y <= 4.2e+109:
            		tmp = 3.0 * x
            	else:
            		tmp = y + y
            	return tmp
            
            function code(x, y, z)
            	tmp = 0.0
            	if (y <= -3.45e+56)
            		tmp = Float64(y + y);
            	elseif (y <= 4.2e+109)
            		tmp = Float64(3.0 * x);
            	else
            		tmp = Float64(y + y);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	tmp = 0.0;
            	if (y <= -3.45e+56)
            		tmp = y + y;
            	elseif (y <= 4.2e+109)
            		tmp = 3.0 * x;
            	else
            		tmp = y + y;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := If[LessEqual[y, -3.45e+56], N[(y + y), $MachinePrecision], If[LessEqual[y, 4.2e+109], N[(3.0 * x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;y \leq -3.45 \cdot 10^{+56}:\\
            \;\;\;\;y + y\\
            
            \mathbf{elif}\;y \leq 4.2 \cdot 10^{+109}:\\
            \;\;\;\;3 \cdot x\\
            
            \mathbf{else}:\\
            \;\;\;\;y + y\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if y < -3.45e56 or 4.2000000000000003e109 < y

              1. Initial program 99.9%

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

                \[\leadsto \color{blue}{2 \cdot y} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \color{blue}{y \cdot 2} \]
                2. lower-*.f6468.9

                  \[\leadsto \color{blue}{y \cdot 2} \]
              5. Applied rewrites68.9%

                \[\leadsto \color{blue}{y \cdot 2} \]
              6. Step-by-step derivation
                1. Applied rewrites68.9%

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

                if -3.45e56 < y < 4.2000000000000003e109

                1. Initial program 99.8%

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

                  \[\leadsto \color{blue}{3 \cdot x} \]
                4. Step-by-step derivation
                  1. lower-*.f6449.8

                    \[\leadsto \color{blue}{3 \cdot x} \]
                5. Applied rewrites49.8%

                  \[\leadsto \color{blue}{3 \cdot x} \]
              7. Recombined 2 regimes into one program.
              8. Add Preprocessing

              Alternative 6: 33.1% accurate, 4.0× speedup?

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

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

                \[\leadsto \color{blue}{2 \cdot y} \]
              4. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto \color{blue}{y \cdot 2} \]
                2. lower-*.f6431.5

                  \[\leadsto \color{blue}{y \cdot 2} \]
              5. Applied rewrites31.5%

                \[\leadsto \color{blue}{y \cdot 2} \]
              6. Step-by-step derivation
                1. Applied rewrites31.5%

                  \[\leadsto y + \color{blue}{y} \]
                2. Add Preprocessing

                Reproduce

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