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

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

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

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

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

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

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

Alternative 2: 60.5% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;x \cdot 0.5\\


\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))) < -9.9999999999999999e45 or 2.00000000000000005e144 < (*.f64 y (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z)))

    1. Initial program 99.9%

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

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

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

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{\left(-z\right)} + 0.5 \cdot \frac{x}{y}\right) \]
      2. +-commutative70.8%

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

        \[\leadsto y \cdot \color{blue}{\left(0.5 \cdot \frac{x}{y} - z\right)} \]
    8. Simplified70.8%

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

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

        \[\leadsto y \cdot \color{blue}{\left(-z\right)} \]
    11. Simplified63.7%

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

    if -9.9999999999999999e45 < (*.f64 y (+.f64 (-.f64 #s(literal 1 binary64) z) (log.f64 z))) < 2.00000000000000005e144

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

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

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

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

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

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

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

Alternative 3: 98.4% accurate, 0.5× speedup?

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

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

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


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

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

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

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

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

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right) \cdot z} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-out99.7%

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

        \[\leadsto \color{blue}{x \cdot 0.5 - y \cdot z} \]
      3. add-sqr-sqrt49.5%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot z \]
      4. sqrt-unprod59.1%

        \[\leadsto x \cdot 0.5 - \color{blue}{\sqrt{y \cdot y}} \cdot z \]
      5. sqr-neg59.1%

        \[\leadsto x \cdot 0.5 - \sqrt{\color{blue}{\left(-y\right) \cdot \left(-y\right)}} \cdot z \]
      6. sqrt-unprod17.8%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \cdot z \]
      7. add-sqr-sqrt31.1%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(-y\right)} \cdot z \]
      8. *-commutative31.1%

        \[\leadsto x \cdot 0.5 - \color{blue}{z \cdot \left(-y\right)} \]
      9. add-sqr-sqrt17.8%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \]
      10. sqrt-unprod59.1%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \]
      11. sqr-neg59.1%

        \[\leadsto x \cdot 0.5 - z \cdot \sqrt{\color{blue}{y \cdot y}} \]
      12. sqrt-unprod49.5%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
      13. add-sqr-sqrt99.7%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{y} \]
    7. Applied egg-rr99.7%

      \[\leadsto \color{blue}{x \cdot 0.5 - z \cdot y} \]

    if -1e13 < (+.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 0 99.2%

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

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

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

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

Alternative 4: 74.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.6 \cdot 10^{-253} \lor \neg \left(z \leq 1.15 \cdot 10^{-166}\right) \land z \leq 9.8 \cdot 10^{-139}:\\
\;\;\;\;y + y \cdot \log z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 2.6e-253 or 1.14999999999999999e-166 < z < 9.80000000000000063e-139

    1. Initial program 99.7%

      \[x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. distribute-rgt-in99.7%

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

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

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

      \[\leadsto y \cdot \log z + \color{blue}{y} \]

    if 2.6e-253 < z < 1.14999999999999999e-166 or 9.80000000000000063e-139 < z

    1. Initial program 99.9%

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

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

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

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

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right) \cdot z} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-out86.6%

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

        \[\leadsto \color{blue}{x \cdot 0.5 - y \cdot z} \]
      3. add-sqr-sqrt45.5%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot z \]
      4. sqrt-unprod60.1%

        \[\leadsto x \cdot 0.5 - \color{blue}{\sqrt{y \cdot y}} \cdot z \]
      5. sqr-neg60.1%

        \[\leadsto x \cdot 0.5 - \sqrt{\color{blue}{\left(-y\right) \cdot \left(-y\right)}} \cdot z \]
      6. sqrt-unprod21.7%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \cdot z \]
      7. add-sqr-sqrt45.4%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(-y\right)} \cdot z \]
      8. *-commutative45.4%

        \[\leadsto x \cdot 0.5 - \color{blue}{z \cdot \left(-y\right)} \]
      9. add-sqr-sqrt21.7%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \]
      10. sqrt-unprod60.1%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \]
      11. sqr-neg60.1%

        \[\leadsto x \cdot 0.5 - z \cdot \sqrt{\color{blue}{y \cdot y}} \]
      12. sqrt-unprod45.5%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
      13. add-sqr-sqrt86.6%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{y} \]
    7. Applied egg-rr86.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.6 \cdot 10^{-253} \lor \neg \left(z \leq 1.15 \cdot 10^{-166}\right) \land z \leq 9.8 \cdot 10^{-139}:\\ \;\;\;\;y + y \cdot \log z\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+112} \lor \neg \left(y \leq 5.2 \cdot 10^{+32}\right):\\
\;\;\;\;y \cdot \left(\left(\log z + 1\right) - z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.1999999999999998e112 or 5.2000000000000004e32 < y

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.1999999999999998e112 < y < 5.2000000000000004e32

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

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

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

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

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right) \cdot z} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-out87.1%

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

        \[\leadsto \color{blue}{x \cdot 0.5 - y \cdot z} \]
      3. add-sqr-sqrt43.2%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot z \]
      4. sqrt-unprod68.3%

        \[\leadsto x \cdot 0.5 - \color{blue}{\sqrt{y \cdot y}} \cdot z \]
      5. sqr-neg68.3%

        \[\leadsto x \cdot 0.5 - \sqrt{\color{blue}{\left(-y\right) \cdot \left(-y\right)}} \cdot z \]
      6. sqrt-unprod28.8%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \cdot z \]
      7. add-sqr-sqrt59.2%

        \[\leadsto x \cdot 0.5 - \color{blue}{\left(-y\right)} \cdot z \]
      8. *-commutative59.2%

        \[\leadsto x \cdot 0.5 - \color{blue}{z \cdot \left(-y\right)} \]
      9. add-sqr-sqrt28.8%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \]
      10. sqrt-unprod68.3%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \]
      11. sqr-neg68.3%

        \[\leadsto x \cdot 0.5 - z \cdot \sqrt{\color{blue}{y \cdot y}} \]
      12. sqrt-unprod43.2%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
      13. add-sqr-sqrt87.1%

        \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{y} \]
    7. Applied egg-rr87.1%

      \[\leadsto \color{blue}{x \cdot 0.5 - z \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.6%

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

Alternative 6: 99.9% accurate, 1.0× speedup?

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

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

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

Alternative 7: 74.6% accurate, 15.9× speedup?

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

\\
x \cdot 0.5 - y \cdot z
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

    \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y\right) \cdot z} \]
  6. Step-by-step derivation
    1. distribute-lft-neg-out77.8%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(-y \cdot z\right)} \]
    2. unsub-neg77.8%

      \[\leadsto \color{blue}{x \cdot 0.5 - y \cdot z} \]
    3. add-sqr-sqrt41.0%

      \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \cdot z \]
    4. sqrt-unprod55.1%

      \[\leadsto x \cdot 0.5 - \color{blue}{\sqrt{y \cdot y}} \cdot z \]
    5. sqr-neg55.1%

      \[\leadsto x \cdot 0.5 - \sqrt{\color{blue}{\left(-y\right) \cdot \left(-y\right)}} \cdot z \]
    6. sqrt-unprod20.1%

      \[\leadsto x \cdot 0.5 - \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \cdot z \]
    7. add-sqr-sqrt42.4%

      \[\leadsto x \cdot 0.5 - \color{blue}{\left(-y\right)} \cdot z \]
    8. *-commutative42.4%

      \[\leadsto x \cdot 0.5 - \color{blue}{z \cdot \left(-y\right)} \]
    9. add-sqr-sqrt20.1%

      \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{-y} \cdot \sqrt{-y}\right)} \]
    10. sqrt-unprod55.1%

      \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}} \]
    11. sqr-neg55.1%

      \[\leadsto x \cdot 0.5 - z \cdot \sqrt{\color{blue}{y \cdot y}} \]
    12. sqrt-unprod41.0%

      \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{\left(\sqrt{y} \cdot \sqrt{y}\right)} \]
    13. add-sqr-sqrt77.8%

      \[\leadsto x \cdot 0.5 - z \cdot \color{blue}{y} \]
  7. Applied egg-rr77.8%

    \[\leadsto \color{blue}{x \cdot 0.5 - z \cdot y} \]
  8. Final simplification77.8%

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

Alternative 8: 40.3% accurate, 37.0× speedup?

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

\\
x \cdot 0.5
\end{array}
Derivation
  1. Initial program 99.9%

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

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

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

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

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

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

    \[\leadsto x \cdot 0.5 \]
  8. 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 2024191 
(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)))))