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

Percentage Accurate: 99.9% → 100.0%
Time: 2.5s
Alternatives: 10
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ x \cdot \left(y + z\right) + z \cdot 5 \end{array} \]
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
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.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}

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 10 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} \\ x \cdot \left(y + z\right) + z \cdot 5 \end{array} \]
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
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.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot \left(y + z\right) + z \cdot 5
\end{array}

Alternative 1: 100.0% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, 5, \left(z + y\right) \cdot x\right)} \]
  4. Add Preprocessing

Alternative 2: 99.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+211}:\\ \;\;\;\;\left(z + y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x - -5, z, y \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1e+211) (* (+ z y) x) (fma (- x -5.0) z (* y x))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1e+211) {
		tmp = (z + y) * x;
	} else {
		tmp = fma((x - -5.0), z, (y * x));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (x <= -1e+211)
		tmp = Float64(Float64(z + y) * x);
	else
		tmp = fma(Float64(x - -5.0), z, Float64(y * x));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[x, -1e+211], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], N[(N[(x - -5.0), $MachinePrecision] * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+211}:\\
\;\;\;\;\left(z + y\right) \cdot x\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x - -5, z, y \cdot x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.9999999999999996e210

    1. Initial program 99.8%

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

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

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

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

        \[\leadsto \left(z + y\right) \cdot x \]
      4. lower-+.f64100.0

        \[\leadsto \left(z + y\right) \cdot x \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\left(z + y\right) \cdot x} \]

    if -9.9999999999999996e210 < 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 x \cdot \left(y + z\right) + \color{blue}{z \cdot 5} \]
      2. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(\mathsf{neg}\left(5\right)\right)}, z, x \cdot y\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{fma}\left(x - -5, z, \color{blue}{y \cdot x}\right) \]
      18. lower-*.f6499.2

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

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

Alternative 3: 98.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -130:\\ \;\;\;\;\left(z + y\right) \cdot x\\ \mathbf{elif}\;x \leq 5:\\ \;\;\;\;\mathsf{fma}\left(5, z, y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, z, y \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -130.0)
   (* (+ z y) x)
   (if (<= x 5.0) (fma 5.0 z (* y x)) (fma x z (* y x)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -130.0) {
		tmp = (z + y) * x;
	} else if (x <= 5.0) {
		tmp = fma(5.0, z, (y * x));
	} else {
		tmp = fma(x, z, (y * x));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (x <= -130.0)
		tmp = Float64(Float64(z + y) * x);
	elseif (x <= 5.0)
		tmp = fma(5.0, z, Float64(y * x));
	else
		tmp = fma(x, z, Float64(y * x));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[x, -130.0], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 5.0], N[(5.0 * z + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * z + N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -130:\\
\;\;\;\;\left(z + y\right) \cdot x\\

\mathbf{elif}\;x \leq 5:\\
\;\;\;\;\mathsf{fma}\left(5, z, y \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -130

    1. Initial program 99.8%

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

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

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

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

        \[\leadsto \left(z + y\right) \cdot x \]
      4. lower-+.f6499.0

        \[\leadsto \left(z + y\right) \cdot x \]
    4. Applied rewrites99.0%

      \[\leadsto \color{blue}{\left(z + y\right) \cdot x} \]

    if -130 < x < 5

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(\mathsf{neg}\left(5\right)\right)}, z, x \cdot y\right) \]
      15. metadata-evalN/A

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

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

        \[\leadsto \mathsf{fma}\left(x - -5, z, \color{blue}{y \cdot x}\right) \]
      18. lower-*.f6499.9

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{5}, z, y \cdot x\right) \]
    5. Step-by-step derivation
      1. Applied rewrites98.8%

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

      if 5 < x

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(\mathsf{neg}\left(5\right)\right)}, z, x \cdot y\right) \]
        15. metadata-evalN/A

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

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

          \[\leadsto \mathsf{fma}\left(x - -5, z, \color{blue}{y \cdot x}\right) \]
        18. lower-*.f6498.1

          \[\leadsto \mathsf{fma}\left(x - -5, z, \color{blue}{y \cdot x}\right) \]
      3. Applied rewrites98.1%

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{x}, z, y \cdot x\right) \]
      5. Step-by-step derivation
        1. Applied rewrites96.9%

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

      Alternative 4: 98.4% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z + y\right) \cdot x\\ \mathbf{if}\;x \leq -130:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 5:\\ \;\;\;\;\mathsf{fma}\left(5, z, y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* (+ z y) x)))
         (if (<= x -130.0) t_0 (if (<= x 5.0) (fma 5.0 z (* y x)) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = (z + y) * x;
      	double tmp;
      	if (x <= -130.0) {
      		tmp = t_0;
      	} else if (x <= 5.0) {
      		tmp = fma(5.0, z, (y * x));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	t_0 = Float64(Float64(z + y) * x)
      	tmp = 0.0
      	if (x <= -130.0)
      		tmp = t_0;
      	elseif (x <= 5.0)
      		tmp = fma(5.0, z, Float64(y * x));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -130.0], t$95$0, If[LessEqual[x, 5.0], N[(5.0 * z + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \left(z + y\right) \cdot x\\
      \mathbf{if}\;x \leq -130:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;x \leq 5:\\
      \;\;\;\;\mathsf{fma}\left(5, z, y \cdot x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -130 or 5 < 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 + z\right)} \]
        3. Step-by-step derivation
          1. *-commutativeN/A

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

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

            \[\leadsto \left(z + y\right) \cdot x \]
          4. lower-+.f6498.9

            \[\leadsto \left(z + y\right) \cdot x \]
        4. Applied rewrites98.9%

          \[\leadsto \color{blue}{\left(z + y\right) \cdot x} \]

        if -130 < x < 5

        1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{x - \left(\mathsf{neg}\left(5\right)\right)}, z, x \cdot y\right) \]
          15. metadata-evalN/A

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

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

            \[\leadsto \mathsf{fma}\left(x - -5, z, \color{blue}{y \cdot x}\right) \]
          18. lower-*.f6499.9

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

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

          \[\leadsto \mathsf{fma}\left(\color{blue}{5}, z, y \cdot x\right) \]
        5. Step-by-step derivation
          1. Applied rewrites98.8%

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

        Alternative 5: 80.8% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(z, 5, z \cdot x\right)\\ \mathbf{if}\;z \leq -1.05:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 7.1 \cdot 10^{+31}:\\ \;\;\;\;\left(z + y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (fma z 5.0 (* z x))))
           (if (<= z -1.05) t_0 (if (<= z 7.1e+31) (* (+ z y) x) t_0))))
        double code(double x, double y, double z) {
        	double t_0 = fma(z, 5.0, (z * x));
        	double tmp;
        	if (z <= -1.05) {
        		tmp = t_0;
        	} else if (z <= 7.1e+31) {
        		tmp = (z + y) * x;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	t_0 = fma(z, 5.0, Float64(z * x))
        	tmp = 0.0
        	if (z <= -1.05)
        		tmp = t_0;
        	elseif (z <= 7.1e+31)
        		tmp = Float64(Float64(z + y) * x);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(z * 5.0 + N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.05], t$95$0, If[LessEqual[z, 7.1e+31], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{fma}\left(z, 5, z \cdot x\right)\\
        \mathbf{if}\;z \leq -1.05:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;z \leq 7.1 \cdot 10^{+31}:\\
        \;\;\;\;\left(z + y\right) \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < -1.05000000000000004 or 7.09999999999999961e31 < z

          1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(z, 5, \color{blue}{z} \cdot x\right) \]
          5. Step-by-step derivation
            1. +-commutative86.5

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

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

          if -1.05000000000000004 < z < 7.09999999999999961e31

          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 + z\right)} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

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

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

              \[\leadsto \left(z + y\right) \cdot x \]
            4. lower-+.f6475.5

              \[\leadsto \left(z + y\right) \cdot x \]
          4. Applied rewrites75.5%

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

        Alternative 6: 80.7% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x - -5\right) \cdot z\\ \mathbf{if}\;z \leq -1.05:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 7.1 \cdot 10^{+31}:\\ \;\;\;\;\left(z + y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (* (- x -5.0) z)))
           (if (<= z -1.05) t_0 (if (<= z 7.1e+31) (* (+ z y) x) t_0))))
        double code(double x, double y, double z) {
        	double t_0 = (x - -5.0) * z;
        	double tmp;
        	if (z <= -1.05) {
        		tmp = t_0;
        	} else if (z <= 7.1e+31) {
        		tmp = (z + y) * 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 - (-5.0d0)) * z
            if (z <= (-1.05d0)) then
                tmp = t_0
            else if (z <= 7.1d+31) then
                tmp = (z + y) * 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 - -5.0) * z;
        	double tmp;
        	if (z <= -1.05) {
        		tmp = t_0;
        	} else if (z <= 7.1e+31) {
        		tmp = (z + y) * x;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	t_0 = (x - -5.0) * z
        	tmp = 0
        	if z <= -1.05:
        		tmp = t_0
        	elif z <= 7.1e+31:
        		tmp = (z + y) * x
        	else:
        		tmp = t_0
        	return tmp
        
        function code(x, y, z)
        	t_0 = Float64(Float64(x - -5.0) * z)
        	tmp = 0.0
        	if (z <= -1.05)
        		tmp = t_0;
        	elseif (z <= 7.1e+31)
        		tmp = Float64(Float64(z + y) * x);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	t_0 = (x - -5.0) * z;
        	tmp = 0.0;
        	if (z <= -1.05)
        		tmp = t_0;
        	elseif (z <= 7.1e+31)
        		tmp = (z + y) * x;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -1.05], t$95$0, If[LessEqual[z, 7.1e+31], N[(N[(z + y), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(x - -5\right) \cdot z\\
        \mathbf{if}\;z \leq -1.05:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;z \leq 7.1 \cdot 10^{+31}:\\
        \;\;\;\;\left(z + y\right) \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < -1.05000000000000004 or 7.09999999999999961e31 < z

          1. Initial program 99.8%

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

            \[\leadsto \color{blue}{5 \cdot z + x \cdot z} \]
          3. Step-by-step derivation
            1. distribute-rgt-outN/A

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

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

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

              \[\leadsto \left(x + 5\right) \cdot z \]
            5. add-flipN/A

              \[\leadsto \left(x - \left(\mathsf{neg}\left(5\right)\right)\right) \cdot z \]
            6. metadata-evalN/A

              \[\leadsto \left(x - -5\right) \cdot z \]
            7. lower--.f6486.4

              \[\leadsto \left(x - -5\right) \cdot z \]
          4. Applied rewrites86.4%

            \[\leadsto \color{blue}{\left(x - -5\right) \cdot z} \]

          if -1.05000000000000004 < z < 7.09999999999999961e31

          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 + z\right)} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

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

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

              \[\leadsto \left(z + y\right) \cdot x \]
            4. lower-+.f6475.5

              \[\leadsto \left(z + y\right) \cdot x \]
          4. Applied rewrites75.5%

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

        Alternative 7: 75.5% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x - -5\right) \cdot z\\ \mathbf{if}\;z \leq -0.0052:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-120}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (* (- x -5.0) z)))
           (if (<= z -0.0052) t_0 (if (<= z 1.2e-120) (* y x) t_0))))
        double code(double x, double y, double z) {
        	double t_0 = (x - -5.0) * z;
        	double tmp;
        	if (z <= -0.0052) {
        		tmp = t_0;
        	} else if (z <= 1.2e-120) {
        		tmp = y * 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 - (-5.0d0)) * z
            if (z <= (-0.0052d0)) then
                tmp = t_0
            else if (z <= 1.2d-120) then
                tmp = y * 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 - -5.0) * z;
        	double tmp;
        	if (z <= -0.0052) {
        		tmp = t_0;
        	} else if (z <= 1.2e-120) {
        		tmp = y * x;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	t_0 = (x - -5.0) * z
        	tmp = 0
        	if z <= -0.0052:
        		tmp = t_0
        	elif z <= 1.2e-120:
        		tmp = y * x
        	else:
        		tmp = t_0
        	return tmp
        
        function code(x, y, z)
        	t_0 = Float64(Float64(x - -5.0) * z)
        	tmp = 0.0
        	if (z <= -0.0052)
        		tmp = t_0;
        	elseif (z <= 1.2e-120)
        		tmp = Float64(y * x);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	t_0 = (x - -5.0) * z;
        	tmp = 0.0;
        	if (z <= -0.0052)
        		tmp = t_0;
        	elseif (z <= 1.2e-120)
        		tmp = y * x;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -0.0052], t$95$0, If[LessEqual[z, 1.2e-120], N[(y * x), $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(x - -5\right) \cdot z\\
        \mathbf{if}\;z \leq -0.0052:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;z \leq 1.2 \cdot 10^{-120}:\\
        \;\;\;\;y \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if z < -0.0051999999999999998 or 1.2e-120 < z

          1. Initial program 99.8%

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

            \[\leadsto \color{blue}{5 \cdot z + x \cdot z} \]
          3. Step-by-step derivation
            1. distribute-rgt-outN/A

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

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

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

              \[\leadsto \left(x + 5\right) \cdot z \]
            5. add-flipN/A

              \[\leadsto \left(x - \left(\mathsf{neg}\left(5\right)\right)\right) \cdot z \]
            6. metadata-evalN/A

              \[\leadsto \left(x - -5\right) \cdot z \]
            7. lower--.f6480.2

              \[\leadsto \left(x - -5\right) \cdot z \]
          4. Applied rewrites80.2%

            \[\leadsto \color{blue}{\left(x - -5\right) \cdot z} \]

          if -0.0051999999999999998 < z < 1.2e-120

          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} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

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

              \[\leadsto y \cdot \color{blue}{x} \]
          4. Applied rewrites68.4%

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

        Alternative 8: 61.8% accurate, 0.6× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{+39}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{-44}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 3900:\\ \;\;\;\;5 \cdot z\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{+148}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= x -2.6e+39)
           (* x z)
           (if (<= x -2.15e-44)
             (* y x)
             (if (<= x 3900.0) (* 5.0 z) (if (<= x 9.2e+148) (* y x) (* x z))))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -2.6e+39) {
        		tmp = x * z;
        	} else if (x <= -2.15e-44) {
        		tmp = y * x;
        	} else if (x <= 3900.0) {
        		tmp = 5.0 * z;
        	} else if (x <= 9.2e+148) {
        		tmp = y * x;
        	} 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 <= (-2.6d+39)) then
                tmp = x * z
            else if (x <= (-2.15d-44)) then
                tmp = y * x
            else if (x <= 3900.0d0) then
                tmp = 5.0d0 * z
            else if (x <= 9.2d+148) then
                tmp = y * x
            else
                tmp = x * z
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (x <= -2.6e+39) {
        		tmp = x * z;
        	} else if (x <= -2.15e-44) {
        		tmp = y * x;
        	} else if (x <= 3900.0) {
        		tmp = 5.0 * z;
        	} else if (x <= 9.2e+148) {
        		tmp = y * x;
        	} else {
        		tmp = x * z;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if x <= -2.6e+39:
        		tmp = x * z
        	elif x <= -2.15e-44:
        		tmp = y * x
        	elif x <= 3900.0:
        		tmp = 5.0 * z
        	elif x <= 9.2e+148:
        		tmp = y * x
        	else:
        		tmp = x * z
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (x <= -2.6e+39)
        		tmp = Float64(x * z);
        	elseif (x <= -2.15e-44)
        		tmp = Float64(y * x);
        	elseif (x <= 3900.0)
        		tmp = Float64(5.0 * z);
        	elseif (x <= 9.2e+148)
        		tmp = Float64(y * x);
        	else
        		tmp = Float64(x * z);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (x <= -2.6e+39)
        		tmp = x * z;
        	elseif (x <= -2.15e-44)
        		tmp = y * x;
        	elseif (x <= 3900.0)
        		tmp = 5.0 * z;
        	elseif (x <= 9.2e+148)
        		tmp = y * x;
        	else
        		tmp = x * z;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[x, -2.6e+39], N[(x * z), $MachinePrecision], If[LessEqual[x, -2.15e-44], N[(y * x), $MachinePrecision], If[LessEqual[x, 3900.0], N[(5.0 * z), $MachinePrecision], If[LessEqual[x, 9.2e+148], N[(y * x), $MachinePrecision], N[(x * z), $MachinePrecision]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq -2.6 \cdot 10^{+39}:\\
        \;\;\;\;x \cdot z\\
        
        \mathbf{elif}\;x \leq -2.15 \cdot 10^{-44}:\\
        \;\;\;\;y \cdot x\\
        
        \mathbf{elif}\;x \leq 3900:\\
        \;\;\;\;5 \cdot z\\
        
        \mathbf{elif}\;x \leq 9.2 \cdot 10^{+148}:\\
        \;\;\;\;y \cdot x\\
        
        \mathbf{else}:\\
        \;\;\;\;x \cdot z\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if x < -2.6e39 or 9.2000000000000002e148 < x

          1. Initial program 99.9%

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

            \[\leadsto \color{blue}{5 \cdot z + x \cdot z} \]
          3. Step-by-step derivation
            1. distribute-rgt-outN/A

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

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

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

              \[\leadsto \left(x + 5\right) \cdot z \]
            5. add-flipN/A

              \[\leadsto \left(x - \left(\mathsf{neg}\left(5\right)\right)\right) \cdot z \]
            6. metadata-evalN/A

              \[\leadsto \left(x - -5\right) \cdot z \]
            7. lower--.f6453.8

              \[\leadsto \left(x - -5\right) \cdot z \]
          4. Applied rewrites53.8%

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

            \[\leadsto x \cdot z \]
          6. Step-by-step derivation
            1. Applied rewrites53.8%

              \[\leadsto x \cdot z \]

            if -2.6e39 < x < -2.15000000000000007e-44 or 3900 < x < 9.2000000000000002e148

            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} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto y \cdot \color{blue}{x} \]
            4. Applied rewrites52.1%

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

            if -2.15000000000000007e-44 < x < 3900

            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-*.f6471.6

                \[\leadsto 5 \cdot \color{blue}{z} \]
            4. Applied rewrites71.6%

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

          Alternative 9: 55.2% accurate, 1.1× speedup?

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

            1. Initial program 99.8%

              \[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-*.f6447.0

                \[\leadsto 5 \cdot \color{blue}{z} \]
            4. Applied rewrites47.0%

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

            if -1.05000000000000004 < z < 7.09999999999999961e31

            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} \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

                \[\leadsto y \cdot \color{blue}{x} \]
            4. Applied rewrites62.9%

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

          Alternative 10: 36.3% accurate, 3.1× speedup?

          \[\begin{array}{l} \\ 5 \cdot z \end{array} \]
          (FPCore (x y z) :precision binary64 (* 5.0 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.0 * z), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          5 \cdot z
          \end{array}
          
          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.3

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

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

          Reproduce

          ?
          herbie shell --seed 2025128 
          (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.0)))