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

Percentage Accurate: 99.9% → 99.9%
Time: 3.8s
Alternatives: 8
Speedup: 1.0×

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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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 8 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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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.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;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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}
Derivation
  1. Initial program 99.9%

    \[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 54.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{+137}:\\ \;\;\;\;y + y\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-105}:\\ \;\;\;\;z + x\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-19}:\\ \;\;\;\;3 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y + y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -9e+137)
   (+ y y)
   (if (<= y 7.6e-105) (+ z x) (if (<= y 2.6e-19) (* 3.0 x) (+ y y)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -9e+137) {
		tmp = y + y;
	} else if (y <= 7.6e-105) {
		tmp = z + x;
	} else if (y <= 2.6e-19) {
		tmp = 3.0 * x;
	} else {
		tmp = y + y;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-9d+137)) then
        tmp = y + y
    else if (y <= 7.6d-105) then
        tmp = z + x
    else if (y <= 2.6d-19) 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 <= -9e+137) {
		tmp = y + y;
	} else if (y <= 7.6e-105) {
		tmp = z + x;
	} else if (y <= 2.6e-19) {
		tmp = 3.0 * x;
	} else {
		tmp = y + y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -9e+137:
		tmp = y + y
	elif y <= 7.6e-105:
		tmp = z + x
	elif y <= 2.6e-19:
		tmp = 3.0 * x
	else:
		tmp = y + y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -9e+137)
		tmp = Float64(y + y);
	elseif (y <= 7.6e-105)
		tmp = Float64(z + x);
	elseif (y <= 2.6e-19)
		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 <= -9e+137)
		tmp = y + y;
	elseif (y <= 7.6e-105)
		tmp = z + x;
	elseif (y <= 2.6e-19)
		tmp = 3.0 * x;
	else
		tmp = y + y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -9e+137], N[(y + y), $MachinePrecision], If[LessEqual[y, 7.6e-105], N[(z + x), $MachinePrecision], If[LessEqual[y, 2.6e-19], N[(3.0 * x), $MachinePrecision], N[(y + y), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+137}:\\
\;\;\;\;y + y\\

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

\mathbf{elif}\;y \leq 2.6 \cdot 10^{-19}:\\
\;\;\;\;3 \cdot x\\

\mathbf{else}:\\
\;\;\;\;y + y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.0000000000000003e137 or 2.60000000000000013e-19 < 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. Applied rewrites64.5%

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

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

        if -9.0000000000000003e137 < y < 7.5999999999999995e-105

        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 inf

          \[\leadsto \color{blue}{z} + x \]
        4. Step-by-step derivation
          1. Applied rewrites61.0%

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

          if 7.5999999999999995e-105 < y < 2.60000000000000013e-19

          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. Applied rewrites70.7%

              \[\leadsto \color{blue}{3 \cdot x} \]
          5. Recombined 3 regimes into one program.
          6. Add Preprocessing

          Alternative 3: 84.6% accurate, 0.7× speedup?

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

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

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

              if -5.5000000000000001e75 < z < 1.2000000000000001e-65

              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. Applied rewrites92.4%

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

                    \[\leadsto \mathsf{fma}\left(3, x, y + y\right) \]
                3. Recombined 2 regimes into one program.
                4. Final simplification89.0%

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

                Alternative 4: 84.3% accurate, 0.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7.6 \cdot 10^{+117} \lor \neg \left(y \leq 2.6 \cdot 10^{-19}\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 -7.6e+117) (not (<= y 2.6e-19))) (fma 2.0 y z) (fma 3.0 x z)))
                double code(double x, double y, double z) {
                	double tmp;
                	if ((y <= -7.6e+117) || !(y <= 2.6e-19)) {
                		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 <= -7.6e+117) || !(y <= 2.6e-19))
                		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, -7.6e+117], N[Not[LessEqual[y, 2.6e-19]], $MachinePrecision]], N[(2.0 * y + z), $MachinePrecision], N[(3.0 * x + z), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;y \leq -7.6 \cdot 10^{+117} \lor \neg \left(y \leq 2.6 \cdot 10^{-19}\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 < -7.6000000000000003e117 or 2.60000000000000013e-19 < 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. Applied rewrites83.4%

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

                    if -7.6000000000000003e117 < y < 2.60000000000000013e-19

                    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. Applied rewrites91.8%

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

                      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.6 \cdot 10^{+117} \lor \neg \left(y \leq 2.6 \cdot 10^{-19}\right):\\ \;\;\;\;\mathsf{fma}\left(2, y, z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(3, x, z\right)\\ \end{array} \]
                    7. Add Preprocessing

                    Alternative 5: 79.8% accurate, 0.8× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.2 \cdot 10^{+138} \lor \neg \left(x \leq 2.7 \cdot 10^{+165}\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 -2.2e+138) (not (<= x 2.7e+165))) (* 3.0 x) (fma 2.0 y z)))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if ((x <= -2.2e+138) || !(x <= 2.7e+165)) {
                    		tmp = 3.0 * x;
                    	} else {
                    		tmp = fma(2.0, y, z);
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if ((x <= -2.2e+138) || !(x <= 2.7e+165))
                    		tmp = Float64(3.0 * x);
                    	else
                    		tmp = fma(2.0, y, z);
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_, z_] := If[Or[LessEqual[x, -2.2e+138], N[Not[LessEqual[x, 2.7e+165]], $MachinePrecision]], N[(3.0 * x), $MachinePrecision], N[(2.0 * y + z), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;x \leq -2.2 \cdot 10^{+138} \lor \neg \left(x \leq 2.7 \cdot 10^{+165}\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 < -2.2000000000000001e138 or 2.7e165 < 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. Applied rewrites79.0%

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

                        if -2.2000000000000001e138 < x < 2.7e165

                        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. Applied rewrites84.6%

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

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

                        Alternative 6: 55.5% accurate, 1.0× speedup?

                        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{+137} \lor \neg \left(y \leq 2.6 \cdot 10^{-19}\right):\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \end{array} \]
                        (FPCore (x y z)
                         :precision binary64
                         (if (or (<= y -9e+137) (not (<= y 2.6e-19))) (+ y y) (+ z x)))
                        double code(double x, double y, double z) {
                        	double tmp;
                        	if ((y <= -9e+137) || !(y <= 2.6e-19)) {
                        		tmp = y + y;
                        	} else {
                        		tmp = z + x;
                        	}
                        	return tmp;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(x, y, z)
                        use fmin_fmax_functions
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            real(8), intent (in) :: z
                            real(8) :: tmp
                            if ((y <= (-9d+137)) .or. (.not. (y <= 2.6d-19))) then
                                tmp = y + y
                            else
                                tmp = z + x
                            end if
                            code = tmp
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	double tmp;
                        	if ((y <= -9e+137) || !(y <= 2.6e-19)) {
                        		tmp = y + y;
                        	} else {
                        		tmp = z + x;
                        	}
                        	return tmp;
                        }
                        
                        def code(x, y, z):
                        	tmp = 0
                        	if (y <= -9e+137) or not (y <= 2.6e-19):
                        		tmp = y + y
                        	else:
                        		tmp = z + x
                        	return tmp
                        
                        function code(x, y, z)
                        	tmp = 0.0
                        	if ((y <= -9e+137) || !(y <= 2.6e-19))
                        		tmp = Float64(y + y);
                        	else
                        		tmp = Float64(z + x);
                        	end
                        	return tmp
                        end
                        
                        function tmp_2 = code(x, y, z)
                        	tmp = 0.0;
                        	if ((y <= -9e+137) || ~((y <= 2.6e-19)))
                        		tmp = y + y;
                        	else
                        		tmp = z + x;
                        	end
                        	tmp_2 = tmp;
                        end
                        
                        code[x_, y_, z_] := If[Or[LessEqual[y, -9e+137], N[Not[LessEqual[y, 2.6e-19]], $MachinePrecision]], N[(y + y), $MachinePrecision], N[(z + x), $MachinePrecision]]
                        
                        \begin{array}{l}
                        
                        \\
                        \begin{array}{l}
                        \mathbf{if}\;y \leq -9 \cdot 10^{+137} \lor \neg \left(y \leq 2.6 \cdot 10^{-19}\right):\\
                        \;\;\;\;y + y\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;z + x\\
                        
                        
                        \end{array}
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if y < -9.0000000000000003e137 or 2.60000000000000013e-19 < 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. Applied rewrites64.5%

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

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

                              if -9.0000000000000003e137 < y < 2.60000000000000013e-19

                              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 inf

                                \[\leadsto \color{blue}{z} + x \]
                              4. Step-by-step derivation
                                1. Applied rewrites56.5%

                                  \[\leadsto \color{blue}{z} + x \]
                              5. Recombined 2 regimes into one program.
                              6. Final simplification59.9%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{+137} \lor \neg \left(y \leq 2.6 \cdot 10^{-19}\right):\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;z + x\\ \end{array} \]
                              7. Add Preprocessing

                              Alternative 7: 51.8% accurate, 1.0× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+17}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-32}:\\ \;\;\;\;y + y\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \end{array} \]
                              (FPCore (x y z)
                               :precision binary64
                               (if (<= z -7e+17) z (if (<= z 2.4e-32) (+ y y) z)))
                              double code(double x, double y, double z) {
                              	double tmp;
                              	if (z <= -7e+17) {
                              		tmp = z;
                              	} else if (z <= 2.4e-32) {
                              		tmp = y + y;
                              	} else {
                              		tmp = z;
                              	}
                              	return tmp;
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(x, y, z)
                              use fmin_fmax_functions
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  real(8), intent (in) :: z
                                  real(8) :: tmp
                                  if (z <= (-7d+17)) then
                                      tmp = z
                                  else if (z <= 2.4d-32) then
                                      tmp = y + y
                                  else
                                      tmp = z
                                  end if
                                  code = tmp
                              end function
                              
                              public static double code(double x, double y, double z) {
                              	double tmp;
                              	if (z <= -7e+17) {
                              		tmp = z;
                              	} else if (z <= 2.4e-32) {
                              		tmp = y + y;
                              	} else {
                              		tmp = z;
                              	}
                              	return tmp;
                              }
                              
                              def code(x, y, z):
                              	tmp = 0
                              	if z <= -7e+17:
                              		tmp = z
                              	elif z <= 2.4e-32:
                              		tmp = y + y
                              	else:
                              		tmp = z
                              	return tmp
                              
                              function code(x, y, z)
                              	tmp = 0.0
                              	if (z <= -7e+17)
                              		tmp = z;
                              	elseif (z <= 2.4e-32)
                              		tmp = Float64(y + y);
                              	else
                              		tmp = z;
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(x, y, z)
                              	tmp = 0.0;
                              	if (z <= -7e+17)
                              		tmp = z;
                              	elseif (z <= 2.4e-32)
                              		tmp = y + y;
                              	else
                              		tmp = z;
                              	end
                              	tmp_2 = tmp;
                              end
                              
                              code[x_, y_, z_] := If[LessEqual[z, -7e+17], z, If[LessEqual[z, 2.4e-32], N[(y + y), $MachinePrecision], z]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              \mathbf{if}\;z \leq -7 \cdot 10^{+17}:\\
                              \;\;\;\;z\\
                              
                              \mathbf{elif}\;z \leq 2.4 \cdot 10^{-32}:\\
                              \;\;\;\;y + y\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;z\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if z < -7e17 or 2.4000000000000001e-32 < 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 z around inf

                                  \[\leadsto \color{blue}{z} \]
                                4. Step-by-step derivation
                                  1. Applied rewrites64.5%

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

                                  if -7e17 < z < 2.4000000000000001e-32

                                  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. Applied rewrites47.6%

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

                                        \[\leadsto y + \color{blue}{y} \]
                                    3. Recombined 2 regimes into one program.
                                    4. Add Preprocessing

                                    Alternative 8: 33.9% accurate, 16.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;
                                    }
                                    
                                    module fmin_fmax_functions
                                        implicit none
                                        private
                                        public fmax
                                        public fmin
                                    
                                        interface fmax
                                            module procedure fmax88
                                            module procedure fmax44
                                            module procedure fmax84
                                            module procedure fmax48
                                        end interface
                                        interface fmin
                                            module procedure fmin88
                                            module procedure fmin44
                                            module procedure fmin84
                                            module procedure fmin48
                                        end interface
                                    contains
                                        real(8) function fmax88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmax44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmax84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmax48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmin44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmin48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                        end function
                                    end module
                                    
                                    real(8) function code(x, y, z)
                                    use fmin_fmax_functions
                                        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. Add Preprocessing
                                    3. Taylor expanded in z around inf

                                      \[\leadsto \color{blue}{z} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites37.9%

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

                                      Reproduce

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