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

Percentage Accurate: 99.9% → 99.9%
Time: 5.9s
Alternatives: 7
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 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 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, 1.2× speedup?

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

\\
\mathsf{fma}\left(2, x + y, z + x\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. Step-by-step derivation
    1. lift-+.f64N/A

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

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

      \[\leadsto \color{blue}{\left(\left(\left(x + y\right) + y\right) + x\right) + \left(z + x\right)} \]
    4. lift-+.f64N/A

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

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

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

      \[\leadsto \left(\left(x + y\right) + \color{blue}{\left(x + y\right)}\right) + \left(z + x\right) \]
    8. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 84.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.7 \cdot 10^{+129}:\\ \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-59}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+67}:\\ \;\;\;\;\mathsf{fma}\left(3, x, y + y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -4.7e+129)
   (fma y 2.0 z)
   (if (<= z -9.5e-59)
     (fma 3.0 x z)
     (if (<= z 5.6e+67) (fma 3.0 x (+ y y)) (fma 3.0 x z)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.7e+129) {
		tmp = fma(y, 2.0, z);
	} else if (z <= -9.5e-59) {
		tmp = fma(3.0, x, z);
	} else if (z <= 5.6e+67) {
		tmp = fma(3.0, x, (y + y));
	} else {
		tmp = fma(3.0, x, z);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (z <= -4.7e+129)
		tmp = fma(y, 2.0, z);
	elseif (z <= -9.5e-59)
		tmp = fma(3.0, x, z);
	elseif (z <= 5.6e+67)
		tmp = fma(3.0, x, Float64(y + y));
	else
		tmp = fma(3.0, x, z);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[z, -4.7e+129], N[(y * 2.0 + z), $MachinePrecision], If[LessEqual[z, -9.5e-59], N[(3.0 * x + z), $MachinePrecision], If[LessEqual[z, 5.6e+67], N[(3.0 * x + N[(y + y), $MachinePrecision]), $MachinePrecision], N[(3.0 * x + z), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.7 \cdot 10^{+129}:\\
\;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\

\mathbf{elif}\;z \leq -9.5 \cdot 10^{-59}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\

\mathbf{elif}\;z \leq 5.6 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(3, x, 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 < -4.70000000000000008e129

    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.f6492.6

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

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

    if -4.70000000000000008e129 < z < -9.4999999999999994e-59 or 5.5999999999999995e67 < 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.f6485.7

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

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

    if -9.4999999999999994e-59 < z < 5.5999999999999995e67

    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(2 \cdot x + 2 \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+N/A

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

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

        \[\leadsto \color{blue}{3} \cdot x + 2 \cdot y \]
      4. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(3, x, \color{blue}{y \cdot 2}\right) \]
      6. lower-*.f6493.6

        \[\leadsto \mathsf{fma}\left(3, x, \color{blue}{y \cdot 2}\right) \]
    5. Applied rewrites93.6%

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

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

    Alternative 3: 86.4% accurate, 0.7× speedup?

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

      1. Initial program 99.7%

        \[\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.f6490.9

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

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

      if -2.5500000000000001e110 < x < 9.50000000000000019e42

      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}{\left(z + 2 \cdot y\right)} + x \]
      4. Step-by-step derivation
        1. +-commutativeN/A

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

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

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

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

      if 9.50000000000000019e42 < x

      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(2 \cdot x + 2 \cdot y\right)} \]
      4. Step-by-step derivation
        1. associate-+r+N/A

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

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

          \[\leadsto \color{blue}{3} \cdot x + 2 \cdot y \]
        4. lower-fma.f64N/A

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

          \[\leadsto \mathsf{fma}\left(3, x, \color{blue}{y \cdot 2}\right) \]
        6. lower-*.f6492.2

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

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

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

      Alternative 4: 84.9% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+78}:\\ \;\;\;\;\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 -1.02e-10)
         (fma y 2.0 z)
         (if (<= y 1.4e+78) (fma 3.0 x z) (fma y 2.0 z))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (y <= -1.02e-10) {
      		tmp = fma(y, 2.0, z);
      	} else if (y <= 1.4e+78) {
      		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 <= -1.02e-10)
      		tmp = fma(y, 2.0, z);
      	elseif (y <= 1.4e+78)
      		tmp = fma(3.0, x, z);
      	else
      		tmp = fma(y, 2.0, z);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[LessEqual[y, -1.02e-10], N[(y * 2.0 + z), $MachinePrecision], If[LessEqual[y, 1.4e+78], N[(3.0 * x + z), $MachinePrecision], N[(y * 2.0 + z), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -1.02 \cdot 10^{-10}:\\
      \;\;\;\;\mathsf{fma}\left(y, 2, z\right)\\
      
      \mathbf{elif}\;y \leq 1.4 \cdot 10^{+78}:\\
      \;\;\;\;\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 < -1.01999999999999997e-10 or 1.4000000000000001e78 < 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.f6482.7

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

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

        if -1.01999999999999997e-10 < y < 1.4000000000000001e78

        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.f6491.6

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

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

      Alternative 5: 80.3% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+91}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (<= y -2.15e+91) (+ y y) (if (<= y 2.4e+151) (fma 3.0 x z) (+ y y))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (y <= -2.15e+91) {
      		tmp = y + y;
      	} else if (y <= 2.4e+151) {
      		tmp = fma(3.0, x, z);
      	} else {
      		tmp = y + y;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if (y <= -2.15e+91)
      		tmp = Float64(y + y);
      	elseif (y <= 2.4e+151)
      		tmp = fma(3.0, x, z);
      	else
      		tmp = Float64(y + y);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[LessEqual[y, -2.15e+91], N[(y + y), $MachinePrecision], If[LessEqual[y, 2.4e+151], N[(3.0 * x + z), $MachinePrecision], N[(y + y), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -2.15 \cdot 10^{+91}:\\
      \;\;\;\;y + y\\
      
      \mathbf{elif}\;y \leq 2.4 \cdot 10^{+151}:\\
      \;\;\;\;\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 < -2.15e91 or 2.4000000000000001e151 < 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-*.f6477.3

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

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

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

          if -2.15e91 < y < 2.4000000000000001e151

          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.f6486.5

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

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

        Alternative 6: 52.6% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-16}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+78}:\\ \;\;\;\;3 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= y -3.3e-16) (+ y y) (if (<= y 1.35e+78) (* 3.0 x) (+ y y))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -3.3e-16) {
        		tmp = y + y;
        	} else if (y <= 1.35e+78) {
        		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.3d-16)) then
                tmp = y + y
            else if (y <= 1.35d+78) 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.3e-16) {
        		tmp = y + y;
        	} else if (y <= 1.35e+78) {
        		tmp = 3.0 * x;
        	} else {
        		tmp = y + y;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if y <= -3.3e-16:
        		tmp = y + y
        	elif y <= 1.35e+78:
        		tmp = 3.0 * x
        	else:
        		tmp = y + y
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (y <= -3.3e-16)
        		tmp = Float64(y + y);
        	elseif (y <= 1.35e+78)
        		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.3e-16)
        		tmp = y + y;
        	elseif (y <= 1.35e+78)
        		tmp = 3.0 * x;
        	else
        		tmp = y + y;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[y, -3.3e-16], N[(y + y), $MachinePrecision], If[LessEqual[y, 1.35e+78], N[(3.0 * x), $MachinePrecision], N[(y + y), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq -3.3 \cdot 10^{-16}:\\
        \;\;\;\;y + y\\
        
        \mathbf{elif}\;y \leq 1.35 \cdot 10^{+78}:\\
        \;\;\;\;3 \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;y + y\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -3.29999999999999988e-16 or 1.35000000000000002e78 < 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-*.f6465.0

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

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

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

            if -3.29999999999999988e-16 < y < 1.35000000000000002e78

            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-*.f6454.2

                \[\leadsto \color{blue}{3 \cdot x} \]
            5. Applied rewrites54.2%

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

          Alternative 7: 35.2% 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-*.f6434.0

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

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

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

            Reproduce

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