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

Percentage Accurate: 99.9% → 99.9%
Time: 9.8s
Alternatives: 9
Speedup: N/A×

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, 1.0× speedup?

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

\\
\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(y, \log z - z, 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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(y, \color{blue}{z \cdot \left(-1 \cdot \frac{\log \left(\frac{1}{z}\right)}{z} - 1\right)}, \mathsf{fma}\left(\frac{1}{2}, x, y\right)\right) \]
  7. Step-by-step derivation
    1. distribute-rgt-out--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 59.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(\log z + \left(1 - z\right)\right)\\ t_1 := z \cdot \left(-y\right)\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{+175}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+28}:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ (log z) (- 1.0 z)))) (t_1 (* z (- y))))
   (if (<= t_0 -2e+175) t_1 (if (<= t_0 2e+28) (* 0.5 x) t_1))))
double code(double x, double y, double z) {
	double t_0 = y * (log(z) + (1.0 - z));
	double t_1 = z * -y;
	double tmp;
	if (t_0 <= -2e+175) {
		tmp = t_1;
	} else if (t_0 <= 2e+28) {
		tmp = 0.5 * x;
	} else {
		tmp = t_1;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y * (log(z) + (1.0d0 - z))
    t_1 = z * -y
    if (t_0 <= (-2d+175)) then
        tmp = t_1
    else if (t_0 <= 2d+28) then
        tmp = 0.5d0 * x
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (Math.log(z) + (1.0 - z));
	double t_1 = z * -y;
	double tmp;
	if (t_0 <= -2e+175) {
		tmp = t_1;
	} else if (t_0 <= 2e+28) {
		tmp = 0.5 * x;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (math.log(z) + (1.0 - z))
	t_1 = z * -y
	tmp = 0
	if t_0 <= -2e+175:
		tmp = t_1
	elif t_0 <= 2e+28:
		tmp = 0.5 * x
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(log(z) + Float64(1.0 - z)))
	t_1 = Float64(z * Float64(-y))
	tmp = 0.0
	if (t_0 <= -2e+175)
		tmp = t_1;
	elseif (t_0 <= 2e+28)
		tmp = Float64(0.5 * x);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (log(z) + (1.0 - z));
	t_1 = z * -y;
	tmp = 0.0;
	if (t_0 <= -2e+175)
		tmp = t_1;
	elseif (t_0 <= 2e+28)
		tmp = 0.5 * x;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[Log[z], $MachinePrecision] + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * (-y)), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+175], t$95$1, If[LessEqual[t$95$0, 2e+28], N[(0.5 * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+28}:\\
\;\;\;\;0.5 \cdot x\\

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


\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))) < -1.9999999999999999e175 or 1.99999999999999992e28 < (*.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. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(y \cdot z\right)} \]
      2. distribute-rgt-neg-inN/A

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

        \[\leadsto \color{blue}{y \cdot \left(\mathsf{neg}\left(z\right)\right)} \]
      4. lower-neg.f6460.5

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

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

    if -1.9999999999999999e175 < (*.f64 y (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z))) < 1.99999999999999992e28

    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. lower-*.f6461.7

        \[\leadsto \color{blue}{0.5 \cdot x} \]
    5. Simplified61.7%

      \[\leadsto \color{blue}{0.5 \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification61.2%

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

Alternative 3: 73.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\log z + \left(1 - z\right) \leq -470:\\
\;\;\;\;\mathsf{fma}\left(y, -z, 0.5 \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \log z, 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)) < -470

    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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \mathsf{fma}\left(\frac{1}{2}, x, y\right)\right) \]
      2. lower-neg.f6490.0

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-z}, \mathsf{fma}\left(0.5, x, y\right)\right) \]
    8. Simplified90.0%

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

      \[\leadsto \mathsf{fma}\left(y, \mathsf{neg}\left(z\right), \color{blue}{\frac{1}{2} \cdot x}\right) \]
    10. Step-by-step derivation
      1. lower-*.f6490.3

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

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

    if -470 < (+.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. distribute-lft-inN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \log z + y \cdot 1} \]
      3. *-rgt-identityN/A

        \[\leadsto y \cdot \log z + \color{blue}{y} \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, \log z, y\right)} \]
      5. lower-log.f6453.9

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z}, y\right) \]
    8. Simplified53.9%

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

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

Alternative 4: 85.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y, -z, 0.5 \cdot x\right)\\
\mathbf{if}\;0.5 \cdot x \leq -1 \cdot 10^{-47}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;0.5 \cdot x \leq 2 \cdot 10^{-83}:\\
\;\;\;\;\mathsf{fma}\left(y, \log z - z, y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x #s(literal 1/2 binary64)) < -9.9999999999999997e-48 or 2.0000000000000001e-83 < (*.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 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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \mathsf{fma}\left(\frac{1}{2}, x, y\right)\right) \]
      2. lower-neg.f6490.4

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

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

      \[\leadsto \mathsf{fma}\left(y, \mathsf{neg}\left(z\right), \color{blue}{\frac{1}{2} \cdot x}\right) \]
    10. Step-by-step derivation
      1. lower-*.f6490.9

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

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

    if -9.9999999999999997e-48 < (*.f64 x #s(literal 1/2 binary64)) < 2.0000000000000001e-83

    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 x around 0

      \[\leadsto \color{blue}{y \cdot \left(\left(1 + \log z\right) - z\right)} \]
    4. Step-by-step derivation
      1. sub-negN/A

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

        \[\leadsto y \cdot \color{blue}{\left(1 + \left(\log z + \left(\mathsf{neg}\left(z\right)\right)\right)\right)} \]
      3. mul-1-negN/A

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

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

        \[\leadsto \color{blue}{y \cdot \left(\log z + -1 \cdot z\right) + y \cdot 1} \]
      6. *-rgt-identityN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, \log z + -1 \cdot z, y\right)} \]
      8. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(y, \log z + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}, y\right) \]
      9. sub-negN/A

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z - z}, y\right) \]
      11. lower-log.f6495.8

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z} - z, y\right) \]
    5. Simplified95.8%

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

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

Alternative 5: 98.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.052:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(y, \log z, y\right)\right)\\

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


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

    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 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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{z \cdot \left(-1 \cdot \frac{\log \left(\frac{1}{z}\right)}{z} - 1\right)}, \mathsf{fma}\left(\frac{1}{2}, x, y\right)\right) \]
    7. Step-by-step derivation
      1. distribute-rgt-out--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x + y \cdot \left(\left(1 + \log z\right) - z\right)} \]
    10. Simplified99.7%

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{2}, x, \color{blue}{\mathsf{fma}\left(y, \log z, y\right)}\right) \]
      3. lower-log.f6498.1

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

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

    if 0.0519999999999999976 < z

    1. Initial program 100.0%

      \[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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \log z - z, \color{blue}{\frac{1}{2} \cdot x}\right) \]
    7. Step-by-step derivation
      1. lower-*.f6498.5

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

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

Alternative 6: 98.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.052:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(y, \log z, y\right)\right)\\

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


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

    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 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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{z \cdot \left(-1 \cdot \frac{\log \left(\frac{1}{z}\right)}{z} - 1\right)}, \mathsf{fma}\left(\frac{1}{2}, x, y\right)\right) \]
    7. Step-by-step derivation
      1. distribute-rgt-out--N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x + y \cdot \left(\left(1 + \log z\right) - z\right)} \]
    10. Simplified99.7%

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{1}{2}, x, \color{blue}{\mathsf{fma}\left(y, \log z, y\right)}\right) \]
      3. lower-log.f6498.1

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

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

    if 0.0519999999999999976 < z

    1. Initial program 100.0%

      \[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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \mathsf{fma}\left(\frac{1}{2}, x, y\right)\right) \]
      2. lower-neg.f6498.2

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-z}, \mathsf{fma}\left(0.5, x, y\right)\right) \]
    8. Simplified98.2%

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

Alternative 7: 74.3% accurate, 8.6× speedup?

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

\\
\mathsf{fma}\left(y, -z, 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. 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. sub-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \mathsf{fma}\left(\frac{1}{2}, x, y\right)\right) \]
    2. lower-neg.f6475.5

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{-z}, \mathsf{fma}\left(0.5, x, y\right)\right) \]
  8. Simplified75.5%

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

    \[\leadsto \mathsf{fma}\left(y, \mathsf{neg}\left(z\right), \color{blue}{\frac{1}{2} \cdot x}\right) \]
  10. Step-by-step derivation
    1. lower-*.f6476.6

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

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

Alternative 8: 74.3% accurate, 8.6× speedup?

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

\\
\mathsf{fma}\left(0.5, x, z \cdot \left(-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 z around inf

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

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

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

      \[\leadsto x \cdot \frac{1}{2} + \color{blue}{y \cdot \left(\mathsf{neg}\left(z\right)\right)} \]
    4. lower-neg.f6476.6

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

    \[\leadsto x \cdot 0.5 + \color{blue}{y \cdot \left(-z\right)} \]
  6. Taylor expanded in x around 0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, x, -1 \cdot \left(y \cdot z\right)\right)} \]
    3. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(\frac{1}{2}, x, \color{blue}{\mathsf{neg}\left(y \cdot z\right)}\right) \]
    4. distribute-rgt-neg-inN/A

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{2}, x, \color{blue}{y \cdot \left(\mathsf{neg}\left(z\right)\right)}\right) \]
    6. lower-neg.f6476.6

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

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

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

Alternative 9: 39.2% 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;
}
real(8) function code(x, y, z)
    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. lower-*.f6441.7

      \[\leadsto \color{blue}{0.5 \cdot x} \]
  5. Simplified41.7%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  6. 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)));
}
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 2024215 
(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)))))