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

Percentage Accurate: 99.9% → 99.9%
Time: 7.9s
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, 1.0× speedup?

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

\\
x \cdot 0.5 - y \cdot \left(\left(z + -1\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. Final simplification99.9%

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

Alternative 2: 85.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{-57} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-32}\right):\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y + y \cdot \left(\log z - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* x 0.5) -2e-57) (not (<= (* x 0.5) 5e-32)))
   (- (* x 0.5) (* y z))
   (+ y (* y (- (log z) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (((x * 0.5) <= -2e-57) || !((x * 0.5) <= 5e-32)) {
		tmp = (x * 0.5) - (y * z);
	} else {
		tmp = y + (y * (log(z) - 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 * 0.5d0) <= (-2d-57)) .or. (.not. ((x * 0.5d0) <= 5d-32))) then
        tmp = (x * 0.5d0) - (y * z)
    else
        tmp = y + (y * (log(z) - z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (((x * 0.5) <= -2e-57) || !((x * 0.5) <= 5e-32)) {
		tmp = (x * 0.5) - (y * z);
	} else {
		tmp = y + (y * (Math.log(z) - z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((x * 0.5) <= -2e-57) or not ((x * 0.5) <= 5e-32):
		tmp = (x * 0.5) - (y * z)
	else:
		tmp = y + (y * (math.log(z) - z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(x * 0.5) <= -2e-57) || !(Float64(x * 0.5) <= 5e-32))
		tmp = Float64(Float64(x * 0.5) - Float64(y * z));
	else
		tmp = Float64(y + Float64(y * Float64(log(z) - z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((x * 0.5) <= -2e-57) || ~(((x * 0.5) <= 5e-32)))
		tmp = (x * 0.5) - (y * z);
	else
		tmp = y + (y * (log(z) - z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * 0.5), $MachinePrecision], -2e-57], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-32]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y + N[(y * N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{-57} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-32}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x 1/2) < -1.99999999999999991e-57 or 5e-32 < (*.f64 x 1/2)

    1. Initial program 100.0%

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

      \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg88.0%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y \cdot z\right)} \]
      2. distribute-rgt-neg-out88.0%

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

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

    if -1.99999999999999991e-57 < (*.f64 x 1/2) < 5e-32

    1. Initial program 99.7%

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

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

        \[\leadsto x \cdot 0.5 + y \cdot \color{blue}{\left(1 + \left(\left(-z\right) + \log z\right)\right)} \]
      3. distribute-lft-in99.7%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot 1 + y \cdot \left(\left(-z\right) + \log z\right)\right)} \]
      4. *-rgt-identity99.7%

        \[\leadsto x \cdot 0.5 + \left(\color{blue}{y} + y \cdot \left(\left(-z\right) + \log z\right)\right) \]
      5. associate-+r+99.7%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{-57} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-32}\right):\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y + y \cdot \left(\log z - z\right)\\ \end{array} \]

Alternative 3: 85.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{-57} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-32}\right):\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 + \left(\log z - z\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* x 0.5) -2e-57) (not (<= (* x 0.5) 5e-32)))
   (- (* x 0.5) (* y z))
   (* y (+ 1.0 (- (log z) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (((x * 0.5) <= -2e-57) || !((x * 0.5) <= 5e-32)) {
		tmp = (x * 0.5) - (y * z);
	} else {
		tmp = y * (1.0 + (log(z) - 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 * 0.5d0) <= (-2d-57)) .or. (.not. ((x * 0.5d0) <= 5d-32))) then
        tmp = (x * 0.5d0) - (y * z)
    else
        tmp = y * (1.0d0 + (log(z) - z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (((x * 0.5) <= -2e-57) || !((x * 0.5) <= 5e-32)) {
		tmp = (x * 0.5) - (y * z);
	} else {
		tmp = y * (1.0 + (Math.log(z) - z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((x * 0.5) <= -2e-57) or not ((x * 0.5) <= 5e-32):
		tmp = (x * 0.5) - (y * z)
	else:
		tmp = y * (1.0 + (math.log(z) - z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(x * 0.5) <= -2e-57) || !(Float64(x * 0.5) <= 5e-32))
		tmp = Float64(Float64(x * 0.5) - Float64(y * z));
	else
		tmp = Float64(y * Float64(1.0 + Float64(log(z) - z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((x * 0.5) <= -2e-57) || ~(((x * 0.5) <= 5e-32)))
		tmp = (x * 0.5) - (y * z);
	else
		tmp = y * (1.0 + (log(z) - z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * 0.5), $MachinePrecision], -2e-57], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-32]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 + N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{-57} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-32}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x 1/2) < -1.99999999999999991e-57 or 5e-32 < (*.f64 x 1/2)

    1. Initial program 100.0%

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

      \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg88.0%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y \cdot z\right)} \]
      2. distribute-rgt-neg-out88.0%

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

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

    if -1.99999999999999991e-57 < (*.f64 x 1/2) < 5e-32

    1. Initial program 99.7%

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

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

        \[\leadsto x \cdot 0.5 + y \cdot \color{blue}{\left(1 + \left(\left(-z\right) + \log z\right)\right)} \]
      3. distribute-lft-in99.7%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot 1 + y \cdot \left(\left(-z\right) + \log z\right)\right)} \]
      4. *-rgt-identity99.7%

        \[\leadsto x \cdot 0.5 + \left(\color{blue}{y} + y \cdot \left(\left(-z\right) + \log z\right)\right) \]
      5. associate-+r+99.7%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(-1 \cdot \left(\log z - z\right) - 1\right)\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg91.0%

        \[\leadsto \color{blue}{-y \cdot \left(-1 \cdot \left(\log z - z\right) - 1\right)} \]
      2. distribute-rgt-neg-in91.0%

        \[\leadsto \color{blue}{y \cdot \left(-\left(-1 \cdot \left(\log z - z\right) - 1\right)\right)} \]
      3. sub-neg91.0%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 \cdot \left(\log z - z\right) + \left(-1\right)\right)}\right) \]
      4. mul-1-neg91.0%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(-\left(\log z - z\right)\right)} + \left(-1\right)\right)\right) \]
      5. sub-neg91.0%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\log z + \left(-z\right)\right)}\right) + \left(-1\right)\right)\right) \]
      6. +-commutative91.0%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\left(-z\right) + \log z\right)}\right) + \left(-1\right)\right)\right) \]
      7. distribute-neg-in91.0%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(\left(-\left(-z\right)\right) + \left(-\log z\right)\right)} + \left(-1\right)\right)\right) \]
      8. remove-double-neg91.0%

        \[\leadsto y \cdot \left(-\left(\left(\color{blue}{z} + \left(-\log z\right)\right) + \left(-1\right)\right)\right) \]
      9. sub-neg91.0%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(z - \log z\right)} + \left(-1\right)\right)\right) \]
      10. metadata-eval91.0%

        \[\leadsto y \cdot \left(-\left(\left(z - \log z\right) + \color{blue}{-1}\right)\right) \]
      11. +-commutative91.0%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 + \left(z - \log z\right)\right)}\right) \]
    6. Simplified91.0%

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

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

Alternative 4: 73.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq 10^{-260} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-124}\right):\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y + y \cdot \log z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* x 0.5) 1e-260) (not (<= (* x 0.5) 5e-124)))
   (- (* x 0.5) (* y z))
   (+ y (* y (log z)))))
double code(double x, double y, double z) {
	double tmp;
	if (((x * 0.5) <= 1e-260) || !((x * 0.5) <= 5e-124)) {
		tmp = (x * 0.5) - (y * z);
	} else {
		tmp = y + (y * log(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 * 0.5d0) <= 1d-260) .or. (.not. ((x * 0.5d0) <= 5d-124))) then
        tmp = (x * 0.5d0) - (y * z)
    else
        tmp = y + (y * log(z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (((x * 0.5) <= 1e-260) || !((x * 0.5) <= 5e-124)) {
		tmp = (x * 0.5) - (y * z);
	} else {
		tmp = y + (y * Math.log(z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if ((x * 0.5) <= 1e-260) or not ((x * 0.5) <= 5e-124):
		tmp = (x * 0.5) - (y * z)
	else:
		tmp = y + (y * math.log(z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((Float64(x * 0.5) <= 1e-260) || !(Float64(x * 0.5) <= 5e-124))
		tmp = Float64(Float64(x * 0.5) - Float64(y * z));
	else
		tmp = Float64(y + Float64(y * log(z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (((x * 0.5) <= 1e-260) || ~(((x * 0.5) <= 5e-124)))
		tmp = (x * 0.5) - (y * z);
	else
		tmp = y + (y * log(z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * 0.5), $MachinePrecision], 1e-260], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-124]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq 10^{-260} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-124}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\

\mathbf{else}:\\
\;\;\;\;y + y \cdot \log z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x 1/2) < 9.99999999999999961e-261 or 5.0000000000000003e-124 < (*.f64 x 1/2)

    1. Initial program 99.9%

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

      \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg80.5%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y \cdot z\right)} \]
      2. distribute-rgt-neg-out80.5%

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

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

    if 9.99999999999999961e-261 < (*.f64 x 1/2) < 5.0000000000000003e-124

    1. Initial program 99.4%

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

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

        \[\leadsto x \cdot 0.5 + y \cdot \color{blue}{\left(1 + \left(\left(-z\right) + \log z\right)\right)} \]
      3. distribute-lft-in99.4%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot 1 + y \cdot \left(\left(-z\right) + \log z\right)\right)} \]
      4. *-rgt-identity99.4%

        \[\leadsto x \cdot 0.5 + \left(\color{blue}{y} + y \cdot \left(\left(-z\right) + \log z\right)\right) \]
      5. associate-+r+99.5%

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

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

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

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

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

      \[\leadsto \color{blue}{y + y \cdot \left(\log z - z\right)} \]
    5. Taylor expanded in z around 0 70.9%

      \[\leadsto \color{blue}{y \cdot \log z + y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification79.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq 10^{-260} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-124}\right):\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y + y \cdot \log z\\ \end{array} \]

Alternative 5: 98.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

        \[\leadsto x \cdot 0.5 + y \cdot \color{blue}{\left(1 + \left(\left(-z\right) + \log z\right)\right)} \]
      3. distribute-lft-in99.7%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot 1 + y \cdot \left(\left(-z\right) + \log z\right)\right)} \]
      4. *-rgt-identity99.7%

        \[\leadsto x \cdot 0.5 + \left(\color{blue}{y} + y \cdot \left(\left(-z\right) + \log z\right)\right) \]
      5. associate-+r+99.7%

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

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

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

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

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

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

    if 0.28000000000000003 < z

    1. Initial program 100.0%

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

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

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y \cdot z\right)} \]
      2. distribute-rgt-neg-out99.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 0.28:\\ \;\;\;\;y \cdot \log z + \left(x \cdot 0.5 + y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \end{array} \]

Alternative 6: 58.4% accurate, 10.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 8.8 \cdot 10^{+14} \lor \neg \left(z \leq 2.6 \cdot 10^{+87}\right) \land z \leq 6.6 \cdot 10^{+127}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z 8.8e+14) (and (not (<= z 2.6e+87)) (<= z 6.6e+127)))
   (* x 0.5)
   (* y (- z))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= 8.8e+14) || (!(z <= 2.6e+87) && (z <= 6.6e+127))) {
		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 ((z <= 8.8d+14) .or. (.not. (z <= 2.6d+87)) .and. (z <= 6.6d+127)) 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 ((z <= 8.8e+14) || (!(z <= 2.6e+87) && (z <= 6.6e+127))) {
		tmp = x * 0.5;
	} else {
		tmp = y * -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= 8.8e+14) or (not (z <= 2.6e+87) and (z <= 6.6e+127)):
		tmp = x * 0.5
	else:
		tmp = y * -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= 8.8e+14) || (!(z <= 2.6e+87) && (z <= 6.6e+127)))
		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 ((z <= 8.8e+14) || (~((z <= 2.6e+87)) && (z <= 6.6e+127)))
		tmp = x * 0.5;
	else
		tmp = y * -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, 8.8e+14], And[N[Not[LessEqual[z, 2.6e+87]], $MachinePrecision], LessEqual[z, 6.6e+127]]], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.8 \cdot 10^{+14} \lor \neg \left(z \leq 2.6 \cdot 10^{+87}\right) \land z \leq 6.6 \cdot 10^{+127}:\\
\;\;\;\;x \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 8.8e14 or 2.59999999999999998e87 < z < 6.59999999999999953e127

    1. Initial program 99.8%

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

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

    if 8.8e14 < z < 2.59999999999999998e87 or 6.59999999999999953e127 < 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. sub-neg100.0%

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

        \[\leadsto x \cdot 0.5 + y \cdot \color{blue}{\left(1 + \left(\left(-z\right) + \log z\right)\right)} \]
      3. distribute-lft-in100.0%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot 1 + y \cdot \left(\left(-z\right) + \log z\right)\right)} \]
      4. *-rgt-identity100.0%

        \[\leadsto x \cdot 0.5 + \left(\color{blue}{y} + y \cdot \left(\left(-z\right) + \log z\right)\right) \]
      5. associate-+r+100.0%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot \left(-1 \cdot \left(\log z - z\right) - 1\right)\right)} \]
    5. Step-by-step derivation
      1. mul-1-neg77.8%

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

        \[\leadsto \color{blue}{y \cdot \left(-\left(-1 \cdot \left(\log z - z\right) - 1\right)\right)} \]
      3. sub-neg77.8%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 \cdot \left(\log z - z\right) + \left(-1\right)\right)}\right) \]
      4. mul-1-neg77.8%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(-\left(\log z - z\right)\right)} + \left(-1\right)\right)\right) \]
      5. sub-neg77.8%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\log z + \left(-z\right)\right)}\right) + \left(-1\right)\right)\right) \]
      6. +-commutative77.8%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\left(-z\right) + \log z\right)}\right) + \left(-1\right)\right)\right) \]
      7. distribute-neg-in77.8%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(\left(-\left(-z\right)\right) + \left(-\log z\right)\right)} + \left(-1\right)\right)\right) \]
      8. remove-double-neg77.8%

        \[\leadsto y \cdot \left(-\left(\left(\color{blue}{z} + \left(-\log z\right)\right) + \left(-1\right)\right)\right) \]
      9. sub-neg77.8%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(z - \log z\right)} + \left(-1\right)\right)\right) \]
      10. metadata-eval77.8%

        \[\leadsto y \cdot \left(-\left(\left(z - \log z\right) + \color{blue}{-1}\right)\right) \]
      11. +-commutative77.8%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 + \left(z - \log z\right)\right)}\right) \]
    6. Simplified77.8%

      \[\leadsto \color{blue}{y \cdot \left(-\left(-1 + \left(z - \log z\right)\right)\right)} \]
    7. Taylor expanded in z around inf 77.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 8.8 \cdot 10^{+14} \lor \neg \left(z \leq 2.6 \cdot 10^{+87}\right) \land z \leq 6.6 \cdot 10^{+127}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \]

Alternative 7: 58.7% accurate, 10.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq 6.5 \cdot 10^{+14}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+87}:\\ \;\;\;\;y \cdot \left(1 - z\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+124}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z 6.5e+14)
   (* x 0.5)
   (if (<= z 6.5e+87)
     (* y (- 1.0 z))
     (if (<= z 1.35e+124) (* x 0.5) (* y (- z))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= 6.5e+14) {
		tmp = x * 0.5;
	} else if (z <= 6.5e+87) {
		tmp = y * (1.0 - z);
	} else if (z <= 1.35e+124) {
		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 (z <= 6.5d+14) then
        tmp = x * 0.5d0
    else if (z <= 6.5d+87) then
        tmp = y * (1.0d0 - z)
    else if (z <= 1.35d+124) 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 (z <= 6.5e+14) {
		tmp = x * 0.5;
	} else if (z <= 6.5e+87) {
		tmp = y * (1.0 - z);
	} else if (z <= 1.35e+124) {
		tmp = x * 0.5;
	} else {
		tmp = y * -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= 6.5e+14:
		tmp = x * 0.5
	elif z <= 6.5e+87:
		tmp = y * (1.0 - z)
	elif z <= 1.35e+124:
		tmp = x * 0.5
	else:
		tmp = y * -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= 6.5e+14)
		tmp = Float64(x * 0.5);
	elseif (z <= 6.5e+87)
		tmp = Float64(y * Float64(1.0 - z));
	elseif (z <= 1.35e+124)
		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 (z <= 6.5e+14)
		tmp = x * 0.5;
	elseif (z <= 6.5e+87)
		tmp = y * (1.0 - z);
	elseif (z <= 1.35e+124)
		tmp = x * 0.5;
	else
		tmp = y * -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, 6.5e+14], N[(x * 0.5), $MachinePrecision], If[LessEqual[z, 6.5e+87], N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.35e+124], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.5 \cdot 10^{+14}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{+87}:\\
\;\;\;\;y \cdot \left(1 - z\right)\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{+124}:\\
\;\;\;\;x \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 6.5e14 or 6.5000000000000002e87 < z < 1.34999999999999989e124

    1. Initial program 99.8%

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

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

    if 6.5e14 < z < 6.5000000000000002e87

    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. sub-neg100.0%

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

        \[\leadsto x \cdot 0.5 + y \cdot \color{blue}{\left(1 + \left(\left(-z\right) + \log z\right)\right)} \]
      3. distribute-lft-in100.0%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot 1 + y \cdot \left(\left(-z\right) + \log z\right)\right)} \]
      4. *-rgt-identity100.0%

        \[\leadsto x \cdot 0.5 + \left(\color{blue}{y} + y \cdot \left(\left(-z\right) + \log z\right)\right) \]
      5. associate-+r+100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-y \cdot \left(-1 \cdot \left(\log z - z\right) - 1\right)} \]
      2. distribute-rgt-neg-in74.9%

        \[\leadsto \color{blue}{y \cdot \left(-\left(-1 \cdot \left(\log z - z\right) - 1\right)\right)} \]
      3. sub-neg74.9%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 \cdot \left(\log z - z\right) + \left(-1\right)\right)}\right) \]
      4. mul-1-neg74.9%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(-\left(\log z - z\right)\right)} + \left(-1\right)\right)\right) \]
      5. sub-neg74.9%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\log z + \left(-z\right)\right)}\right) + \left(-1\right)\right)\right) \]
      6. +-commutative74.9%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\left(-z\right) + \log z\right)}\right) + \left(-1\right)\right)\right) \]
      7. distribute-neg-in74.9%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(\left(-\left(-z\right)\right) + \left(-\log z\right)\right)} + \left(-1\right)\right)\right) \]
      8. remove-double-neg74.9%

        \[\leadsto y \cdot \left(-\left(\left(\color{blue}{z} + \left(-\log z\right)\right) + \left(-1\right)\right)\right) \]
      9. sub-neg74.9%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(z - \log z\right)} + \left(-1\right)\right)\right) \]
      10. metadata-eval74.9%

        \[\leadsto y \cdot \left(-\left(\left(z - \log z\right) + \color{blue}{-1}\right)\right) \]
      11. +-commutative74.9%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 + \left(z - \log z\right)\right)}\right) \]
    6. Simplified74.9%

      \[\leadsto \color{blue}{y \cdot \left(-\left(-1 + \left(z - \log z\right)\right)\right)} \]
    7. Step-by-step derivation
      1. expm1-log1p-u71.2%

        \[\leadsto y \cdot \left(-\left(-1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(z - \log z\right)\right)}\right)\right) \]
    8. Applied egg-rr71.2%

      \[\leadsto y \cdot \left(-\left(-1 + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(z - \log z\right)\right)}\right)\right) \]
    9. Taylor expanded in z around inf 74.4%

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

    if 1.34999999999999989e124 < 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. sub-neg100.0%

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

        \[\leadsto x \cdot 0.5 + y \cdot \color{blue}{\left(1 + \left(\left(-z\right) + \log z\right)\right)} \]
      3. distribute-lft-in100.0%

        \[\leadsto x \cdot 0.5 + \color{blue}{\left(y \cdot 1 + y \cdot \left(\left(-z\right) + \log z\right)\right)} \]
      4. *-rgt-identity100.0%

        \[\leadsto x \cdot 0.5 + \left(\color{blue}{y} + y \cdot \left(\left(-z\right) + \log z\right)\right) \]
      5. associate-+r+100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-y \cdot \left(-1 \cdot \left(\log z - z\right) - 1\right)} \]
      2. distribute-rgt-neg-in78.9%

        \[\leadsto \color{blue}{y \cdot \left(-\left(-1 \cdot \left(\log z - z\right) - 1\right)\right)} \]
      3. sub-neg78.9%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 \cdot \left(\log z - z\right) + \left(-1\right)\right)}\right) \]
      4. mul-1-neg78.9%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(-\left(\log z - z\right)\right)} + \left(-1\right)\right)\right) \]
      5. sub-neg78.9%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\log z + \left(-z\right)\right)}\right) + \left(-1\right)\right)\right) \]
      6. +-commutative78.9%

        \[\leadsto y \cdot \left(-\left(\left(-\color{blue}{\left(\left(-z\right) + \log z\right)}\right) + \left(-1\right)\right)\right) \]
      7. distribute-neg-in78.9%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(\left(-\left(-z\right)\right) + \left(-\log z\right)\right)} + \left(-1\right)\right)\right) \]
      8. remove-double-neg78.9%

        \[\leadsto y \cdot \left(-\left(\left(\color{blue}{z} + \left(-\log z\right)\right) + \left(-1\right)\right)\right) \]
      9. sub-neg78.9%

        \[\leadsto y \cdot \left(-\left(\color{blue}{\left(z - \log z\right)} + \left(-1\right)\right)\right) \]
      10. metadata-eval78.9%

        \[\leadsto y \cdot \left(-\left(\left(z - \log z\right) + \color{blue}{-1}\right)\right) \]
      11. +-commutative78.9%

        \[\leadsto y \cdot \left(-\color{blue}{\left(-1 + \left(z - \log z\right)\right)}\right) \]
    6. Simplified78.9%

      \[\leadsto \color{blue}{y \cdot \left(-\left(-1 + \left(z - \log z\right)\right)\right)} \]
    7. Taylor expanded in z around inf 78.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 6.5 \cdot 10^{+14}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+87}:\\ \;\;\;\;y \cdot \left(1 - z\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{+124}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \]

Alternative 8: 75.2% 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. Taylor expanded in z around inf 76.5%

    \[\leadsto x \cdot 0.5 + \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
  3. Step-by-step derivation
    1. mul-1-neg76.5%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y \cdot z\right)} \]
    2. distribute-rgt-neg-out76.5%

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

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

    \[\leadsto x \cdot 0.5 - y \cdot z \]

Alternative 9: 41.4% 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. Taylor expanded in x around inf 43.7%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  3. Final simplification43.7%

    \[\leadsto x \cdot 0.5 \]

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 2023213 
(FPCore (x y z)
  :name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
  :precision binary64

  :herbie-target
  (- (+ y (* 0.5 x)) (* y (- z (log z))))

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