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

Percentage Accurate: 99.9% → 99.9%
Time: 12.4s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.9% accurate, 1.0× speedup?

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

\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}

Alternative 1: 99.9% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 75.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;z \leq 6 \cdot 10^{-104}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(\frac{y}{x}, -z, 0.5\right)\\

\mathbf{elif}\;z \leq 3.2 \cdot 10^{-65}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 2.4e-265 or 6.0000000000000005e-104 < z < 3.1999999999999999e-65

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z - z}, y\right) \]
      11. log-lowering-log.f6469.3

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z}, y\right) \]
    7. Step-by-step derivation
      1. log-lowering-log.f6469.3

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

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

    if 2.4e-265 < z < 6.0000000000000005e-104

    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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \mathsf{fma}\left(\frac{y}{x}, \color{blue}{-z}, 0.5\right) \]
    10. Simplified60.0%

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

    if 3.1999999999999999e-65 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(1 - z, y, \mathsf{fma}\left(y, \log z, \color{blue}{x \cdot 0.5}\right)\right) \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \frac{1}{2} \cdot x\right) \]
      7. *-lowering-*.f6493.2

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

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

Alternative 3: 86.3% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \log z - z\\
\mathbf{if}\;y \leq -8.5 \cdot 10^{+54}:\\
\;\;\;\;y + y \cdot t\_0\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{+58}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, 0.5 \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, t\_0, y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -8.4999999999999995e54

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \log z - z, y\right)} \]
    6. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(\log z - z\right) + y} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{y \cdot \left(\log z - z\right)} + y \]
      3. --lowering--.f64N/A

        \[\leadsto y \cdot \color{blue}{\left(\log z - z\right)} + y \]
      4. log-lowering-log.f6495.3

        \[\leadsto y \cdot \left(\color{blue}{\log z} - z\right) + y \]
    7. Applied egg-rr95.3%

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

    if -8.4999999999999995e54 < y < 1.5000000000000001e58

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \frac{1}{2} \cdot x\right) \]
      7. *-lowering-*.f6487.3

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

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

    if 1.5000000000000001e58 < y

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z - z}, y\right) \]
      11. log-lowering-log.f6487.4

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

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

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

Alternative 4: 86.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(y, \log z - z, y\right)\\
\mathbf{if}\;y \leq -2.6 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.25 \cdot 10^{+58}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, 0.5 \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.60000000000000003e65 or 1.24999999999999996e58 < y

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z - z}, y\right) \]
      11. log-lowering-log.f6490.9

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

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

    if -2.60000000000000003e65 < y < 1.24999999999999996e58

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \frac{1}{2} \cdot x\right) \]
      7. *-lowering-*.f6487.3

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

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

Alternative 5: 98.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.4 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(0.5, x, \mathsf{fma}\left(y, \log z, y\right)\right)\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3999999999999999e-6 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(1 - z, y, \mathsf{fma}\left(y, \log z, \color{blue}{x \cdot 0.5}\right)\right) \]
    4. Applied egg-rr100.0%

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

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

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

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

Alternative 6: 61.0% accurate, 8.6× speedup?

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

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

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


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

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6452.0

        \[\leadsto \color{blue}{0.5 \cdot x} \]
    5. Simplified52.0%

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

    if 3.5000000000000001e32 < z

    1. Initial program 100.0%

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \left(\mathsf{neg}\left(z\right)\right)} \]
      4. neg-lowering-neg.f6471.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 3.5 \cdot 10^{+32}:\\ \;\;\;\;0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;-y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.6% accurate, 8.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, \frac{1}{2} \cdot x\right) \]
    7. *-lowering-*.f6474.5

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

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

Alternative 8: 40.2% accurate, 20.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
  4. Step-by-step derivation
    1. *-lowering-*.f6442.0

      \[\leadsto \color{blue}{0.5 \cdot x} \]
  5. Simplified42.0%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  6. Add Preprocessing

Alternative 9: 1.8% accurate, 120.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. Add Preprocessing
  3. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\log z - z}, y\right) \]
    11. log-lowering-log.f6458.6

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(z\right)}, y\right) \]
    2. neg-lowering-neg.f6433.0

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

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

    \[\leadsto \color{blue}{y} \]
  10. Step-by-step derivation
    1. Simplified2.0%

      \[\leadsto \color{blue}{y} \]
    2. 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 2024198 
    (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)))))