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

Percentage Accurate: 99.9% → 99.7%
Time: 8.4s
Alternatives: 10
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 10 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.7% accurate, 1.0× speedup?

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

\\
x \cdot 0.5 + \left(y \cdot \left(1 + \log z\right) - y \cdot 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. Taylor expanded in z around 0 99.9%

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

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

Alternative 2: 83.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{+58} \lor \neg \left(x \cdot 0.5 \leq -1 \cdot 10^{-19} \lor \neg \left(x \cdot 0.5 \leq -2 \cdot 10^{-75}\right) \land 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+58)
         (not
          (or (<= (* x 0.5) -1e-19)
              (and (not (<= (* x 0.5) -2e-75)) (<= (* 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+58) || !(((x * 0.5) <= -1e-19) || (!((x * 0.5) <= -2e-75) && ((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+58)) .or. (.not. ((x * 0.5d0) <= (-1d-19)) .or. (.not. ((x * 0.5d0) <= (-2d-75))) .and. ((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+58) || !(((x * 0.5) <= -1e-19) || (!((x * 0.5) <= -2e-75) && ((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+58) or not (((x * 0.5) <= -1e-19) or (not ((x * 0.5) <= -2e-75) and ((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+58) || !((Float64(x * 0.5) <= -1e-19) || (!(Float64(x * 0.5) <= -2e-75) && (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+58) || ~((((x * 0.5) <= -1e-19) || (~(((x * 0.5) <= -2e-75)) && ((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+58], N[Not[Or[LessEqual[N[(x * 0.5), $MachinePrecision], -1e-19], And[N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], -2e-75]], $MachinePrecision], 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^{+58} \lor \neg \left(x \cdot 0.5 \leq -1 \cdot 10^{-19} \lor \neg \left(x \cdot 0.5 \leq -2 \cdot 10^{-75}\right) \land 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.99999999999999989e58 or -9.9999999999999998e-20 < (*.f64 x 1/2) < -1.9999999999999999e-75 or 4.9999999999999997e32 < (*.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 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999989e58 < (*.f64 x 1/2) < -9.9999999999999998e-20 or -1.9999999999999999e-75 < (*.f64 x 1/2) < 4.9999999999999997e32

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

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

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

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

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

        \[\leadsto \left(x \cdot 0.5 + y\right) + \color{blue}{\left(0 - \left(z - \log z\right)\right)} \cdot y \]
      8. neg-sub099.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{+58} \lor \neg \left(x \cdot 0.5 \leq -1 \cdot 10^{-19} \lor \neg \left(x \cdot 0.5 \leq -2 \cdot 10^{-75}\right) \land 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: 74.6% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;z \leq 2.5 \cdot 10^{-103}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 8 \cdot 10^{-50}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{-13}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 1.14999999999999994e-211 or 2.49999999999999983e-103 < z < 8.00000000000000006e-50

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.14999999999999994e-211 < z < 2.49999999999999983e-103 or 8.00000000000000006e-50 < z < 1.35000000000000005e-13

    1. Initial program 99.7%

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

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

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

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

    if 1.35000000000000005e-13 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 1.15 \cdot 10^{-211}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-103}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-50}:\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-13}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\ \end{array} \]

Alternative 4: 74.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.6 \cdot 10^{-211} \lor \neg \left(z \leq 8.4 \cdot 10^{-103}\right) \land \left(z \leq 1.02 \cdot 10^{-50} \lor \neg \left(z \leq 5.7 \cdot 10^{-14}\right)\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 4.59999999999999976e-211 or 8.40000000000000019e-103 < z < 1.0199999999999999e-50 or 5.69999999999999969e-14 < z

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.59999999999999976e-211 < z < 8.40000000000000019e-103 or 1.0199999999999999e-50 < z < 5.69999999999999969e-14

    1. Initial program 99.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 4.6 \cdot 10^{-211} \lor \neg \left(z \leq 8.4 \cdot 10^{-103}\right) \land \left(z \leq 1.02 \cdot 10^{-50} \lor \neg \left(z \leq 5.7 \cdot 10^{-14}\right)\right):\\ \;\;\;\;x \cdot 0.5 - y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(1 + \log z\right)\\ \end{array} \]

Alternative 5: 98.8% accurate, 1.0× speedup?

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

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

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


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

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

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

    if 0.00449999999999999966 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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. Final simplification99.9%

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

Alternative 7: 74.9% 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.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 60.8% accurate, 18.3× speedup?

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

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

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


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

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

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

    if 1.02e16 < 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 0 100.0%

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(y \cdot z\right)} \]
    5. Step-by-step derivation
      1. associate-*r*78.7%

        \[\leadsto \color{blue}{\left(-1 \cdot y\right) \cdot z} \]
      2. neg-mul-178.7%

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

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

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

Alternative 9: 40.9% 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 40.5%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  3. Final simplification40.5%

    \[\leadsto x \cdot 0.5 \]

Alternative 10: 1.8% accurate, 111.0× speedup?

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

\\
y
\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-rgt-in99.8%

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

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

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

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

      \[\leadsto \left(x \cdot 0.5 + y\right) + \color{blue}{\left(0 - \left(z - \log z\right)\right)} \cdot y \]
    8. neg-sub099.8%

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 0.5, y\right) - y \cdot \left(z - \log z\right)} \]
  4. Step-by-step derivation
    1. add-sqr-sqrt99.5%

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

      \[\leadsto \mathsf{fma}\left(x, 0.5, y\right) - y \cdot \color{blue}{{\left(\sqrt{z - \log z}\right)}^{2}} \]
  5. Applied egg-rr99.5%

    \[\leadsto \mathsf{fma}\left(x, 0.5, y\right) - y \cdot \color{blue}{{\left(\sqrt{z - \log z}\right)}^{2}} \]
  6. Step-by-step derivation
    1. add-cube-cbrt99.0%

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

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

      \[\leadsto \mathsf{fma}\left(x, 0.5, y\right) - {\left(\sqrt[3]{y \cdot \color{blue}{\left(\sqrt{z - \log z} \cdot \sqrt{z - \log z}\right)}}\right)}^{3} \]
    4. add-sqr-sqrt99.0%

      \[\leadsto \mathsf{fma}\left(x, 0.5, y\right) - {\left(\sqrt[3]{y \cdot \color{blue}{\left(z - \log z\right)}}\right)}^{3} \]
    5. *-commutative99.0%

      \[\leadsto \mathsf{fma}\left(x, 0.5, y\right) - {\left(\sqrt[3]{\color{blue}{\left(z - \log z\right) \cdot y}}\right)}^{3} \]
  7. Applied egg-rr99.0%

    \[\leadsto \mathsf{fma}\left(x, 0.5, y\right) - \color{blue}{{\left(\sqrt[3]{\left(z - \log z\right) \cdot y}\right)}^{3}} \]
  8. Taylor expanded in y around inf 2.0%

    \[\leadsto \color{blue}{y} \]
  9. Final simplification2.0%

    \[\leadsto y \]

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 2023293 
(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)))))