Linear.Quaternion:$c/ from linear-1.19.1.3, A

Percentage Accurate: 98.4% → 99.3%
Time: 2.7s
Alternatives: 10
Speedup: 1.3×

Specification

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

\\
\left(\left(x \cdot y + z \cdot z\right) + z \cdot z\right) + z \cdot z
\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: 98.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.3% accurate, 1.3× speedup?

\[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 5 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left(3 \cdot z\_m, z\_m, y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;z\_m \cdot z\_m\\ \end{array} \end{array} \]
z_m = (fabs.f64 z)
(FPCore (x y z_m)
 :precision binary64
 (if (<= z_m 5e+153) (fma (* 3.0 z_m) z_m (* y x)) (* z_m z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m) {
	double tmp;
	if (z_m <= 5e+153) {
		tmp = fma((3.0 * z_m), z_m, (y * x));
	} else {
		tmp = z_m * z_m;
	}
	return tmp;
}
z_m = abs(z)
function code(x, y, z_m)
	tmp = 0.0
	if (z_m <= 5e+153)
		tmp = fma(Float64(3.0 * z_m), z_m, Float64(y * x));
	else
		tmp = Float64(z_m * z_m);
	end
	return tmp
end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 5e+153], N[(N[(3.0 * z$95$m), $MachinePrecision] * z$95$m + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(z$95$m * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|

\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(3 \cdot z\_m, z\_m, y \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;z\_m \cdot z\_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 5.00000000000000018e153

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(2 \cdot {z}^{2} + z \cdot z\right) + x \cdot y} \]
      14. pow2N/A

        \[\leadsto \left(2 \cdot \color{blue}{\left(z \cdot z\right)} + z \cdot z\right) + x \cdot y \]
      15. distribute-lft1-inN/A

        \[\leadsto \color{blue}{\left(2 + 1\right) \cdot \left(z \cdot z\right)} + x \cdot y \]
      16. metadata-evalN/A

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

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

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

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

    if 5.00000000000000018e153 < z

    1. Initial program 98.4%

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

      \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
    3. Step-by-step derivation
      1. pow2N/A

        \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
      2. pow2N/A

        \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
      3. distribute-lft1-inN/A

        \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
      4. metadata-evalN/A

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

        \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
      6. lift-*.f6453.3

        \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
    4. Applied rewrites53.3%

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

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

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

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

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

        \[\leadsto \left(z \cdot 3\right) \cdot z \]
      6. lower-*.f6453.3

        \[\leadsto \left(z \cdot 3\right) \cdot z \]
    6. Applied rewrites53.3%

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

        \[\leadsto \left(z \cdot 3\right) \cdot z \]
      2. *-commutativeN/A

        \[\leadsto \left(3 \cdot z\right) \cdot z \]
      3. metadata-evalN/A

        \[\leadsto \left(\left(2 + 1\right) \cdot z\right) \cdot z \]
      4. distribute-lft1-inN/A

        \[\leadsto \left(2 \cdot z + z\right) \cdot z \]
      5. count-2-revN/A

        \[\leadsto \left(\left(z + z\right) + z\right) \cdot z \]
      6. associate-+l+N/A

        \[\leadsto \left(z + \left(z + z\right)\right) \cdot z \]
      7. flip-+N/A

        \[\leadsto \left(z + \frac{z \cdot z - z \cdot z}{z - z}\right) \cdot z \]
      8. pow2N/A

        \[\leadsto \left(z + \frac{{z}^{2} - z \cdot z}{z - z}\right) \cdot z \]
      9. pow2N/A

        \[\leadsto \left(z + \frac{{z}^{2} - {z}^{2}}{z - z}\right) \cdot z \]
      10. +-inversesN/A

        \[\leadsto \left(z + \frac{0}{z - z}\right) \cdot z \]
      11. metadata-evalN/A

        \[\leadsto \left(z + \frac{1 - 1}{z - z}\right) \cdot z \]
      12. metadata-evalN/A

        \[\leadsto \left(z + \frac{1 \cdot 1 - 1}{z - z}\right) \cdot z \]
      13. metadata-evalN/A

        \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{z - z}\right) \cdot z \]
      14. +-inversesN/A

        \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{0}\right) \cdot z \]
      15. metadata-evalN/A

        \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{1 - 1}\right) \cdot z \]
      16. flip-+N/A

        \[\leadsto \left(z + \left(1 + 1\right)\right) \cdot z \]
      17. metadata-evalN/A

        \[\leadsto \left(z + 2\right) \cdot z \]
      18. lower-+.f6429.4

        \[\leadsto \left(z + 2\right) \cdot z \]
    8. Applied rewrites29.4%

      \[\leadsto \left(z + 2\right) \cdot z \]
    9. Taylor expanded in z around inf

      \[\leadsto z \cdot z \]
    10. Step-by-step derivation
      1. Applied rewrites33.0%

        \[\leadsto z \cdot z \]
    11. Recombined 2 regimes into one program.
    12. Add Preprocessing

    Alternative 2: 86.0% accurate, 1.4× speedup?

    \[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\ \;\;\;\;\mathsf{fma}\left(z\_m, z\_m, x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z\_m, z\_m + z\_m, z\_m \cdot z\_m\right)\\ \end{array} \end{array} \]
    z_m = (fabs.f64 z)
    (FPCore (x y z_m)
     :precision binary64
     (if (<= z_m 6.3e-24) (fma z_m z_m (* x y)) (fma z_m (+ z_m z_m) (* z_m z_m))))
    z_m = fabs(z);
    double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 6.3e-24) {
    		tmp = fma(z_m, z_m, (x * y));
    	} else {
    		tmp = fma(z_m, (z_m + z_m), (z_m * z_m));
    	}
    	return tmp;
    }
    
    z_m = abs(z)
    function code(x, y, z_m)
    	tmp = 0.0
    	if (z_m <= 6.3e-24)
    		tmp = fma(z_m, z_m, Float64(x * y));
    	else
    		tmp = fma(z_m, Float64(z_m + z_m), Float64(z_m * z_m));
    	end
    	return tmp
    end
    
    z_m = N[Abs[z], $MachinePrecision]
    code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(z$95$m * z$95$m + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(z$95$m * N[(z$95$m + z$95$m), $MachinePrecision] + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    z_m = \left|z\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
    \;\;\;\;\mathsf{fma}\left(z\_m, z\_m, x \cdot y\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(z\_m, z\_m + z\_m, z\_m \cdot z\_m\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < 6.29999999999999979e-24

      1. Initial program 98.4%

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{z \cdot z + y \cdot x} \]
        4. lower-fma.f6478.0

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

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

          \[\leadsto \mathsf{fma}\left(z, z, x \cdot \color{blue}{y}\right) \]
        7. lower-*.f6478.0

          \[\leadsto \mathsf{fma}\left(z, z, x \cdot \color{blue}{y}\right) \]
      6. Applied rewrites78.0%

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

      if 6.29999999999999979e-24 < z

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
      3. Step-by-step derivation
        1. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
        2. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
        3. distribute-lft1-inN/A

          \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
        4. metadata-evalN/A

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        6. lift-*.f6453.3

          \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
      4. Applied rewrites53.3%

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

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        3. metadata-evalN/A

          \[\leadsto \left(2 + 1\right) \cdot \left(\color{blue}{z} \cdot z\right) \]
        4. distribute-lft1-inN/A

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

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

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

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

          \[\leadsto \mathsf{fma}\left(z, z + \color{blue}{z}, z \cdot z\right) \]
        9. lift-*.f6453.3

          \[\leadsto \mathsf{fma}\left(z, z + z, z \cdot z\right) \]
      6. Applied rewrites53.3%

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

    Alternative 3: 86.0% accurate, 1.7× speedup?

    \[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\ \;\;\;\;\mathsf{fma}\left(z\_m, z\_m, x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(z\_m \cdot 3\right) \cdot z\_m\\ \end{array} \end{array} \]
    z_m = (fabs.f64 z)
    (FPCore (x y z_m)
     :precision binary64
     (if (<= z_m 6.3e-24) (fma z_m z_m (* x y)) (* (* z_m 3.0) z_m)))
    z_m = fabs(z);
    double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 6.3e-24) {
    		tmp = fma(z_m, z_m, (x * y));
    	} else {
    		tmp = (z_m * 3.0) * z_m;
    	}
    	return tmp;
    }
    
    z_m = abs(z)
    function code(x, y, z_m)
    	tmp = 0.0
    	if (z_m <= 6.3e-24)
    		tmp = fma(z_m, z_m, Float64(x * y));
    	else
    		tmp = Float64(Float64(z_m * 3.0) * z_m);
    	end
    	return tmp
    end
    
    z_m = N[Abs[z], $MachinePrecision]
    code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(z$95$m * z$95$m + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m * 3.0), $MachinePrecision] * z$95$m), $MachinePrecision]]
    
    \begin{array}{l}
    z_m = \left|z\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
    \;\;\;\;\mathsf{fma}\left(z\_m, z\_m, x \cdot y\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(z\_m \cdot 3\right) \cdot z\_m\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < 6.29999999999999979e-24

      1. Initial program 98.4%

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{z \cdot z + y \cdot x} \]
        4. lower-fma.f6478.0

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

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

          \[\leadsto \mathsf{fma}\left(z, z, x \cdot \color{blue}{y}\right) \]
        7. lower-*.f6478.0

          \[\leadsto \mathsf{fma}\left(z, z, x \cdot \color{blue}{y}\right) \]
      6. Applied rewrites78.0%

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

      if 6.29999999999999979e-24 < z

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
      3. Step-by-step derivation
        1. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
        2. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
        3. distribute-lft1-inN/A

          \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
        4. metadata-evalN/A

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        6. lift-*.f6453.3

          \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
      4. Applied rewrites53.3%

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

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

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

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

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

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
        6. lower-*.f6453.3

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
      6. Applied rewrites53.3%

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

    Alternative 4: 85.3% accurate, 2.0× speedup?

    \[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(z\_m \cdot 3\right) \cdot z\_m\\ \end{array} \end{array} \]
    z_m = (fabs.f64 z)
    (FPCore (x y z_m)
     :precision binary64
     (if (<= z_m 6.3e-24) (* y x) (* (* z_m 3.0) z_m)))
    z_m = fabs(z);
    double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 6.3e-24) {
    		tmp = y * x;
    	} else {
    		tmp = (z_m * 3.0) * z_m;
    	}
    	return tmp;
    }
    
    z_m =     private
    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_m)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z_m
        real(8) :: tmp
        if (z_m <= 6.3d-24) then
            tmp = y * x
        else
            tmp = (z_m * 3.0d0) * z_m
        end if
        code = tmp
    end function
    
    z_m = Math.abs(z);
    public static double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 6.3e-24) {
    		tmp = y * x;
    	} else {
    		tmp = (z_m * 3.0) * z_m;
    	}
    	return tmp;
    }
    
    z_m = math.fabs(z)
    def code(x, y, z_m):
    	tmp = 0
    	if z_m <= 6.3e-24:
    		tmp = y * x
    	else:
    		tmp = (z_m * 3.0) * z_m
    	return tmp
    
    z_m = abs(z)
    function code(x, y, z_m)
    	tmp = 0.0
    	if (z_m <= 6.3e-24)
    		tmp = Float64(y * x);
    	else
    		tmp = Float64(Float64(z_m * 3.0) * z_m);
    	end
    	return tmp
    end
    
    z_m = abs(z);
    function tmp_2 = code(x, y, z_m)
    	tmp = 0.0;
    	if (z_m <= 6.3e-24)
    		tmp = y * x;
    	else
    		tmp = (z_m * 3.0) * z_m;
    	end
    	tmp_2 = tmp;
    end
    
    z_m = N[Abs[z], $MachinePrecision]
    code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(y * x), $MachinePrecision], N[(N[(z$95$m * 3.0), $MachinePrecision] * z$95$m), $MachinePrecision]]
    
    \begin{array}{l}
    z_m = \left|z\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
    \;\;\;\;y \cdot x\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(z\_m \cdot 3\right) \cdot z\_m\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < 6.29999999999999979e-24

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{x \cdot y} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

      if 6.29999999999999979e-24 < z

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
      3. Step-by-step derivation
        1. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
        2. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
        3. distribute-lft1-inN/A

          \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
        4. metadata-evalN/A

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        6. lift-*.f6453.3

          \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
      4. Applied rewrites53.3%

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

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

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

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

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

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
        6. lower-*.f6453.3

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
      6. Applied rewrites53.3%

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

    Alternative 5: 85.3% accurate, 2.0× speedup?

    \[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;3 \cdot \left(z\_m \cdot z\_m\right)\\ \end{array} \end{array} \]
    z_m = (fabs.f64 z)
    (FPCore (x y z_m)
     :precision binary64
     (if (<= z_m 6.3e-24) (* y x) (* 3.0 (* z_m z_m))))
    z_m = fabs(z);
    double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 6.3e-24) {
    		tmp = y * x;
    	} else {
    		tmp = 3.0 * (z_m * z_m);
    	}
    	return tmp;
    }
    
    z_m =     private
    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_m)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z_m
        real(8) :: tmp
        if (z_m <= 6.3d-24) then
            tmp = y * x
        else
            tmp = 3.0d0 * (z_m * z_m)
        end if
        code = tmp
    end function
    
    z_m = Math.abs(z);
    public static double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 6.3e-24) {
    		tmp = y * x;
    	} else {
    		tmp = 3.0 * (z_m * z_m);
    	}
    	return tmp;
    }
    
    z_m = math.fabs(z)
    def code(x, y, z_m):
    	tmp = 0
    	if z_m <= 6.3e-24:
    		tmp = y * x
    	else:
    		tmp = 3.0 * (z_m * z_m)
    	return tmp
    
    z_m = abs(z)
    function code(x, y, z_m)
    	tmp = 0.0
    	if (z_m <= 6.3e-24)
    		tmp = Float64(y * x);
    	else
    		tmp = Float64(3.0 * Float64(z_m * z_m));
    	end
    	return tmp
    end
    
    z_m = abs(z);
    function tmp_2 = code(x, y, z_m)
    	tmp = 0.0;
    	if (z_m <= 6.3e-24)
    		tmp = y * x;
    	else
    		tmp = 3.0 * (z_m * z_m);
    	end
    	tmp_2 = tmp;
    end
    
    z_m = N[Abs[z], $MachinePrecision]
    code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 6.3e-24], N[(y * x), $MachinePrecision], N[(3.0 * N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    z_m = \left|z\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z\_m \leq 6.3 \cdot 10^{-24}:\\
    \;\;\;\;y \cdot x\\
    
    \mathbf{else}:\\
    \;\;\;\;3 \cdot \left(z\_m \cdot z\_m\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < 6.29999999999999979e-24

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{x \cdot y} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

      if 6.29999999999999979e-24 < z

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
      3. Step-by-step derivation
        1. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
        2. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
        3. distribute-lft1-inN/A

          \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
        4. metadata-evalN/A

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        6. lift-*.f6453.3

          \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
      4. Applied rewrites53.3%

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

    Alternative 6: 74.4% accurate, 2.0× speedup?

    \[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 9.6 \cdot 10^{+91}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z\_m \cdot \left(z\_m + z\_m\right)\\ \end{array} \end{array} \]
    z_m = (fabs.f64 z)
    (FPCore (x y z_m)
     :precision binary64
     (if (<= z_m 9.6e+91) (* y x) (* z_m (+ z_m z_m))))
    z_m = fabs(z);
    double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 9.6e+91) {
    		tmp = y * x;
    	} else {
    		tmp = z_m * (z_m + z_m);
    	}
    	return tmp;
    }
    
    z_m =     private
    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_m)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z_m
        real(8) :: tmp
        if (z_m <= 9.6d+91) then
            tmp = y * x
        else
            tmp = z_m * (z_m + z_m)
        end if
        code = tmp
    end function
    
    z_m = Math.abs(z);
    public static double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 9.6e+91) {
    		tmp = y * x;
    	} else {
    		tmp = z_m * (z_m + z_m);
    	}
    	return tmp;
    }
    
    z_m = math.fabs(z)
    def code(x, y, z_m):
    	tmp = 0
    	if z_m <= 9.6e+91:
    		tmp = y * x
    	else:
    		tmp = z_m * (z_m + z_m)
    	return tmp
    
    z_m = abs(z)
    function code(x, y, z_m)
    	tmp = 0.0
    	if (z_m <= 9.6e+91)
    		tmp = Float64(y * x);
    	else
    		tmp = Float64(z_m * Float64(z_m + z_m));
    	end
    	return tmp
    end
    
    z_m = abs(z);
    function tmp_2 = code(x, y, z_m)
    	tmp = 0.0;
    	if (z_m <= 9.6e+91)
    		tmp = y * x;
    	else
    		tmp = z_m * (z_m + z_m);
    	end
    	tmp_2 = tmp;
    end
    
    z_m = N[Abs[z], $MachinePrecision]
    code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 9.6e+91], N[(y * x), $MachinePrecision], N[(z$95$m * N[(z$95$m + z$95$m), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    z_m = \left|z\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z\_m \leq 9.6 \cdot 10^{+91}:\\
    \;\;\;\;y \cdot x\\
    
    \mathbf{else}:\\
    \;\;\;\;z\_m \cdot \left(z\_m + z\_m\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < 9.59999999999999932e91

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{x \cdot y} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

      if 9.59999999999999932e91 < z

      1. Initial program 98.4%

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{z \cdot z + y \cdot x} \]
        4. lower-fma.f6478.0

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

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

          \[\leadsto \mathsf{fma}\left(z, z, x \cdot \color{blue}{y}\right) \]
        7. lower-*.f6478.0

          \[\leadsto \mathsf{fma}\left(z, z, x \cdot \color{blue}{y}\right) \]
      6. Applied rewrites78.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, z, x \cdot y\right)} \]
      7. Step-by-step derivation
        1. lift-fma.f64N/A

          \[\leadsto \color{blue}{z \cdot z + x \cdot y} \]
        2. pow2N/A

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

          \[\leadsto \color{blue}{x \cdot y + {z}^{2}} \]
        4. pow2N/A

          \[\leadsto x \cdot y + \color{blue}{z \cdot z} \]
        5. fp-cancel-sign-sub-invN/A

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

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

          \[\leadsto x \cdot y - \left(\mathsf{neg}\left(\color{blue}{{z}^{2}}\right)\right) \]
        8. *-lft-identityN/A

          \[\leadsto x \cdot y - \left(\mathsf{neg}\left(\color{blue}{1 \cdot {z}^{2}}\right)\right) \]
        9. metadata-evalN/A

          \[\leadsto x \cdot y - \left(\mathsf{neg}\left(\color{blue}{\frac{2}{2}} \cdot {z}^{2}\right)\right) \]
        10. associate-*l/N/A

          \[\leadsto x \cdot y - \left(\mathsf{neg}\left(\color{blue}{\frac{2 \cdot {z}^{2}}{2}}\right)\right) \]
      8. Applied rewrites36.5%

        \[\leadsto \color{blue}{y \cdot x - -1} \]
      9. Taylor expanded in z around inf

        \[\leadsto \color{blue}{2 \cdot {z}^{2}} \]
      10. Step-by-step derivation
        1. count-2-revN/A

          \[\leadsto {z}^{2} + \color{blue}{{z}^{2}} \]
        2. pow2N/A

          \[\leadsto z \cdot z + {\color{blue}{z}}^{2} \]
        3. pow2N/A

          \[\leadsto z \cdot z + z \cdot \color{blue}{z} \]
        4. distribute-rgt-outN/A

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

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

          \[\leadsto z \cdot \color{blue}{\left(2 \cdot z\right)} \]
        7. count-2-revN/A

          \[\leadsto z \cdot \left(z + \color{blue}{z}\right) \]
        8. lower-+.f6433.6

          \[\leadsto z \cdot \left(z + \color{blue}{z}\right) \]
      11. Applied rewrites33.6%

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

    Alternative 7: 74.2% accurate, 2.7× speedup?

    \[\begin{array}{l} z_m = \left|z\right| \\ \begin{array}{l} \mathbf{if}\;z\_m \leq 9.6 \cdot 10^{+91}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;z\_m \cdot z\_m\\ \end{array} \end{array} \]
    z_m = (fabs.f64 z)
    (FPCore (x y z_m)
     :precision binary64
     (if (<= z_m 9.6e+91) (* y x) (* z_m z_m)))
    z_m = fabs(z);
    double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 9.6e+91) {
    		tmp = y * x;
    	} else {
    		tmp = z_m * z_m;
    	}
    	return tmp;
    }
    
    z_m =     private
    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_m)
    use fmin_fmax_functions
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z_m
        real(8) :: tmp
        if (z_m <= 9.6d+91) then
            tmp = y * x
        else
            tmp = z_m * z_m
        end if
        code = tmp
    end function
    
    z_m = Math.abs(z);
    public static double code(double x, double y, double z_m) {
    	double tmp;
    	if (z_m <= 9.6e+91) {
    		tmp = y * x;
    	} else {
    		tmp = z_m * z_m;
    	}
    	return tmp;
    }
    
    z_m = math.fabs(z)
    def code(x, y, z_m):
    	tmp = 0
    	if z_m <= 9.6e+91:
    		tmp = y * x
    	else:
    		tmp = z_m * z_m
    	return tmp
    
    z_m = abs(z)
    function code(x, y, z_m)
    	tmp = 0.0
    	if (z_m <= 9.6e+91)
    		tmp = Float64(y * x);
    	else
    		tmp = Float64(z_m * z_m);
    	end
    	return tmp
    end
    
    z_m = abs(z);
    function tmp_2 = code(x, y, z_m)
    	tmp = 0.0;
    	if (z_m <= 9.6e+91)
    		tmp = y * x;
    	else
    		tmp = z_m * z_m;
    	end
    	tmp_2 = tmp;
    end
    
    z_m = N[Abs[z], $MachinePrecision]
    code[x_, y_, z$95$m_] := If[LessEqual[z$95$m, 9.6e+91], N[(y * x), $MachinePrecision], N[(z$95$m * z$95$m), $MachinePrecision]]
    
    \begin{array}{l}
    z_m = \left|z\right|
    
    \\
    \begin{array}{l}
    \mathbf{if}\;z\_m \leq 9.6 \cdot 10^{+91}:\\
    \;\;\;\;y \cdot x\\
    
    \mathbf{else}:\\
    \;\;\;\;z\_m \cdot z\_m\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < 9.59999999999999932e91

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{x \cdot y} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

      if 9.59999999999999932e91 < z

      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
      3. Step-by-step derivation
        1. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
        2. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
        3. distribute-lft1-inN/A

          \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
        4. metadata-evalN/A

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        6. lift-*.f6453.3

          \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
      4. Applied rewrites53.3%

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

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

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

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

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

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
        6. lower-*.f6453.3

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
      6. Applied rewrites53.3%

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

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
        2. *-commutativeN/A

          \[\leadsto \left(3 \cdot z\right) \cdot z \]
        3. metadata-evalN/A

          \[\leadsto \left(\left(2 + 1\right) \cdot z\right) \cdot z \]
        4. distribute-lft1-inN/A

          \[\leadsto \left(2 \cdot z + z\right) \cdot z \]
        5. count-2-revN/A

          \[\leadsto \left(\left(z + z\right) + z\right) \cdot z \]
        6. associate-+l+N/A

          \[\leadsto \left(z + \left(z + z\right)\right) \cdot z \]
        7. flip-+N/A

          \[\leadsto \left(z + \frac{z \cdot z - z \cdot z}{z - z}\right) \cdot z \]
        8. pow2N/A

          \[\leadsto \left(z + \frac{{z}^{2} - z \cdot z}{z - z}\right) \cdot z \]
        9. pow2N/A

          \[\leadsto \left(z + \frac{{z}^{2} - {z}^{2}}{z - z}\right) \cdot z \]
        10. +-inversesN/A

          \[\leadsto \left(z + \frac{0}{z - z}\right) \cdot z \]
        11. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 - 1}{z - z}\right) \cdot z \]
        12. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1}{z - z}\right) \cdot z \]
        13. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{z - z}\right) \cdot z \]
        14. +-inversesN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{0}\right) \cdot z \]
        15. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{1 - 1}\right) \cdot z \]
        16. flip-+N/A

          \[\leadsto \left(z + \left(1 + 1\right)\right) \cdot z \]
        17. metadata-evalN/A

          \[\leadsto \left(z + 2\right) \cdot z \]
        18. lower-+.f6429.4

          \[\leadsto \left(z + 2\right) \cdot z \]
      8. Applied rewrites29.4%

        \[\leadsto \left(z + 2\right) \cdot z \]
      9. Taylor expanded in z around inf

        \[\leadsto z \cdot z \]
      10. Step-by-step derivation
        1. Applied rewrites33.0%

          \[\leadsto z \cdot z \]
      11. Recombined 2 regimes into one program.
      12. Add Preprocessing

      Alternative 8: 53.5% accurate, 5.3× speedup?

      \[\begin{array}{l} z_m = \left|z\right| \\ y \cdot x \end{array} \]
      z_m = (fabs.f64 z)
      (FPCore (x y z_m) :precision binary64 (* y x))
      z_m = fabs(z);
      double code(double x, double y, double z_m) {
      	return y * x;
      }
      
      z_m =     private
      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_m)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z_m
          code = y * x
      end function
      
      z_m = Math.abs(z);
      public static double code(double x, double y, double z_m) {
      	return y * x;
      }
      
      z_m = math.fabs(z)
      def code(x, y, z_m):
      	return y * x
      
      z_m = abs(z)
      function code(x, y, z_m)
      	return Float64(y * x)
      end
      
      z_m = abs(z);
      function tmp = code(x, y, z_m)
      	tmp = y * x;
      end
      
      z_m = N[Abs[z], $MachinePrecision]
      code[x_, y_, z$95$m_] := N[(y * x), $MachinePrecision]
      
      \begin{array}{l}
      z_m = \left|z\right|
      
      \\
      y \cdot x
      \end{array}
      
      Derivation
      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{x \cdot y} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

      Alternative 9: 5.2% accurate, 5.6× speedup?

      \[\begin{array}{l} z_m = \left|z\right| \\ z\_m + z\_m \end{array} \]
      z_m = (fabs.f64 z)
      (FPCore (x y z_m) :precision binary64 (+ z_m z_m))
      z_m = fabs(z);
      double code(double x, double y, double z_m) {
      	return z_m + z_m;
      }
      
      z_m =     private
      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_m)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z_m
          code = z_m + z_m
      end function
      
      z_m = Math.abs(z);
      public static double code(double x, double y, double z_m) {
      	return z_m + z_m;
      }
      
      z_m = math.fabs(z)
      def code(x, y, z_m):
      	return z_m + z_m
      
      z_m = abs(z)
      function code(x, y, z_m)
      	return Float64(z_m + z_m)
      end
      
      z_m = abs(z);
      function tmp = code(x, y, z_m)
      	tmp = z_m + z_m;
      end
      
      z_m = N[Abs[z], $MachinePrecision]
      code[x_, y_, z$95$m_] := N[(z$95$m + z$95$m), $MachinePrecision]
      
      \begin{array}{l}
      z_m = \left|z\right|
      
      \\
      z\_m + z\_m
      \end{array}
      
      Derivation
      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
      3. Step-by-step derivation
        1. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
        2. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
        3. distribute-lft1-inN/A

          \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
        4. metadata-evalN/A

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        6. lift-*.f6453.3

          \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
      4. Applied rewrites53.3%

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

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

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

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

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

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
        6. lower-*.f6453.3

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
      6. Applied rewrites53.3%

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

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
        2. *-commutativeN/A

          \[\leadsto \left(3 \cdot z\right) \cdot z \]
        3. metadata-evalN/A

          \[\leadsto \left(\left(2 + 1\right) \cdot z\right) \cdot z \]
        4. distribute-lft1-inN/A

          \[\leadsto \left(2 \cdot z + z\right) \cdot z \]
        5. count-2-revN/A

          \[\leadsto \left(\left(z + z\right) + z\right) \cdot z \]
        6. associate-+l+N/A

          \[\leadsto \left(z + \left(z + z\right)\right) \cdot z \]
        7. flip-+N/A

          \[\leadsto \left(z + \frac{z \cdot z - z \cdot z}{z - z}\right) \cdot z \]
        8. pow2N/A

          \[\leadsto \left(z + \frac{{z}^{2} - z \cdot z}{z - z}\right) \cdot z \]
        9. pow2N/A

          \[\leadsto \left(z + \frac{{z}^{2} - {z}^{2}}{z - z}\right) \cdot z \]
        10. +-inversesN/A

          \[\leadsto \left(z + \frac{0}{z - z}\right) \cdot z \]
        11. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 - 1}{z - z}\right) \cdot z \]
        12. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1}{z - z}\right) \cdot z \]
        13. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{z - z}\right) \cdot z \]
        14. +-inversesN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{0}\right) \cdot z \]
        15. metadata-evalN/A

          \[\leadsto \left(z + \frac{1 \cdot 1 - 1 \cdot 1}{1 - 1}\right) \cdot z \]
        16. flip-+N/A

          \[\leadsto \left(z + \left(1 + 1\right)\right) \cdot z \]
        17. metadata-evalN/A

          \[\leadsto \left(z + 2\right) \cdot z \]
        18. lower-+.f6429.4

          \[\leadsto \left(z + 2\right) \cdot z \]
      8. Applied rewrites29.4%

        \[\leadsto \left(z + 2\right) \cdot z \]
      9. Taylor expanded in z around 0

        \[\leadsto 2 \cdot \color{blue}{z} \]
      10. Step-by-step derivation
        1. count-2-revN/A

          \[\leadsto z + z \]
        2. lower-+.f645.2

          \[\leadsto z + z \]
      11. Applied rewrites5.2%

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

      Alternative 10: 3.7% accurate, 21.0× speedup?

      \[\begin{array}{l} z_m = \left|z\right| \\ 3 \end{array} \]
      z_m = (fabs.f64 z)
      (FPCore (x y z_m) :precision binary64 3.0)
      z_m = fabs(z);
      double code(double x, double y, double z_m) {
      	return 3.0;
      }
      
      z_m =     private
      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_m)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z_m
          code = 3.0d0
      end function
      
      z_m = Math.abs(z);
      public static double code(double x, double y, double z_m) {
      	return 3.0;
      }
      
      z_m = math.fabs(z)
      def code(x, y, z_m):
      	return 3.0
      
      z_m = abs(z)
      function code(x, y, z_m)
      	return 3.0
      end
      
      z_m = abs(z);
      function tmp = code(x, y, z_m)
      	tmp = 3.0;
      end
      
      z_m = N[Abs[z], $MachinePrecision]
      code[x_, y_, z$95$m_] := 3.0
      
      \begin{array}{l}
      z_m = \left|z\right|
      
      \\
      3
      \end{array}
      
      Derivation
      1. Initial program 98.4%

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

        \[\leadsto \color{blue}{2 \cdot {z}^{2} + {z}^{2}} \]
      3. Step-by-step derivation
        1. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + {z}^{2} \]
        2. pow2N/A

          \[\leadsto 2 \cdot \left(z \cdot z\right) + z \cdot \color{blue}{z} \]
        3. distribute-lft1-inN/A

          \[\leadsto \left(2 + 1\right) \cdot \color{blue}{\left(z \cdot z\right)} \]
        4. metadata-evalN/A

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

          \[\leadsto 3 \cdot \color{blue}{\left(z \cdot z\right)} \]
        6. lift-*.f6453.3

          \[\leadsto 3 \cdot \left(z \cdot \color{blue}{z}\right) \]
      4. Applied rewrites53.3%

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

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

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

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

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

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
        6. lower-*.f6453.3

          \[\leadsto \left(z \cdot 3\right) \cdot z \]
      6. Applied rewrites53.3%

        \[\leadsto \color{blue}{\left(z \cdot 3\right) \cdot z} \]
      7. Taylor expanded in z around 0

        \[\leadsto 3 \cdot \color{blue}{{z}^{2}} \]
      8. Step-by-step derivation
        1. *-lft-identityN/A

          \[\leadsto 3 \cdot \left(1 \cdot {z}^{\color{blue}{2}}\right) \]
        2. metadata-evalN/A

          \[\leadsto 3 \cdot \left(\frac{2}{2} \cdot {z}^{2}\right) \]
        3. associate-*l/N/A

          \[\leadsto 3 \cdot \frac{2 \cdot {z}^{2}}{2} \]
      9. Applied rewrites3.7%

        \[\leadsto 3 \]
      10. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2025123 
      (FPCore (x y z)
        :name "Linear.Quaternion:$c/ from linear-1.19.1.3, A"
        :precision binary64
        (+ (+ (+ (* x y) (* z z)) (* z z)) (* z z)))