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

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

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

\\
\mathsf{fma}\left(3, x, \mathsf{fma}\left(2, y, 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. Add Preprocessing
  3. Taylor expanded in x around 0

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

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

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

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

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

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

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

Alternative 2: 86.2% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;y \leq 4 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(3, x, z\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(3, x, y + y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.2e16

    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}{\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. lower-fma.f6488.0

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

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

    if -2.2e16 < y < 3.99999999999999993e67

    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.f6494.9

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

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

    if 3.99999999999999993e67 < 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 z around 0

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot y + \color{blue}{3 \cdot x} \]
    7. Step-by-step derivation
      1. Applied rewrites87.4%

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

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

      Alternative 3: 85.5% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

        if -2.7e16 < y < 3.99999999999999993e67

        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.f6494.9

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

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

        if 3.99999999999999993e67 < 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 z around 0

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

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

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

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

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

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

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

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

          \[\leadsto 2 \cdot y + \color{blue}{3 \cdot x} \]
        7. Step-by-step derivation
          1. Applied rewrites87.4%

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

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

          Alternative 4: 85.7% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+16} \lor \neg \left(y \leq 3.6 \cdot 10^{+70}\right):\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (or (<= y -2.7e+16) (not (<= y 3.6e+70))) (fma 2.0 y z) (fma 3.0 x z)))
          double code(double x, double y, double z) {
          	double tmp;
          	if ((y <= -2.7e+16) || !(y <= 3.6e+70)) {
          		tmp = fma(2.0, y, z);
          	} else {
          		tmp = fma(3.0, x, z);
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if ((y <= -2.7e+16) || !(y <= 3.6e+70))
          		tmp = fma(2.0, y, z);
          	else
          		tmp = fma(3.0, x, z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[Or[LessEqual[y, -2.7e+16], N[Not[LessEqual[y, 3.6e+70]], $MachinePrecision]], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x + z), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -2.7 \cdot 10^{+16} \lor \neg \left(y \leq 3.6 \cdot 10^{+70}\right):\\
          \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -2.7e16 or 3.6e70 < 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 + \left(2 \cdot y + 3 \cdot x\right)} \]
            4. Step-by-step derivation
              1. associate-+r+N/A

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{2 \cdot y + z} \]
              2. lower-fma.f6485.7

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

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

            if -2.7e16 < y < 3.6e70

            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.f6495.0

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+16} \lor \neg \left(y \leq 3.6 \cdot 10^{+70}\right):\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \end{array} \]
          5. Add Preprocessing

          Alternative 5: 79.3% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+134} \lor \neg \left(x \leq 9.2 \cdot 10^{+167}\right):\\ \;\;\;\;3 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (or (<= x -1.6e+134) (not (<= x 9.2e+167))) (* 3.0 x) (fma 2.0 y z)))
          double code(double x, double y, double z) {
          	double tmp;
          	if ((x <= -1.6e+134) || !(x <= 9.2e+167)) {
          		tmp = 3.0 * x;
          	} else {
          		tmp = fma(2.0, y, z);
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if ((x <= -1.6e+134) || !(x <= 9.2e+167))
          		tmp = Float64(3.0 * x);
          	else
          		tmp = fma(2.0, y, z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[Or[LessEqual[x, -1.6e+134], N[Not[LessEqual[x, 9.2e+167]], $MachinePrecision]], N[(3.0 * x), $MachinePrecision], N[(2.0 * y + z), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq -1.6 \cdot 10^{+134} \lor \neg \left(x \leq 9.2 \cdot 10^{+167}\right):\\
          \;\;\;\;3 \cdot x\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -1.6e134 or 9.19999999999999952e167 < 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 x around inf

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

                \[\leadsto \color{blue}{3 \cdot x} \]
            5. Applied rewrites78.6%

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

            if -1.6e134 < x < 9.19999999999999952e167

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(2, y, z\right)} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification82.4%

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+134} \lor \neg \left(x \leq 9.2 \cdot 10^{+167}\right):\\ \;\;\;\;3 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \end{array} \]
          5. Add Preprocessing

          Alternative 6: 53.1% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+15} \lor \neg \left(y \leq 3.6 \cdot 10^{+70}\right):\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (or (<= y -6.5e+15) (not (<= y 3.6e+70))) (+ y y) (* 3.0 x)))
          double code(double x, double y, double z) {
          	double tmp;
          	if ((y <= -6.5e+15) || !(y <= 3.6e+70)) {
          		tmp = y + y;
          	} else {
          		tmp = 3.0 * x;
          	}
          	return tmp;
          }
          
          real(8) function code(x, y, z)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: tmp
              if ((y <= (-6.5d+15)) .or. (.not. (y <= 3.6d+70))) then
                  tmp = y + y
              else
                  tmp = 3.0d0 * x
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if ((y <= -6.5e+15) || !(y <= 3.6e+70)) {
          		tmp = y + y;
          	} else {
          		tmp = 3.0 * x;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if (y <= -6.5e+15) or not (y <= 3.6e+70):
          		tmp = y + y
          	else:
          		tmp = 3.0 * x
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if ((y <= -6.5e+15) || !(y <= 3.6e+70))
          		tmp = Float64(y + y);
          	else
          		tmp = Float64(3.0 * x);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if ((y <= -6.5e+15) || ~((y <= 3.6e+70)))
          		tmp = y + y;
          	else
          		tmp = 3.0 * x;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[Or[LessEqual[y, -6.5e+15], N[Not[LessEqual[y, 3.6e+70]], $MachinePrecision]], N[(y + y), $MachinePrecision], N[(3.0 * x), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -6.5 \cdot 10^{+15} \lor \neg \left(y \leq 3.6 \cdot 10^{+70}\right):\\
          \;\;\;\;y + y\\
          
          \mathbf{else}:\\
          \;\;\;\;3 \cdot x\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -6.5e15 or 3.6e70 < 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 z around 0

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\color{blue}{y + x}, 2, x\right) \]
              6. lower-+.f6477.6

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

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

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

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

                  \[\leadsto y + y \]

                if -6.5e15 < y < 3.6e70

                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} \]
              3. Recombined 2 regimes into one program.
              4. Final simplification58.6%

                \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+15} \lor \neg \left(y \leq 3.6 \cdot 10^{+70}\right):\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;3 \cdot x\\ \end{array} \]
              5. Add Preprocessing

              Alternative 7: 34.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 z around 0

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

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{y + x}, 2, x\right) \]
                6. lower-+.f6467.7

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

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

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

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

                    \[\leadsto y + y \]
                  2. Add Preprocessing

                  Reproduce

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