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

Percentage Accurate: 99.9% → 99.9%
Time: 10.1s
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)));
}
real(8) function code(x, y, z)
    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)));
}
real(8) function code(x, y, z)
    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, 0.5× speedup?

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

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

    \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
  2. Step-by-step derivation
    1. +-commutative99.9%

      \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right) + x \cdot 0.5} \]
    2. fma-define99.9%

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

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

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

Alternative 2: 74.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(1 + \log z\right)\\ t_1 := x \cdot 0.5 - y \cdot z\\ \mathbf{if}\;z \leq 5.2 \cdot 10^{-151}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{-123}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{-115}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-64}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-11}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ 1.0 (log z)))) (t_1 (- (* x 0.5) (* y z))))
   (if (<= z 5.2e-151)
     t_0
     (if (<= z 6.4e-123)
       t_1
       (if (<= z 2.25e-115)
         t_0
         (if (<= z 3.5e-64)
           t_1
           (if (<= z 5.2e-11) t_0 (fma y (- z) (* x 0.5)))))))))
double code(double x, double y, double z) {
	double t_0 = y * (1.0 + log(z));
	double t_1 = (x * 0.5) - (y * z);
	double tmp;
	if (z <= 5.2e-151) {
		tmp = t_0;
	} else if (z <= 6.4e-123) {
		tmp = t_1;
	} else if (z <= 2.25e-115) {
		tmp = t_0;
	} else if (z <= 3.5e-64) {
		tmp = t_1;
	} else if (z <= 5.2e-11) {
		tmp = t_0;
	} else {
		tmp = fma(y, -z, (x * 0.5));
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(y * Float64(1.0 + log(z)))
	t_1 = Float64(Float64(x * 0.5) - Float64(y * z))
	tmp = 0.0
	if (z <= 5.2e-151)
		tmp = t_0;
	elseif (z <= 6.4e-123)
		tmp = t_1;
	elseif (z <= 2.25e-115)
		tmp = t_0;
	elseif (z <= 3.5e-64)
		tmp = t_1;
	elseif (z <= 5.2e-11)
		tmp = t_0;
	else
		tmp = fma(y, Float64(-z), Float64(x * 0.5));
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 5.2e-151], t$95$0, If[LessEqual[z, 6.4e-123], t$95$1, If[LessEqual[z, 2.25e-115], t$95$0, If[LessEqual[z, 3.5e-64], t$95$1, If[LessEqual[z, 5.2e-11], t$95$0, N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(1 + \log z\right)\\
t_1 := x \cdot 0.5 - y \cdot z\\
\mathbf{if}\;z \leq 5.2 \cdot 10^{-151}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 6.4 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 2.25 \cdot 10^{-115}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{-64}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 5.2 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 5.2000000000000001e-151 or 6.39999999999999957e-123 < z < 2.25000000000000011e-115 or 3.5000000000000003e-64 < z < 5.2000000000000001e-11

    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 0 99.4%

      \[\leadsto x \cdot 0.5 + \color{blue}{y \cdot \left(1 + \log z\right)} \]
    4. Taylor expanded in x around 0 61.7%

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

    if 5.2000000000000001e-151 < z < 6.39999999999999957e-123 or 2.25000000000000011e-115 < z < 3.5000000000000003e-64

    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 z around inf 68.3%

      \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. associate-*r*68.3%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-1 \cdot y\right) \cdot z} \]
      2. mul-1-neg68.3%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right)} \cdot z \]
    5. Simplified68.3%

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

    if 5.2000000000000001e-11 < z

    1. Initial program 100.0%

      \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right) + x \cdot 0.5} \]
      2. fma-define100.0%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{-z}, x \cdot 0.5\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification80.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 5.2 \cdot 10^{-151}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{-123}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{elif}\;z \leq 2.25 \cdot 10^{-115}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{-64}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-11}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 74.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 3.4 \cdot 10^{-152} \lor \neg \left(z \leq 5.5 \cdot 10^{-123}\right) \land \left(z \leq 2.25 \cdot 10^{-115} \lor \neg \left(z \leq 1.25 \cdot 10^{-64}\right) \land z \leq 4.4 \cdot 10^{-11}\right):\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z 3.4e-152)
         (and (not (<= z 5.5e-123))
              (or (<= z 2.25e-115)
                  (and (not (<= z 1.25e-64)) (<= z 4.4e-11)))))
   (* y (+ 1.0 (log z)))
   (- (* x 0.5) (* y z))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= 3.4e-152) || (!(z <= 5.5e-123) && ((z <= 2.25e-115) || (!(z <= 1.25e-64) && (z <= 4.4e-11))))) {
		tmp = y * (1.0 + log(z));
	} else {
		tmp = (x * 0.5) - (y * z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= 3.4d-152) .or. (.not. (z <= 5.5d-123)) .and. (z <= 2.25d-115) .or. (.not. (z <= 1.25d-64)) .and. (z <= 4.4d-11)) then
        tmp = y * (1.0d0 + log(z))
    else
        tmp = (x * 0.5d0) - (y * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= 3.4e-152) || (!(z <= 5.5e-123) && ((z <= 2.25e-115) || (!(z <= 1.25e-64) && (z <= 4.4e-11))))) {
		tmp = y * (1.0 + Math.log(z));
	} else {
		tmp = (x * 0.5) - (y * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= 3.4e-152) or (not (z <= 5.5e-123) and ((z <= 2.25e-115) or (not (z <= 1.25e-64) and (z <= 4.4e-11)))):
		tmp = y * (1.0 + math.log(z))
	else:
		tmp = (x * 0.5) - (y * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= 3.4e-152) || (!(z <= 5.5e-123) && ((z <= 2.25e-115) || (!(z <= 1.25e-64) && (z <= 4.4e-11)))))
		tmp = Float64(y * Float64(1.0 + log(z)));
	else
		tmp = Float64(Float64(x * 0.5) - Float64(y * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= 3.4e-152) || (~((z <= 5.5e-123)) && ((z <= 2.25e-115) || (~((z <= 1.25e-64)) && (z <= 4.4e-11)))))
		tmp = y * (1.0 + log(z));
	else
		tmp = (x * 0.5) - (y * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, 3.4e-152], And[N[Not[LessEqual[z, 5.5e-123]], $MachinePrecision], Or[LessEqual[z, 2.25e-115], And[N[Not[LessEqual[z, 1.25e-64]], $MachinePrecision], LessEqual[z, 4.4e-11]]]]], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.4 \cdot 10^{-152} \lor \neg \left(z \leq 5.5 \cdot 10^{-123}\right) \land \left(z \leq 2.25 \cdot 10^{-115} \lor \neg \left(z \leq 1.25 \cdot 10^{-64}\right) \land z \leq 4.4 \cdot 10^{-11}\right):\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 3.39999999999999984e-152 or 5.5e-123 < z < 2.25000000000000011e-115 or 1.25000000000000008e-64 < z < 4.4000000000000003e-11

    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 0 99.4%

      \[\leadsto x \cdot 0.5 + \color{blue}{y \cdot \left(1 + \log z\right)} \]
    4. Taylor expanded in x around 0 61.7%

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

    if 3.39999999999999984e-152 < z < 5.5e-123 or 2.25000000000000011e-115 < z < 1.25000000000000008e-64 or 4.4000000000000003e-11 < z

    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 z around inf 92.9%

      \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. associate-*r*92.9%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-1 \cdot y\right) \cdot z} \]
      2. mul-1-neg92.9%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right)} \cdot z \]
    5. Simplified92.9%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right) \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 3.4 \cdot 10^{-152} \lor \neg \left(z \leq 5.5 \cdot 10^{-123}\right) \land \left(z \leq 2.25 \cdot 10^{-115} \lor \neg \left(z \leq 1.25 \cdot 10^{-64}\right) \land z \leq 4.4 \cdot 10^{-11}\right):\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -4 \cdot 10^{-101}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\

\mathbf{elif}\;x \cdot 0.5 \leq 10^{-21}:\\
\;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x #s(literal 1/2 binary64)) < -4.00000000000000021e-101

    1. Initial program 99.9%

      \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right) + x \cdot 0.5} \]
      2. fma-define99.9%

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{-1 \cdot z}, x \cdot 0.5\right) \]
    6. Step-by-step derivation
      1. mul-1-neg82.4%

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

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

    if -4.00000000000000021e-101 < (*.f64 x #s(literal 1/2 binary64)) < 9.99999999999999908e-22

    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 -inf 68.8%

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

        \[\leadsto \color{blue}{-x \cdot \left(-1 \cdot \frac{y \cdot \left(\left(1 + \log z\right) - z\right)}{x} - 0.5\right)} \]
      2. distribute-rgt-neg-in68.8%

        \[\leadsto \color{blue}{x \cdot \left(-\left(-1 \cdot \frac{y \cdot \left(\left(1 + \log z\right) - z\right)}{x} - 0.5\right)\right)} \]
      3. fma-neg68.8%

        \[\leadsto x \cdot \left(-\color{blue}{\mathsf{fma}\left(-1, \frac{y \cdot \left(\left(1 + \log z\right) - z\right)}{x}, -0.5\right)}\right) \]
      4. *-commutative68.8%

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

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \frac{\left(\color{blue}{\left(\log z + 1\right)} - z\right) \cdot y}{x}, -0.5\right)\right) \]
      6. associate--l+68.8%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \frac{\color{blue}{\left(\log z + \left(1 - z\right)\right)} \cdot y}{x}, -0.5\right)\right) \]
      7. +-commutative68.8%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \frac{\color{blue}{\left(\left(1 - z\right) + \log z\right)} \cdot y}{x}, -0.5\right)\right) \]
      8. associate-/l*68.7%

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

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \color{blue}{\left(\log z + \left(1 - z\right)\right)} \cdot \frac{y}{x}, -0.5\right)\right) \]
      10. metadata-eval68.7%

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

      \[\leadsto \color{blue}{x \cdot \left(-\mathsf{fma}\left(-1, \left(\log z + \left(1 - z\right)\right) \cdot \frac{y}{x}, -0.5\right)\right)} \]
    6. Step-by-step derivation
      1. clear-num68.6%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \left(\log z + \left(1 - z\right)\right) \cdot \color{blue}{\frac{1}{\frac{x}{y}}}, -0.5\right)\right) \]
      2. un-div-inv68.7%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \color{blue}{\frac{\log z + \left(1 - z\right)}{\frac{x}{y}}}, -0.5\right)\right) \]
    7. Applied egg-rr68.7%

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

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

    if 9.99999999999999908e-22 < (*.f64 x #s(literal 1/2 binary64))

    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 z around inf 88.7%

      \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. associate-*r*88.7%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-1 \cdot y\right) \cdot z} \]
      2. mul-1-neg88.7%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right)} \cdot z \]
    5. Simplified88.7%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right) \cdot z} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -4 \cdot 10^{-101}:\\ \;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\ \mathbf{elif}\;x \cdot 0.5 \leq 10^{-21}:\\ \;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.0245:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\

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


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

    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 0 98.7%

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

    if 0.024500000000000001 < z

    1. Initial program 100.0%

      \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
    2. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right) + x \cdot 0.5} \]
      2. fma-define100.0%

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{-z}, x \cdot 0.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

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

Alternative 6: 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)));
}
real(8) function code(x, y, z)
    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}
Derivation
  1. Initial program 99.9%

    \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
  2. Add Preprocessing
  3. Final simplification99.9%

    \[\leadsto x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
  4. Add Preprocessing

Alternative 7: 55.9% accurate, 7.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -8.8 \cdot 10^{-41} \lor \neg \left(x \leq 2 \cdot 10^{-21}\right):\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -8.8e-41) (not (<= x 2e-21))) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -8.8e-41) || !(x <= 2e-21)) {
		tmp = x * 0.5;
	} else {
		tmp = y * -z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-8.8d-41)) .or. (.not. (x <= 2d-21))) then
        tmp = x * 0.5d0
    else
        tmp = y * -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -8.8e-41) || !(x <= 2e-21)) {
		tmp = x * 0.5;
	} else {
		tmp = y * -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -8.8e-41) or not (x <= 2e-21):
		tmp = x * 0.5
	else:
		tmp = y * -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -8.8e-41) || !(x <= 2e-21))
		tmp = Float64(x * 0.5);
	else
		tmp = Float64(y * Float64(-z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -8.8e-41) || ~((x <= 2e-21)))
		tmp = x * 0.5;
	else
		tmp = y * -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.8e-41], N[Not[LessEqual[x, 2e-21]], $MachinePrecision]], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{-41} \lor \neg \left(x \leq 2 \cdot 10^{-21}\right):\\
\;\;\;\;x \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.7999999999999999e-41 or 1.99999999999999982e-21 < x

    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 67.8%

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

    if -8.7999999999999999e-41 < x < 1.99999999999999982e-21

    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 -inf 70.6%

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

        \[\leadsto \color{blue}{-x \cdot \left(-1 \cdot \frac{y \cdot \left(\left(1 + \log z\right) - z\right)}{x} - 0.5\right)} \]
      2. distribute-rgt-neg-in70.6%

        \[\leadsto \color{blue}{x \cdot \left(-\left(-1 \cdot \frac{y \cdot \left(\left(1 + \log z\right) - z\right)}{x} - 0.5\right)\right)} \]
      3. fma-neg70.6%

        \[\leadsto x \cdot \left(-\color{blue}{\mathsf{fma}\left(-1, \frac{y \cdot \left(\left(1 + \log z\right) - z\right)}{x}, -0.5\right)}\right) \]
      4. *-commutative70.6%

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

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \frac{\left(\color{blue}{\left(\log z + 1\right)} - z\right) \cdot y}{x}, -0.5\right)\right) \]
      6. associate--l+70.6%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \frac{\color{blue}{\left(\log z + \left(1 - z\right)\right)} \cdot y}{x}, -0.5\right)\right) \]
      7. +-commutative70.6%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \frac{\color{blue}{\left(\left(1 - z\right) + \log z\right)} \cdot y}{x}, -0.5\right)\right) \]
      8. associate-/l*70.5%

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

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \color{blue}{\left(\log z + \left(1 - z\right)\right)} \cdot \frac{y}{x}, -0.5\right)\right) \]
      10. metadata-eval70.5%

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

      \[\leadsto \color{blue}{x \cdot \left(-\mathsf{fma}\left(-1, \left(\log z + \left(1 - z\right)\right) \cdot \frac{y}{x}, -0.5\right)\right)} \]
    6. Step-by-step derivation
      1. clear-num70.5%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \left(\log z + \left(1 - z\right)\right) \cdot \color{blue}{\frac{1}{\frac{x}{y}}}, -0.5\right)\right) \]
      2. un-div-inv70.5%

        \[\leadsto x \cdot \left(-\mathsf{fma}\left(-1, \color{blue}{\frac{\log z + \left(1 - z\right)}{\frac{x}{y}}}, -0.5\right)\right) \]
    7. Applied egg-rr70.5%

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

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

        \[\leadsto \color{blue}{-y \cdot z} \]
      2. distribute-rgt-neg-in49.4%

        \[\leadsto \color{blue}{y \cdot \left(-z\right)} \]
    10. Simplified49.4%

      \[\leadsto \color{blue}{y \cdot \left(-z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.8 \cdot 10^{-41} \lor \neg \left(x \leq 2 \cdot 10^{-21}\right):\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 75.8% accurate, 15.9× speedup?

\[\begin{array}{l} \\ x \cdot 0.5 - y \cdot z \end{array} \]
(FPCore (x y z) :precision binary64 (- (* x 0.5) (* y z)))
double code(double x, double y, double z) {
	return (x * 0.5) - (y * z);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * 0.5d0) - (y * z)
end function
public static double code(double x, double y, double z) {
	return (x * 0.5) - (y * z);
}
def code(x, y, z):
	return (x * 0.5) - (y * z)
function code(x, y, z)
	return Float64(Float64(x * 0.5) - Float64(y * z))
end
function tmp = code(x, y, z)
	tmp = (x * 0.5) - (y * z);
end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x \cdot 0.5 - y \cdot z
\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 z around inf 72.6%

    \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
  4. Step-by-step derivation
    1. associate-*r*72.6%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-1 \cdot y\right) \cdot z} \]
    2. mul-1-neg72.6%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right)} \cdot z \]
  5. Simplified72.6%

    \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right) \cdot z} \]
  6. Final simplification72.6%

    \[\leadsto x \cdot 0.5 - y \cdot z \]
  7. Add Preprocessing

Alternative 9: 41.5% accurate, 37.0× speedup?

\[\begin{array}{l} \\ x \cdot 0.5 \end{array} \]
(FPCore (x y z) :precision binary64 (* x 0.5))
double code(double x, double y, double z) {
	return x * 0.5;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x * 0.5d0
end function
public static double code(double x, double y, double z) {
	return x * 0.5;
}
def code(x, y, z):
	return x * 0.5
function code(x, y, z)
	return Float64(x * 0.5)
end
function tmp = code(x, y, z)
	tmp = x * 0.5;
end
code[x_, y_, z_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}

\\
x \cdot 0.5
\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 41.2%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  4. Final simplification41.2%

    \[\leadsto x \cdot 0.5 \]
  5. Add Preprocessing

Developer target: 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)));
}
real(8) function code(x, y, z)
    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 2024078 
(FPCore (x y z)
  :name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
  :precision binary64

  :alt
  (- (+ y (* 0.5 x)) (* y (- z (log z))))

  (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))