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

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

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

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

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

Alternative 2: 85.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-23} \lor \neg \left(x \cdot 0.5 \leq 10^{-157} \lor \neg \left(x \cdot 0.5 \leq 4 \cdot 10^{-120}\right) \land x \cdot 0.5 \leq 10^{-63}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x 1/2) < -5.0000000000000002e-23 or 9.99999999999999943e-158 < (*.f64 x 1/2) < 3.99999999999999991e-120 or 1.00000000000000007e-63 < (*.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 85.5%

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

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

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

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

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

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

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

    if -5.0000000000000002e-23 < (*.f64 x 1/2) < 9.99999999999999943e-158 or 3.99999999999999991e-120 < (*.f64 x 1/2) < 1.00000000000000007e-63

    1. Initial program 99.9%

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

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

        \[\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 90.1%

      \[\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-neg90.1%

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

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

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

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

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

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

        \[\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-neg90.1%

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \left(-\left(-1 + \left(z - \log z\right)\right)\right)} \]
    7. Step-by-step derivation
      1. distribute-neg-in90.1%

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

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

        \[\leadsto y \cdot \color{blue}{\left(1 - \left(z - \log z\right)\right)} \]
      4. associate-+l-90.1%

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

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

      \[\leadsto \color{blue}{y \cdot \left(1 - z\right) + y \cdot \log z} \]
    9. Step-by-step derivation
      1. distribute-lft-out90.1%

        \[\leadsto \color{blue}{y \cdot \left(\left(1 - z\right) + \log z\right)} \]
      2. *-commutative90.1%

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

        \[\leadsto \color{blue}{\left(\log z + \left(1 - z\right)\right)} \cdot y \]
    10. Applied egg-rr90.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-23} \lor \neg \left(x \cdot 0.5 \leq 10^{-157} \lor \neg \left(x \cdot 0.5 \leq 4 \cdot 10^{-120}\right) \land x \cdot 0.5 \leq 10^{-63}\right):\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(1 - z\right) + \log z\right)\\ \end{array} \]

Alternative 3: 98.6% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 4.40000000000000016e-4

    1. Initial program 99.8%

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

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

    if 4.40000000000000016e-4 < 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 97.8%

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

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

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

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

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

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

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

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

Alternative 4: 74.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+198}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.5000000000000001e198

    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.5%

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

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

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

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

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

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

      \[\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 94.2%

      \[\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-neg94.2%

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

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

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

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

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

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

        \[\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-neg94.2%

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

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

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

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

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

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

    if -8.5000000000000001e198 < y

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

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

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

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

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

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

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

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

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

Alternative 5: 60.9% accurate, 10.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 50000000 \lor \neg \left(z \leq 4.2 \cdot 10^{+41}\right) \land z \leq 1.5 \cdot 10^{+58}:\\
\;\;\;\;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 < 5e7 or 4.1999999999999999e41 < z < 1.5000000000000001e58

    1. Initial program 99.9%

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

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

        \[\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 inf 51.9%

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

    if 5e7 < z < 4.1999999999999999e41 or 1.5000000000000001e58 < 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 80.1%

      \[\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-neg80.1%

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

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

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

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

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

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

        \[\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-neg80.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 50000000 \lor \neg \left(z \leq 4.2 \cdot 10^{+41}\right) \land z \leq 1.5 \cdot 10^{+58}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \end{array} \]

Alternative 6: 75.7% 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 72.5%

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

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

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

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

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

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

    \[\leadsto \color{blue}{x \cdot 0.5 - y \cdot z} \]
  7. Final simplification72.5%

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

Alternative 7: 39.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. Step-by-step derivation
    1. sub-neg99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  5. Final simplification39.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 2023230 
(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)))))