Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C

Percentage Accurate: 99.9% → 99.9%
Time: 39.2s
Alternatives: 6
Speedup: 1.0×

Specification

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

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

Alternative 1: 97.9% accurate, 0.7× speedup?

\[\begin{array}{l} t_0 := x \cdot \left(y + z\right)\\ \mathbf{if}\;x \leq -359999999999999968877868109266944:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 40000000:\\ \;\;\;\;x \cdot y + z \cdot 5\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y z)
  :precision binary64
  (let* ((t_0 (* x (+ y z))))
  (if (<= x -359999999999999968877868109266944)
    t_0
    (if (<= x 40000000) (+ (* x y) (* z 5)) t_0))))
double code(double x, double y, double z) {
	double t_0 = x * (y + z);
	double tmp;
	if (x <= -3.6e+32) {
		tmp = t_0;
	} else if (x <= 40000000.0) {
		tmp = (x * y) + (z * 5.0);
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = x * (y + z)
    if (x <= (-3.6d+32)) then
        tmp = t_0
    else if (x <= 40000000.0d0) then
        tmp = (x * y) + (z * 5.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (y + z);
	double tmp;
	if (x <= -3.6e+32) {
		tmp = t_0;
	} else if (x <= 40000000.0) {
		tmp = (x * y) + (z * 5.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y + z)
	tmp = 0
	if x <= -3.6e+32:
		tmp = t_0
	elif x <= 40000000.0:
		tmp = (x * y) + (z * 5.0)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(y + z))
	tmp = 0.0
	if (x <= -3.6e+32)
		tmp = t_0;
	elseif (x <= 40000000.0)
		tmp = Float64(Float64(x * y) + Float64(z * 5.0));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (y + z);
	tmp = 0.0;
	if (x <= -3.6e+32)
		tmp = t_0;
	elseif (x <= 40000000.0)
		tmp = (x * y) + (z * 5.0);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -359999999999999968877868109266944], t$95$0, If[LessEqual[x, 40000000], N[(N[(x * y), $MachinePrecision] + N[(z * 5), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
\mathbf{if}\;x \leq -359999999999999968877868109266944:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 40000000:\\
\;\;\;\;x \cdot y + z \cdot 5\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.5999999999999997e32 or 4e7 < x

    1. Initial program 99.9%

      \[x \cdot \left(y + z\right) + z \cdot 5 \]
    2. Taylor expanded in x around inf

      \[\leadsto \color{blue}{x \cdot \left(y + \left(z + 5 \cdot \frac{z}{x}\right)\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

        \[\leadsto x \cdot \left(y + \left(z + 5 \cdot \color{blue}{\frac{z}{x}}\right)\right) \]
      5. lower-/.f6488.0%

        \[\leadsto x \cdot \left(y + \left(z + 5 \cdot \frac{z}{\color{blue}{x}}\right)\right) \]
    4. Applied rewrites88.0%

      \[\leadsto \color{blue}{x \cdot \left(y + \left(z + 5 \cdot \frac{z}{x}\right)\right)} \]
    5. Taylor expanded in x around inf

      \[\leadsto x \cdot \left(y + z\right) \]
    6. Step-by-step derivation
      1. Applied rewrites65.5%

        \[\leadsto x \cdot \left(y + z\right) \]

      if -3.5999999999999997e32 < x < 4e7

      1. Initial program 99.9%

        \[x \cdot \left(y + z\right) + z \cdot 5 \]
      2. Taylor expanded in y around inf

        \[\leadsto \color{blue}{x \cdot y} + z \cdot 5 \]
      3. Step-by-step derivation
        1. lower-*.f6476.1%

          \[\leadsto x \cdot \color{blue}{y} + z \cdot 5 \]
      4. Applied rewrites76.1%

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

    Alternative 2: 84.9% accurate, 0.8× speedup?

    \[\begin{array}{l} t_0 := x \cdot \left(y + z\right)\\ \mathbf{if}\;x \leq \frac{-6070840288205403}{7588550360256754183279148073529370729071901715047420004889892225542594864082845696}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 680000000:\\ \;\;\;\;z \cdot \left(5 + x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
    (FPCore (x y z)
      :precision binary64
      (let* ((t_0 (* x (+ y z))))
      (if (<=
           x
           -6070840288205403/7588550360256754183279148073529370729071901715047420004889892225542594864082845696)
        t_0
        (if (<= x 680000000) (* z (+ 5 x)) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = x * (y + z);
    	double tmp;
    	if (x <= -8e-67) {
    		tmp = t_0;
    	} else if (x <= 680000000.0) {
    		tmp = z * (5.0 + x);
    	} else {
    		tmp = t_0;
    	}
    	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) :: t_0
        real(8) :: tmp
        t_0 = x * (y + z)
        if (x <= (-8d-67)) then
            tmp = t_0
        else if (x <= 680000000.0d0) then
            tmp = z * (5.0d0 + x)
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double x, double y, double z) {
    	double t_0 = x * (y + z);
    	double tmp;
    	if (x <= -8e-67) {
    		tmp = t_0;
    	} else if (x <= 680000000.0) {
    		tmp = z * (5.0 + x);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	t_0 = x * (y + z)
    	tmp = 0
    	if x <= -8e-67:
    		tmp = t_0
    	elif x <= 680000000.0:
    		tmp = z * (5.0 + x)
    	else:
    		tmp = t_0
    	return tmp
    
    function code(x, y, z)
    	t_0 = Float64(x * Float64(y + z))
    	tmp = 0.0
    	if (x <= -8e-67)
    		tmp = t_0;
    	elseif (x <= 680000000.0)
    		tmp = Float64(z * Float64(5.0 + x));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, y, z)
    	t_0 = x * (y + z);
    	tmp = 0.0;
    	if (x <= -8e-67)
    		tmp = t_0;
    	elseif (x <= 680000000.0)
    		tmp = z * (5.0 + x);
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6070840288205403/7588550360256754183279148073529370729071901715047420004889892225542594864082845696], t$95$0, If[LessEqual[x, 680000000], N[(z * N[(5 + x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    t_0 := x \cdot \left(y + z\right)\\
    \mathbf{if}\;x \leq \frac{-6070840288205403}{7588550360256754183279148073529370729071901715047420004889892225542594864082845696}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;x \leq 680000000:\\
    \;\;\;\;z \cdot \left(5 + x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -7.9999999999999995e-67 or 6.8e8 < x

      1. Initial program 99.9%

        \[x \cdot \left(y + z\right) + z \cdot 5 \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x \cdot \left(y + \left(z + 5 \cdot \frac{z}{x}\right)\right)} \]
      3. Step-by-step derivation
        1. lower-*.f64N/A

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

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

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

          \[\leadsto x \cdot \left(y + \left(z + 5 \cdot \color{blue}{\frac{z}{x}}\right)\right) \]
        5. lower-/.f6488.0%

          \[\leadsto x \cdot \left(y + \left(z + 5 \cdot \frac{z}{\color{blue}{x}}\right)\right) \]
      4. Applied rewrites88.0%

        \[\leadsto \color{blue}{x \cdot \left(y + \left(z + 5 \cdot \frac{z}{x}\right)\right)} \]
      5. Taylor expanded in x around inf

        \[\leadsto x \cdot \left(y + z\right) \]
      6. Step-by-step derivation
        1. Applied rewrites65.5%

          \[\leadsto x \cdot \left(y + z\right) \]

        if -7.9999999999999995e-67 < x < 6.8e8

        1. Initial program 99.9%

          \[x \cdot \left(y + z\right) + z \cdot 5 \]
        2. Taylor expanded in z around inf

          \[\leadsto \color{blue}{z \cdot \left(5 + x\right)} \]
        3. Step-by-step derivation
          1. lower-*.f64N/A

            \[\leadsto z \cdot \color{blue}{\left(5 + x\right)} \]
          2. lower-+.f6461.7%

            \[\leadsto z \cdot \left(5 + \color{blue}{x}\right) \]
        4. Applied rewrites61.7%

          \[\leadsto \color{blue}{z \cdot \left(5 + x\right)} \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 3: 84.4% accurate, 0.8× speedup?

      \[\begin{array}{l} t_0 := x \cdot \left(y + z\right)\\ \mathbf{if}\;x \leq \frac{-6070840288205403}{7588550360256754183279148073529370729071901715047420004889892225542594864082845696}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq \frac{3882113724160211}{5708990770823839524233143877797980545530986496}:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
      (FPCore (x y z)
        :precision binary64
        (let* ((t_0 (* x (+ y z))))
        (if (<=
             x
             -6070840288205403/7588550360256754183279148073529370729071901715047420004889892225542594864082845696)
          t_0
          (if (<=
               x
               3882113724160211/5708990770823839524233143877797980545530986496)
            (* 5 z)
            t_0))))
      double code(double x, double y, double z) {
      	double t_0 = x * (y + z);
      	double tmp;
      	if (x <= -8e-67) {
      		tmp = t_0;
      	} else if (x <= 6.8e-31) {
      		tmp = 5.0 * z;
      	} else {
      		tmp = t_0;
      	}
      	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) :: t_0
          real(8) :: tmp
          t_0 = x * (y + z)
          if (x <= (-8d-67)) then
              tmp = t_0
          else if (x <= 6.8d-31) then
              tmp = 5.0d0 * z
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = x * (y + z);
      	double tmp;
      	if (x <= -8e-67) {
      		tmp = t_0;
      	} else if (x <= 6.8e-31) {
      		tmp = 5.0 * z;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = x * (y + z)
      	tmp = 0
      	if x <= -8e-67:
      		tmp = t_0
      	elif x <= 6.8e-31:
      		tmp = 5.0 * z
      	else:
      		tmp = t_0
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(x * Float64(y + z))
      	tmp = 0.0
      	if (x <= -8e-67)
      		tmp = t_0;
      	elseif (x <= 6.8e-31)
      		tmp = Float64(5.0 * z);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = x * (y + z);
      	tmp = 0.0;
      	if (x <= -8e-67)
      		tmp = t_0;
      	elseif (x <= 6.8e-31)
      		tmp = 5.0 * z;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6070840288205403/7588550360256754183279148073529370729071901715047420004889892225542594864082845696], t$95$0, If[LessEqual[x, 3882113724160211/5708990770823839524233143877797980545530986496], N[(5 * z), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      t_0 := x \cdot \left(y + z\right)\\
      \mathbf{if}\;x \leq \frac{-6070840288205403}{7588550360256754183279148073529370729071901715047420004889892225542594864082845696}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;x \leq \frac{3882113724160211}{5708990770823839524233143877797980545530986496}:\\
      \;\;\;\;5 \cdot z\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -7.9999999999999995e-67 or 6.8000000000000002e-31 < x

        1. Initial program 99.9%

          \[x \cdot \left(y + z\right) + z \cdot 5 \]
        2. Taylor expanded in x around inf

          \[\leadsto \color{blue}{x \cdot \left(y + \left(z + 5 \cdot \frac{z}{x}\right)\right)} \]
        3. Step-by-step derivation
          1. lower-*.f64N/A

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

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

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

            \[\leadsto x \cdot \left(y + \left(z + 5 \cdot \color{blue}{\frac{z}{x}}\right)\right) \]
          5. lower-/.f6488.0%

            \[\leadsto x \cdot \left(y + \left(z + 5 \cdot \frac{z}{\color{blue}{x}}\right)\right) \]
        4. Applied rewrites88.0%

          \[\leadsto \color{blue}{x \cdot \left(y + \left(z + 5 \cdot \frac{z}{x}\right)\right)} \]
        5. Taylor expanded in x around inf

          \[\leadsto x \cdot \left(y + z\right) \]
        6. Step-by-step derivation
          1. Applied rewrites65.5%

            \[\leadsto x \cdot \left(y + z\right) \]

          if -7.9999999999999995e-67 < x < 6.8000000000000002e-31

          1. Initial program 99.9%

            \[x \cdot \left(y + z\right) + z \cdot 5 \]
          2. Taylor expanded in x around 0

            \[\leadsto \color{blue}{5 \cdot z} \]
          3. Step-by-step derivation
            1. lower-*.f6436.2%

              \[\leadsto 5 \cdot \color{blue}{z} \]
          4. Applied rewrites36.2%

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

        Alternative 4: 60.0% accurate, 0.9× speedup?

        \[\begin{array}{l} \mathbf{if}\;x \leq -30999999999999997869293568:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq 40000000:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
        (FPCore (x y z)
          :precision binary64
          (if (<= x -30999999999999997869293568)
          (* x z)
          (if (<= x 40000000) (* 5 z) (* x z))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -3.1e+25) {
        		tmp = x * z;
        	} else if (x <= 40000000.0) {
        		tmp = 5.0 * z;
        	} else {
        		tmp = x * 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 (x <= (-3.1d+25)) then
                tmp = x * z
            else if (x <= 40000000.0d0) then
                tmp = 5.0d0 * z
            else
                tmp = x * z
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -3.1e+25) {
        		tmp = x * z;
        	} else if (x <= 40000000.0) {
        		tmp = 5.0 * z;
        	} else {
        		tmp = x * z;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if x <= -3.1e+25:
        		tmp = x * z
        	elif x <= 40000000.0:
        		tmp = 5.0 * z
        	else:
        		tmp = x * z
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (x <= -3.1e+25)
        		tmp = Float64(x * z);
        	elseif (x <= 40000000.0)
        		tmp = Float64(5.0 * z);
        	else
        		tmp = Float64(x * z);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (x <= -3.1e+25)
        		tmp = x * z;
        	elseif (x <= 40000000.0)
        		tmp = 5.0 * z;
        	else
        		tmp = x * z;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[x, -30999999999999997869293568], N[(x * z), $MachinePrecision], If[LessEqual[x, 40000000], N[(5 * z), $MachinePrecision], N[(x * z), $MachinePrecision]]]
        
        \begin{array}{l}
        \mathbf{if}\;x \leq -30999999999999997869293568:\\
        \;\;\;\;x \cdot z\\
        
        \mathbf{elif}\;x \leq 40000000:\\
        \;\;\;\;5 \cdot z\\
        
        \mathbf{else}:\\
        \;\;\;\;x \cdot z\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < -3.0999999999999998e25 or 4e7 < x

          1. Initial program 99.9%

            \[x \cdot \left(y + z\right) + z \cdot 5 \]
          2. Step-by-step derivation
            1. lift-+.f64N/A

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

              \[\leadsto \color{blue}{x \cdot \left(y + z\right) - \left(\mathsf{neg}\left(z \cdot 5\right)\right)} \]
            3. sub-negate-revN/A

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

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

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

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

              \[\leadsto \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(z\right)\right) \cdot 5 - x \cdot \color{blue}{\left(y + z\right)}\right)\right) \]
            8. +-commutativeN/A

              \[\leadsto \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(z\right)\right) \cdot 5 - x \cdot \color{blue}{\left(z + y\right)}\right)\right) \]
            9. distribute-lft-inN/A

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

              \[\leadsto \mathsf{neg}\left(\color{blue}{\left(\left(\left(\mathsf{neg}\left(z\right)\right) \cdot 5 - x \cdot z\right) - x \cdot y\right)}\right) \]
            11. sub-negate-revN/A

              \[\leadsto \color{blue}{x \cdot y - \left(\left(\mathsf{neg}\left(z\right)\right) \cdot 5 - x \cdot z\right)} \]
            12. lower--.f64N/A

              \[\leadsto \color{blue}{x \cdot y - \left(\left(\mathsf{neg}\left(z\right)\right) \cdot 5 - x \cdot z\right)} \]
            13. *-commutativeN/A

              \[\leadsto \color{blue}{y \cdot x} - \left(\left(\mathsf{neg}\left(z\right)\right) \cdot 5 - x \cdot z\right) \]
            14. lower-*.f64N/A

              \[\leadsto \color{blue}{y \cdot x} - \left(\left(\mathsf{neg}\left(z\right)\right) \cdot 5 - x \cdot z\right) \]
            15. distribute-lft-neg-outN/A

              \[\leadsto y \cdot x - \left(\color{blue}{\left(\mathsf{neg}\left(z \cdot 5\right)\right)} - x \cdot z\right) \]
            16. distribute-rgt-neg-inN/A

              \[\leadsto y \cdot x - \left(\color{blue}{z \cdot \left(\mathsf{neg}\left(5\right)\right)} - x \cdot z\right) \]
            17. *-commutativeN/A

              \[\leadsto y \cdot x - \left(z \cdot \left(\mathsf{neg}\left(5\right)\right) - \color{blue}{z \cdot x}\right) \]
            18. distribute-lft-out--N/A

              \[\leadsto y \cdot x - \color{blue}{z \cdot \left(\left(\mathsf{neg}\left(5\right)\right) - x\right)} \]
            19. *-commutativeN/A

              \[\leadsto y \cdot x - \color{blue}{\left(\left(\mathsf{neg}\left(5\right)\right) - x\right) \cdot z} \]
            20. lower-*.f64N/A

              \[\leadsto y \cdot x - \color{blue}{\left(\left(\mathsf{neg}\left(5\right)\right) - x\right) \cdot z} \]
            21. lower--.f64N/A

              \[\leadsto y \cdot x - \color{blue}{\left(\left(\mathsf{neg}\left(5\right)\right) - x\right)} \cdot z \]
            22. metadata-eval97.8%

              \[\leadsto y \cdot x - \left(\color{blue}{-5} - x\right) \cdot z \]
          3. Applied rewrites97.8%

            \[\leadsto \color{blue}{y \cdot x - \left(-5 - x\right) \cdot z} \]
          4. Taylor expanded in y around 0

            \[\leadsto \color{blue}{z \cdot \left(5 + x\right)} \]
          5. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto z \cdot \color{blue}{\left(5 + x\right)} \]
            2. lower-+.f6461.7%

              \[\leadsto z \cdot \left(5 + \color{blue}{x}\right) \]
          6. Applied rewrites61.7%

            \[\leadsto \color{blue}{z \cdot \left(5 + x\right)} \]
          7. Taylor expanded in x around inf

            \[\leadsto x \cdot \color{blue}{z} \]
          8. Step-by-step derivation
            1. lower-*.f6428.0%

              \[\leadsto x \cdot z \]
          9. Applied rewrites28.0%

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

          if -3.0999999999999998e25 < x < 4e7

          1. Initial program 99.9%

            \[x \cdot \left(y + z\right) + z \cdot 5 \]
          2. Taylor expanded in x around 0

            \[\leadsto \color{blue}{5 \cdot z} \]
          3. Step-by-step derivation
            1. lower-*.f6436.2%

              \[\leadsto 5 \cdot \color{blue}{z} \]
          4. Applied rewrites36.2%

            \[\leadsto \color{blue}{5 \cdot z} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 5: 36.2% accurate, 2.8× speedup?

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

          \[x \cdot \left(y + z\right) + z \cdot 5 \]
        2. Taylor expanded in x around 0

          \[\leadsto \color{blue}{5 \cdot z} \]
        3. Step-by-step derivation
          1. lower-*.f6436.2%

            \[\leadsto 5 \cdot \color{blue}{z} \]
        4. Applied rewrites36.2%

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

        Reproduce

        ?
        herbie shell --seed 2025271 -o generate:evaluate
        (FPCore (x y z)
          :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
          :precision binary64
          (+ (* x (+ y z)) (* z 5)))