System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2

Percentage Accurate: 99.9% → 99.9%
Time: 4.6s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 99.9% accurate, 1.0× speedup?

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

\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right)} + x \cdot \frac{1}{2} \]
    4. *-commutativeN/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - z\right) + \log z, y, x \cdot 0.5\right)} \]
    6. lift-+.f64N/A

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

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

      \[\leadsto \mathsf{fma}\left(\log z + \color{blue}{\left(1 - z\right)}, y, x \cdot \frac{1}{2}\right) \]
    9. associate-+r-N/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{\frac{1}{2} \cdot x}\right) \]
    14. lower-*.f6499.9

      \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{0.5 \cdot x}\right) \]
  4. Applied rewrites99.9%

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

Alternative 2: 74.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(1 - z\right) + \log z\\ \mathbf{if}\;t\_0 \leq -492 \lor \neg \left(t\_0 \leq -330 \lor \neg \left(t\_0 \leq -90.2\right)\right):\\ \;\;\;\;\mathsf{fma}\left(-z, y, 0.5 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log z, y, y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ (- 1.0 z) (log z))))
   (if (or (<= t_0 -492.0) (not (or (<= t_0 -330.0) (not (<= t_0 -90.2)))))
     (fma (- z) y (* 0.5 x))
     (fma (log z) y y))))
double code(double x, double y, double z) {
	double t_0 = (1.0 - z) + log(z);
	double tmp;
	if ((t_0 <= -492.0) || !((t_0 <= -330.0) || !(t_0 <= -90.2))) {
		tmp = fma(-z, y, (0.5 * x));
	} else {
		tmp = fma(log(z), y, y);
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(1.0 - z) + log(z))
	tmp = 0.0
	if ((t_0 <= -492.0) || !((t_0 <= -330.0) || !(t_0 <= -90.2)))
		tmp = fma(Float64(-z), y, Float64(0.5 * x));
	else
		tmp = fma(log(z), y, y);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -492.0], N[Not[Or[LessEqual[t$95$0, -330.0], N[Not[LessEqual[t$95$0, -90.2]], $MachinePrecision]]], $MachinePrecision]], N[((-z) * y + N[(0.5 * x), $MachinePrecision]), $MachinePrecision], N[(N[Log[z], $MachinePrecision] * y + y), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(1 - z\right) + \log z\\
\mathbf{if}\;t\_0 \leq -492 \lor \neg \left(t\_0 \leq -330 \lor \neg \left(t\_0 \leq -90.2\right)\right):\\
\;\;\;\;\mathsf{fma}\left(-z, y, 0.5 \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z)) < -492 or -330 < (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z)) < -90.2000000000000028

    1. Initial program 99.9%

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right)} + x \cdot \frac{1}{2} \]
      4. *-commutativeN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - z\right) + \log z, y, x \cdot 0.5\right)} \]
      6. lift-+.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(\log z + \color{blue}{\left(1 - z\right)}, y, x \cdot \frac{1}{2}\right) \]
      9. associate-+r-N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{\frac{1}{2} \cdot x}\right) \]
      14. lower-*.f6499.9

        \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{0.5 \cdot x}\right) \]
    4. Applied rewrites99.9%

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

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

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

      if -492 < (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z)) < -330 or -90.2000000000000028 < (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z))

      1. Initial program 99.7%

        \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
      2. Add Preprocessing
      3. Taylor expanded in z around 0

        \[\leadsto \color{blue}{\frac{1}{2} \cdot x + y \cdot \left(1 + \log z\right)} \]
      4. Step-by-step derivation
        1. Applied rewrites94.8%

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

          \[\leadsto y + \color{blue}{y \cdot \log z} \]
        3. Step-by-step derivation
          1. Applied rewrites68.7%

            \[\leadsto \mathsf{fma}\left(\log z, \color{blue}{y}, y\right) \]
        4. Recombined 2 regimes into one program.
        5. Final simplification81.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\left(1 - z\right) + \log z \leq -492 \lor \neg \left(\left(1 - z\right) + \log z \leq -330 \lor \neg \left(\left(1 - z\right) + \log z \leq -90.2\right)\right):\\ \;\;\;\;\mathsf{fma}\left(-z, y, 0.5 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log z, y, y\right)\\ \end{array} \]
        6. Add Preprocessing

        Alternative 3: 60.5% accurate, 0.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(\left(1 - z\right) + \log z\right)\\ \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+37} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+113}\right):\\ \;\;\;\;\left(-y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot x\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (* y (+ (- 1.0 z) (log z)))))
           (if (or (<= t_0 -5e+37) (not (<= t_0 2e+113))) (* (- y) z) (* 0.5 x))))
        double code(double x, double y, double z) {
        	double t_0 = y * ((1.0 - z) + log(z));
        	double tmp;
        	if ((t_0 <= -5e+37) || !(t_0 <= 2e+113)) {
        		tmp = -y * z;
        	} else {
        		tmp = 0.5 * 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) :: t_0
            real(8) :: tmp
            t_0 = y * ((1.0d0 - z) + log(z))
            if ((t_0 <= (-5d+37)) .or. (.not. (t_0 <= 2d+113))) then
                tmp = -y * z
            else
                tmp = 0.5d0 * x
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double t_0 = y * ((1.0 - z) + Math.log(z));
        	double tmp;
        	if ((t_0 <= -5e+37) || !(t_0 <= 2e+113)) {
        		tmp = -y * z;
        	} else {
        		tmp = 0.5 * x;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	t_0 = y * ((1.0 - z) + math.log(z))
        	tmp = 0
        	if (t_0 <= -5e+37) or not (t_0 <= 2e+113):
        		tmp = -y * z
        	else:
        		tmp = 0.5 * x
        	return tmp
        
        function code(x, y, z)
        	t_0 = Float64(y * Float64(Float64(1.0 - z) + log(z)))
        	tmp = 0.0
        	if ((t_0 <= -5e+37) || !(t_0 <= 2e+113))
        		tmp = Float64(Float64(-y) * z);
        	else
        		tmp = Float64(0.5 * x);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	t_0 = y * ((1.0 - z) + log(z));
        	tmp = 0.0;
        	if ((t_0 <= -5e+37) || ~((t_0 <= 2e+113)))
        		tmp = -y * z;
        	else
        		tmp = 0.5 * x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -5e+37], N[Not[LessEqual[t$95$0, 2e+113]], $MachinePrecision]], N[((-y) * z), $MachinePrecision], N[(0.5 * x), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := y \cdot \left(\left(1 - z\right) + \log z\right)\\
        \mathbf{if}\;t\_0 \leq -5 \cdot 10^{+37} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+113}\right):\\
        \;\;\;\;\left(-y\right) \cdot z\\
        
        \mathbf{else}:\\
        \;\;\;\;0.5 \cdot x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 y (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z))) < -4.99999999999999989e37 or 2e113 < (*.f64 y (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z)))

          1. Initial program 99.8%

            \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
          2. Add Preprocessing
          3. Taylor expanded in z around inf

            \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
          4. Step-by-step derivation
            1. Applied rewrites61.6%

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

            if -4.99999999999999989e37 < (*.f64 y (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z))) < 2e113

            1. Initial program 99.9%

              \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
            2. Add Preprocessing
            3. Taylor expanded in x around inf

              \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
            4. Step-by-step derivation
              1. Applied rewrites67.0%

                \[\leadsto \color{blue}{0.5 \cdot x} \]
            5. Recombined 2 regimes into one program.
            6. Final simplification64.2%

              \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(\left(1 - z\right) + \log z\right) \leq -5 \cdot 10^{+37} \lor \neg \left(y \cdot \left(\left(1 - z\right) + \log z\right) \leq 2 \cdot 10^{+113}\right):\\ \;\;\;\;\left(-y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot x\\ \end{array} \]
            7. Add Preprocessing

            Alternative 4: 84.5% accurate, 1.0× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+17} \lor \neg \left(x \leq 17500000000\right):\\ \;\;\;\;\mathsf{fma}\left(-z, y, 0.5 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log z - z, y, y\right)\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= x -4e+17) (not (<= x 17500000000.0)))
               (fma (- z) y (* 0.5 x))
               (fma (- (log z) z) y y)))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((x <= -4e+17) || !(x <= 17500000000.0)) {
            		tmp = fma(-z, y, (0.5 * x));
            	} else {
            		tmp = fma((log(z) - z), y, y);
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((x <= -4e+17) || !(x <= 17500000000.0))
            		tmp = fma(Float64(-z), y, Float64(0.5 * x));
            	else
            		tmp = fma(Float64(log(z) - z), y, y);
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[x, -4e+17], N[Not[LessEqual[x, 17500000000.0]], $MachinePrecision]], N[((-z) * y + N[(0.5 * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision] * y + y), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -4 \cdot 10^{+17} \lor \neg \left(x \leq 17500000000\right):\\
            \;\;\;\;\mathsf{fma}\left(-z, y, 0.5 \cdot x\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(\log z - z, y, y\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -4e17 or 1.75e10 < x

              1. Initial program 100.0%

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

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

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

                  \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right)} + x \cdot \frac{1}{2} \]
                4. *-commutativeN/A

                  \[\leadsto \color{blue}{\left(\left(1 - z\right) + \log z\right) \cdot y} + x \cdot \frac{1}{2} \]
                5. lower-fma.f64100.0

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - z\right) + \log z, y, x \cdot 0.5\right)} \]
                6. lift-+.f64N/A

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

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

                  \[\leadsto \mathsf{fma}\left(\log z + \color{blue}{\left(1 - z\right)}, y, x \cdot \frac{1}{2}\right) \]
                9. associate-+r-N/A

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\log z + 1\right) - z}, y, x \cdot \frac{1}{2}\right) \]
                11. lower-+.f64100.0

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

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

                  \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{\frac{1}{2} \cdot x}\right) \]
                14. lower-*.f64100.0

                  \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{0.5 \cdot x}\right) \]
              4. Applied rewrites100.0%

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

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

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

                if -4e17 < x < 1.75e10

                1. Initial program 99.8%

                  \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
                2. Add Preprocessing
                3. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{y \cdot \left(\left(1 + \log z\right) - z\right)} \]
                4. Step-by-step derivation
                  1. Applied rewrites86.6%

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

                  \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+17} \lor \neg \left(x \leq 17500000000\right):\\ \;\;\;\;\mathsf{fma}\left(-z, y, 0.5 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log z - z, y, y\right)\\ \end{array} \]
                7. Add Preprocessing

                Alternative 5: 98.8% accurate, 1.0× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 0.32:\\ \;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\log z, y, y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log z - z, y, x \cdot 0.5\right)\\ \end{array} \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (if (<= z 0.32)
                   (fma 0.5 x (fma (log z) y y))
                   (fma (- (log z) z) y (* x 0.5))))
                double code(double x, double y, double z) {
                	double tmp;
                	if (z <= 0.32) {
                		tmp = fma(0.5, x, fma(log(z), y, y));
                	} else {
                		tmp = fma((log(z) - z), y, (x * 0.5));
                	}
                	return tmp;
                }
                
                function code(x, y, z)
                	tmp = 0.0
                	if (z <= 0.32)
                		tmp = fma(0.5, x, fma(log(z), y, y));
                	else
                		tmp = fma(Float64(log(z) - z), y, Float64(x * 0.5));
                	end
                	return tmp
                end
                
                code[x_, y_, z_] := If[LessEqual[z, 0.32], N[(0.5 * x + N[(N[Log[z], $MachinePrecision] * y + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision] * y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;z \leq 0.32:\\
                \;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\log z, y, y\right)\right)\\
                
                \mathbf{else}:\\
                \;\;\;\;\mathsf{fma}\left(\log z - z, y, x \cdot 0.5\right)\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if z < 0.320000000000000007

                  1. Initial program 99.7%

                    \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
                  2. Add Preprocessing
                  3. Taylor expanded in z around 0

                    \[\leadsto \color{blue}{\frac{1}{2} \cdot x + y \cdot \left(1 + \log z\right)} \]
                  4. Step-by-step derivation
                    1. Applied rewrites98.1%

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

                    if 0.320000000000000007 < z

                    1. Initial program 100.0%

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

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

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

                        \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right)} + x \cdot \frac{1}{2} \]
                      4. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(\left(1 - z\right) + \log z\right) \cdot y} + x \cdot \frac{1}{2} \]
                      5. lower-fma.f64100.0

                        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - z\right) + \log z, y, x \cdot 0.5\right)} \]
                      6. lift-+.f64N/A

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

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

                        \[\leadsto \mathsf{fma}\left(\log z + \color{blue}{\left(1 - z\right)}, y, x \cdot \frac{1}{2}\right) \]
                      9. associate-+r-N/A

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

                        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\log z + 1\right) - z}, y, x \cdot \frac{1}{2}\right) \]
                      11. lower-+.f64100.0

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

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

                        \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{\frac{1}{2} \cdot x}\right) \]
                      14. lower-*.f64100.0

                        \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{0.5 \cdot x}\right) \]
                    4. Applied rewrites100.0%

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

                      \[\leadsto \color{blue}{\frac{1}{2} \cdot x + y \cdot \left(\left(1 + \log z\right) - z\right)} \]
                    6. Applied rewrites100.0%

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

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

                        \[\leadsto \mathsf{fma}\left(\log z - z, y, x \cdot 0.5\right) \]
                    9. Recombined 2 regimes into one program.
                    10. Final simplification98.4%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 0.32:\\ \;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\log z, y, y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\log z - z, y, x \cdot 0.5\right)\\ \end{array} \]
                    11. Add Preprocessing

                    Alternative 6: 98.7% accurate, 1.0× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 0.56:\\ \;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\log z, y, y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 - z, y, 0.5 \cdot x\right)\\ \end{array} \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (if (<= z 0.56) (fma 0.5 x (fma (log z) y y)) (fma (- 1.0 z) y (* 0.5 x))))
                    double code(double x, double y, double z) {
                    	double tmp;
                    	if (z <= 0.56) {
                    		tmp = fma(0.5, x, fma(log(z), y, y));
                    	} else {
                    		tmp = fma((1.0 - z), y, (0.5 * x));
                    	}
                    	return tmp;
                    }
                    
                    function code(x, y, z)
                    	tmp = 0.0
                    	if (z <= 0.56)
                    		tmp = fma(0.5, x, fma(log(z), y, y));
                    	else
                    		tmp = fma(Float64(1.0 - z), y, Float64(0.5 * x));
                    	end
                    	return tmp
                    end
                    
                    code[x_, y_, z_] := If[LessEqual[z, 0.56], N[(0.5 * x + N[(N[Log[z], $MachinePrecision] * y + y), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - z), $MachinePrecision] * y + N[(0.5 * x), $MachinePrecision]), $MachinePrecision]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;z \leq 0.56:\\
                    \;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(\log z, y, y\right)\right)\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;\mathsf{fma}\left(1 - z, y, 0.5 \cdot x\right)\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if z < 0.56000000000000005

                      1. Initial program 99.7%

                        \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
                      2. Add Preprocessing
                      3. Taylor expanded in z around 0

                        \[\leadsto \color{blue}{\frac{1}{2} \cdot x + y \cdot \left(1 + \log z\right)} \]
                      4. Step-by-step derivation
                        1. Applied rewrites98.1%

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

                        if 0.56000000000000005 < z

                        1. Initial program 100.0%

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

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

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

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

                            \[\leadsto y \cdot \color{blue}{\left(\left(1 - z\right) + \log z\right)} + x \cdot \frac{1}{2} \]
                          5. distribute-rgt-inN/A

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

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

                            \[\leadsto \color{blue}{\mathsf{fma}\left(1 - z, y, \log z \cdot y + x \cdot \frac{1}{2}\right)} \]
                          8. lower-fma.f64100.0

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

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

                            \[\leadsto \mathsf{fma}\left(1 - z, y, \mathsf{fma}\left(\log z, y, \color{blue}{\frac{1}{2} \cdot x}\right)\right) \]
                          11. lower-*.f64100.0

                            \[\leadsto \mathsf{fma}\left(1 - z, y, \mathsf{fma}\left(\log z, y, \color{blue}{0.5 \cdot x}\right)\right) \]
                        4. Applied rewrites100.0%

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

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

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

                        Alternative 7: 99.9% accurate, 1.0× speedup?

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

                          \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
                        2. Add Preprocessing
                        3. Taylor expanded in x around 0

                          \[\leadsto \color{blue}{\frac{1}{2} \cdot x + y \cdot \left(\left(1 + \log z\right) - z\right)} \]
                        4. Step-by-step derivation
                          1. Applied rewrites99.9%

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

                          Alternative 8: 75.1% accurate, 8.6× speedup?

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

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

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

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

                              \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right)} + x \cdot \frac{1}{2} \]
                            4. *-commutativeN/A

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

                              \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - z\right) + \log z, y, x \cdot 0.5\right)} \]
                            6. lift-+.f64N/A

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

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

                              \[\leadsto \mathsf{fma}\left(\log z + \color{blue}{\left(1 - z\right)}, y, x \cdot \frac{1}{2}\right) \]
                            9. associate-+r-N/A

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

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

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

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

                              \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{\frac{1}{2} \cdot x}\right) \]
                            14. lower-*.f6499.9

                              \[\leadsto \mathsf{fma}\left(\left(\log z + 1\right) - z, y, \color{blue}{0.5 \cdot x}\right) \]
                          4. Applied rewrites99.9%

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

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

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

                            Alternative 9: 40.8% accurate, 20.0× speedup?

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

                              \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
                            2. Add Preprocessing
                            3. Taylor expanded in x around inf

                              \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
                            4. Step-by-step derivation
                              1. Applied rewrites39.5%

                                \[\leadsto \color{blue}{0.5 \cdot x} \]
                              2. Add Preprocessing

                              Developer Target 1: 99.8% accurate, 1.0× speedup?

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

                              Reproduce

                              ?
                              herbie shell --seed 2025022 
                              (FPCore (x y z)
                                :name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
                                :precision binary64
                              
                                :alt
                                (! :herbie-platform default (- (+ y (* 1/2 x)) (* y (- z (log z)))))
                              
                                (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))