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

Percentage Accurate: 99.9% → 99.9%
Time: 3.5s
Alternatives: 8
Speedup: 1.3×

Specification

?
\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
	return ((((x + y) + y) + x) + z) + x;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((((x + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
	return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z):
	return ((((x + y) + y) + x) + z) + x
function code(x, y, z)
	return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x)
end
function tmp = code(x, y, z)
	tmp = ((((x + y) + y) + x) + z) + x;
end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

\[\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x \]
(FPCore (x y z) :precision binary64 (+ (+ (+ (+ (+ x y) y) x) z) x))
double code(double x, double y, double z) {
	return ((((x + y) + y) + x) + z) + x;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((((x + y) + y) + x) + z) + x
end function
public static double code(double x, double y, double z) {
	return ((((x + y) + y) + x) + z) + x;
}
def code(x, y, z):
	return ((((x + y) + y) + x) + z) + x
function code(x, y, z)
	return Float64(Float64(Float64(Float64(Float64(x + y) + y) + x) + z) + x)
end
function tmp = code(x, y, z)
	tmp = ((((x + y) + y) + x) + z) + x;
end
code[x_, y_, z_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] + y), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision] + x), $MachinePrecision]
\left(\left(\left(\left(x + y\right) + y\right) + x\right) + z\right) + x

Alternative 1: 99.9% accurate, 1.3× speedup?

\[\mathsf{fma}\left(2, y + x, x\right) + z \]
(FPCore (x y z) :precision binary64 (+ (fma 2.0 (+ y x) x) z))
double code(double x, double y, double z) {
	return fma(2.0, (y + x), x) + z;
}
function code(x, y, z)
	return Float64(fma(2.0, Float64(y + x), x) + z)
end
code[x_, y_, z_] := N[(N[(2.0 * N[(y + x), $MachinePrecision] + x), $MachinePrecision] + z), $MachinePrecision]
\mathsf{fma}\left(2, y + x, x\right) + z
Derivation
  1. Initial program 99.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right) + z} \]
    6. add-flip-revN/A

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

      \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(\mathsf{neg}\left(x\right)\right)\right) + z} \]
    8. add-flip-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.7% accurate, 0.9× speedup?

\[\begin{array}{l} t_0 := \mathsf{fma}\left(2, y, x\right) + z\\ \mathbf{if}\;z \leq -13500:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-12}:\\ \;\;\;\;\mathsf{fma}\left(3, x, y \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (fma 2.0 y x) z)))
   (if (<= z -13500.0) t_0 (if (<= z 1.55e-12) (fma 3.0 x (* y 2.0)) t_0))))
double code(double x, double y, double z) {
	double t_0 = fma(2.0, y, x) + z;
	double tmp;
	if (z <= -13500.0) {
		tmp = t_0;
	} else if (z <= 1.55e-12) {
		tmp = fma(3.0, x, (y * 2.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(fma(2.0, y, x) + z)
	tmp = 0.0
	if (z <= -13500.0)
		tmp = t_0;
	elseif (z <= 1.55e-12)
		tmp = fma(3.0, x, Float64(y * 2.0));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 * y + x), $MachinePrecision] + z), $MachinePrecision]}, If[LessEqual[z, -13500.0], t$95$0, If[LessEqual[z, 1.55e-12], N[(3.0 * x + N[(y * 2.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(2, y, x\right) + z\\
\mathbf{if}\;z \leq -13500:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(3, x, y \cdot 2\right)\\

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


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -13500 or 1.5500000000000001e-12 < z

    1. Initial program 99.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right) + z} \]
      6. add-flip-revN/A

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

        \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(\mathsf{neg}\left(x\right)\right)\right) + z} \]
      8. add-flip-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -13500 < z < 1.5500000000000001e-12

      1. Initial program 99.9%

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

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

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

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

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

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

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

          \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
        7. lower-/.f6480.3

          \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
      4. Applied rewrites80.3%

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

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

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

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

          \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
        4. lower-/.f6488.6

          \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
      7. Applied rewrites88.6%

        \[\leadsto \mathsf{fma}\left(3, \color{blue}{x}, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
      8. Taylor expanded in y around inf

        \[\leadsto \mathsf{fma}\left(3, x, y \cdot 2\right) \]
      9. Step-by-step derivation
        1. Applied rewrites66.5%

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

      Alternative 3: 85.6% accurate, 0.9× speedup?

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

        1. Initial program 99.9%

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

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

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

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

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

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

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

            \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
          7. lower-/.f6480.3

            \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
        4. Applied rewrites80.3%

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

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

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

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

            \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
          4. lower-/.f6488.6

            \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
        7. Applied rewrites88.6%

          \[\leadsto \mathsf{fma}\left(3, \color{blue}{x}, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
        8. Taylor expanded in y around inf

          \[\leadsto \mathsf{fma}\left(3, x, y \cdot 2\right) \]
        9. Step-by-step derivation
          1. Applied rewrites66.5%

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

            \[\leadsto \mathsf{fma}\left(3, x, z\right) \]
          3. Step-by-step derivation
            1. Applied rewrites67.0%

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

            if -1.0600000000000001e29 < x < 1.15000000000000008e165

            1. Initial program 99.9%

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

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

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

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

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

                \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right) + z} \]
              6. add-flip-revN/A

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

                \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(\mathsf{neg}\left(x\right)\right)\right) + z} \]
              8. add-flip-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Alternative 4: 84.2% accurate, 1.0× speedup?

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

              1. Initial program 99.9%

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

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

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

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

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

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

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

                  \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
                7. lower-/.f6480.3

                  \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
              4. Applied rewrites80.3%

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
                4. lower-/.f6488.6

                  \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
              7. Applied rewrites88.6%

                \[\leadsto \mathsf{fma}\left(3, \color{blue}{x}, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
              8. Taylor expanded in y around inf

                \[\leadsto \mathsf{fma}\left(3, x, y \cdot 2\right) \]
              9. Step-by-step derivation
                1. Applied rewrites66.5%

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

                  \[\leadsto \mathsf{fma}\left(3, x, z\right) \]
                3. Step-by-step derivation
                  1. Applied rewrites67.0%

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

                  if -1.0600000000000001e29 < x < 1.15000000000000008e165

                  1. Initial program 99.9%

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

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

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

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

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

                      \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) + x\right) + z} \]
                    6. add-flip-revN/A

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

                      \[\leadsto \color{blue}{\left(\left(\left(\left(x + y\right) + y\right) + x\right) - \left(\mathsf{neg}\left(x\right)\right)\right) + z} \]
                    8. add-flip-revN/A

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{2 \cdot y} + z \]
                  5. Step-by-step derivation
                    1. lower-*.f6466.5

                      \[\leadsto 2 \cdot \color{blue}{y} + z \]
                  6. Applied rewrites66.5%

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

                      \[\leadsto 2 \cdot \color{blue}{y} + z \]
                    2. count-2-revN/A

                      \[\leadsto \left(y + \color{blue}{y}\right) + z \]
                    3. lower-+.f6466.5

                      \[\leadsto \left(y + \color{blue}{y}\right) + z \]
                  8. Applied rewrites66.5%

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

                Alternative 5: 79.7% accurate, 1.1× speedup?

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

                  1. Initial program 99.9%

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

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

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

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

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

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

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

                      \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
                    7. lower-/.f6480.3

                      \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
                  4. Applied rewrites80.3%

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

                    \[\leadsto y \cdot 2 \]
                  6. Step-by-step derivation
                    1. Applied rewrites33.9%

                      \[\leadsto y \cdot 2 \]

                    if -5.19999999999999973e116 < y < 4.60000000000000008e157

                    1. Initial program 99.9%

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

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

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

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

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

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

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

                        \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
                      7. lower-/.f6480.3

                        \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
                    4. Applied rewrites80.3%

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

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

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

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

                        \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
                      4. lower-/.f6488.6

                        \[\leadsto \mathsf{fma}\left(3, x, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
                    7. Applied rewrites88.6%

                      \[\leadsto \mathsf{fma}\left(3, \color{blue}{x}, y \cdot \left(2 + \frac{z}{y}\right)\right) \]
                    8. Taylor expanded in y around inf

                      \[\leadsto \mathsf{fma}\left(3, x, y \cdot 2\right) \]
                    9. Step-by-step derivation
                      1. Applied rewrites66.5%

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

                        \[\leadsto \mathsf{fma}\left(3, x, z\right) \]
                      3. Step-by-step derivation
                        1. Applied rewrites67.0%

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

                      Alternative 6: 54.9% accurate, 1.3× speedup?

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

                        1. Initial program 99.9%

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

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

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

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

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

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

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

                            \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
                          7. lower-/.f6480.3

                            \[\leadsto y \cdot \left(2 + \mathsf{fma}\left(2, \frac{x}{y}, \frac{x}{y} + \frac{z}{y}\right)\right) \]
                        4. Applied rewrites80.3%

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

                          \[\leadsto y \cdot 2 \]
                        6. Step-by-step derivation
                          1. Applied rewrites33.9%

                            \[\leadsto y \cdot 2 \]

                          if -6.20000000000000026e57 < y < 4.60000000000000008e157

                          1. Initial program 99.9%

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

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

                              \[\leadsto \left(z + \color{blue}{2 \cdot x}\right) + x \]
                            2. lower-*.f6466.9

                              \[\leadsto \left(z + 2 \cdot \color{blue}{x}\right) + x \]
                          4. Applied rewrites66.9%

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

                            \[\leadsto z + x \]
                          6. Step-by-step derivation
                            1. Applied rewrites39.4%

                              \[\leadsto z + x \]
                          7. Recombined 2 regimes into one program.
                          8. Add Preprocessing

                          Alternative 7: 54.2% accurate, 1.3× speedup?

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

                            1. Initial program 99.9%

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

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

                                \[\leadsto \left(z + \color{blue}{2 \cdot x}\right) + x \]
                              2. lower-*.f6466.9

                                \[\leadsto \left(z + 2 \cdot \color{blue}{x}\right) + x \]
                            4. Applied rewrites66.9%

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

                              \[\leadsto z + x \]
                            6. Step-by-step derivation
                              1. Applied rewrites39.4%

                                \[\leadsto z + x \]

                              if -13500 < z < 1.5500000000000001e-12

                              1. Initial program 99.9%

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

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

                                  \[\leadsto 3 \cdot \color{blue}{x} \]
                              4. Applied rewrites34.4%

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

                            Alternative 8: 39.4% accurate, 3.9× speedup?

                            \[z + x \]
                            (FPCore (x y z) :precision binary64 (+ z x))
                            double code(double x, double y, double z) {
                            	return z + x;
                            }
                            
                            module fmin_fmax_functions
                                implicit none
                                private
                                public fmax
                                public fmin
                            
                                interface fmax
                                    module procedure fmax88
                                    module procedure fmax44
                                    module procedure fmax84
                                    module procedure fmax48
                                end interface
                                interface fmin
                                    module procedure fmin88
                                    module procedure fmin44
                                    module procedure fmin84
                                    module procedure fmin48
                                end interface
                            contains
                                real(8) function fmax88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmax44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmax84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmax48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                end function
                                real(8) function fmin88(x, y) result (res)
                                    real(8), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(4) function fmin44(x, y) result (res)
                                    real(4), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                end function
                                real(8) function fmin84(x, y) result(res)
                                    real(8), intent (in) :: x
                                    real(4), intent (in) :: y
                                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                end function
                                real(8) function fmin48(x, y) result(res)
                                    real(4), intent (in) :: x
                                    real(8), intent (in) :: y
                                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                end function
                            end module
                            
                            real(8) function code(x, y, z)
                            use fmin_fmax_functions
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                real(8), intent (in) :: z
                                code = z + x
                            end function
                            
                            public static double code(double x, double y, double z) {
                            	return z + x;
                            }
                            
                            def code(x, y, z):
                            	return z + x
                            
                            function code(x, y, z)
                            	return Float64(z + x)
                            end
                            
                            function tmp = code(x, y, z)
                            	tmp = z + x;
                            end
                            
                            code[x_, y_, z_] := N[(z + x), $MachinePrecision]
                            
                            z + x
                            
                            Derivation
                            1. Initial program 99.9%

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

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

                                \[\leadsto \left(z + \color{blue}{2 \cdot x}\right) + x \]
                              2. lower-*.f6466.9

                                \[\leadsto \left(z + 2 \cdot \color{blue}{x}\right) + x \]
                            4. Applied rewrites66.9%

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

                              \[\leadsto z + x \]
                            6. Step-by-step derivation
                              1. Applied rewrites39.4%

                                \[\leadsto z + x \]
                              2. Add Preprocessing

                              Reproduce

                              ?
                              herbie shell --seed 2025172 
                              (FPCore (x y z)
                                :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendInside from plot-0.2.3.4"
                                :precision binary64
                                (+ (+ (+ (+ (+ x y) y) x) z) x))