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

Percentage Accurate: 99.9% → 99.9%
Time: 13.9s
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.9% accurate, 0.5× speedup?

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

\\
\mathsf{fma}\left(\left(\log z - z\right) + 1, y, x \cdot 0.5\right)
\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. +-lowering-+.f64N/A

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
    9. log-lowering-log.f6499.9%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
  3. Simplified99.9%

    \[\leadsto \color{blue}{x \cdot 0.5 + y \cdot \left(\left(1 + \log z\right) - z\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. +-commutativeN/A

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{+.f64}\left(1, \mathsf{\_.f64}\left(\mathsf{log.f64}\left(z\right), z\right)\right), y, \mathsf{*.f64}\left(x, \frac{1}{2}\right)\right) \]
  6. Applied egg-rr99.9%

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

    \[\leadsto \mathsf{fma}\left(\left(\log z - z\right) + 1, y, x \cdot 0.5\right) \]
  8. Add Preprocessing

Alternative 2: 75.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(\log z + 1\right)\\ \mathbf{if}\;z \leq 2.3 \cdot 10^{-239}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-127}:\\ \;\;\;\;x \cdot \left(0.5 - \frac{z \cdot y}{x}\right)\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-48}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ (log z) 1.0))))
   (if (<= z 2.3e-239)
     t_0
     (if (<= z 4.5e-127)
       (* x (- 0.5 (/ (* z y) x)))
       (if (<= z 3.8e-48) t_0 (- (* x 0.5) (* z y)))))))
double code(double x, double y, double z) {
	double t_0 = y * (log(z) + 1.0);
	double tmp;
	if (z <= 2.3e-239) {
		tmp = t_0;
	} else if (z <= 4.5e-127) {
		tmp = x * (0.5 - ((z * y) / x));
	} else if (z <= 3.8e-48) {
		tmp = t_0;
	} else {
		tmp = (x * 0.5) - (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) :: t_0
    real(8) :: tmp
    t_0 = y * (log(z) + 1.0d0)
    if (z <= 2.3d-239) then
        tmp = t_0
    else if (z <= 4.5d-127) then
        tmp = x * (0.5d0 - ((z * y) / x))
    else if (z <= 3.8d-48) then
        tmp = t_0
    else
        tmp = (x * 0.5d0) - (z * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (Math.log(z) + 1.0);
	double tmp;
	if (z <= 2.3e-239) {
		tmp = t_0;
	} else if (z <= 4.5e-127) {
		tmp = x * (0.5 - ((z * y) / x));
	} else if (z <= 3.8e-48) {
		tmp = t_0;
	} else {
		tmp = (x * 0.5) - (z * y);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (math.log(z) + 1.0)
	tmp = 0
	if z <= 2.3e-239:
		tmp = t_0
	elif z <= 4.5e-127:
		tmp = x * (0.5 - ((z * y) / x))
	elif z <= 3.8e-48:
		tmp = t_0
	else:
		tmp = (x * 0.5) - (z * y)
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(log(z) + 1.0))
	tmp = 0.0
	if (z <= 2.3e-239)
		tmp = t_0;
	elseif (z <= 4.5e-127)
		tmp = Float64(x * Float64(0.5 - Float64(Float64(z * y) / x)));
	elseif (z <= 3.8e-48)
		tmp = t_0;
	else
		tmp = Float64(Float64(x * 0.5) - Float64(z * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (log(z) + 1.0);
	tmp = 0.0;
	if (z <= 2.3e-239)
		tmp = t_0;
	elseif (z <= 4.5e-127)
		tmp = x * (0.5 - ((z * y) / x));
	elseif (z <= 3.8e-48)
		tmp = t_0;
	else
		tmp = (x * 0.5) - (z * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 2.3e-239], t$95$0, If[LessEqual[z, 4.5e-127], N[(x * N[(0.5 - N[(N[(z * y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.8e-48], t$95$0, N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 4.5 \cdot 10^{-127}:\\
\;\;\;\;x \cdot \left(0.5 - \frac{z \cdot y}{x}\right)\\

\mathbf{elif}\;z \leq 3.8 \cdot 10^{-48}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 2.2999999999999999e-239 or 4.4999999999999999e-127 < z < 3.80000000000000002e-48

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.7%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.7%

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \color{blue}{\log z}\right)\right)\right) \]
      3. log-lowering-log.f6499.7%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right)\right)\right) \]
    7. Simplified99.7%

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

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \color{blue}{\log z}\right)\right) \]
      3. log-lowering-log.f6465.2%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right)\right) \]
    10. Simplified65.2%

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

    if 2.2999999999999999e-239 < z < 4.4999999999999999e-127

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.9%

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \left(\mathsf{neg}\left(y \cdot z\right)\right)\right) \]
      2. neg-sub0N/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      4. *-lowering-*.f6464.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{z}\right)\right)\right) \]
    7. Simplified64.0%

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(x, \left(\mathsf{neg}\left(\left(\frac{y \cdot z}{x} + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)\right)\right)\right) \]
      8. metadata-evalN/A

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

        \[\leadsto \mathsf{*.f64}\left(x, \left(\mathsf{neg}\left(\left(\frac{-1}{2} + \frac{y \cdot z}{x}\right)\right)\right)\right) \]
      10. distribute-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(\left(\mathsf{neg}\left(\frac{-1}{2}\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\frac{y \cdot z}{x}\right)\right)}\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(\frac{1}{2} + \left(\mathsf{neg}\left(\color{blue}{\frac{y \cdot z}{x}}\right)\right)\right)\right) \]
      12. unsub-negN/A

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

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{y \cdot z}{x}\right)}\right)\right) \]
      14. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(y \cdot z\right), \color{blue}{x}\right)\right)\right) \]
      15. *-lowering-*.f6464.0%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\mathsf{*.f64}\left(y, z\right), x\right)\right)\right) \]
    10. Simplified64.0%

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

    if 3.80000000000000002e-48 < 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. +-lowering-+.f64N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \left(\mathsf{neg}\left(y \cdot z\right)\right)\right) \]
      2. neg-sub0N/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      4. *-lowering-*.f6492.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{z}\right)\right)\right) \]
    7. Simplified92.9%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(0 - y \cdot z\right)} \]
    8. Step-by-step derivation
      1. sub0-negN/A

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

        \[\leadsto x \cdot \frac{1}{2} - \color{blue}{y \cdot z} \]
      3. +-lft-identityN/A

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

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(y \cdot z\right)}^{3}}{\color{blue}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)}} \]
      5. sqr-powN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(y \cdot z\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(y \cdot z\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      6. pow-prod-downN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(y \cdot z\right) \cdot \left(y \cdot z\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      7. sqr-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(\mathsf{neg}\left(y \cdot z\right)\right) \cdot \left(\mathsf{neg}\left(y \cdot z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      8. sub0-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(0 - y \cdot z\right) \cdot \left(\mathsf{neg}\left(y \cdot z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      9. sub0-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(0 - y \cdot z\right) \cdot \left(0 - y \cdot z\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      10. pow-prod-downN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(0 - y \cdot z\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - y \cdot z\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      11. sqr-powN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(0 - y \cdot z\right)}^{3}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      12. metadata-evalN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{0 + {\left(0 - y \cdot z\right)}^{3}}{\color{blue}{0} \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      13. sub0-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{0 + {\left(\mathsf{neg}\left(y \cdot z\right)\right)}^{3}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      14. cube-negN/A

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

        \[\leadsto x \cdot \frac{1}{2} - \frac{0 - {\left(y \cdot z\right)}^{3}}{\color{blue}{0 \cdot 0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      16. metadata-evalN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{\color{blue}{0} \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      17. mul0-lftN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0\right)} \]
      18. fmm-defN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, \color{blue}{y \cdot z}, \mathsf{neg}\left(0\right)\right)} \]
      19. metadata-evalN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, y \cdot z, 0\right)} \]
      20. mul0-lftN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, y \cdot z, 0 \cdot \left(y \cdot z\right)\right)} \]
    9. Applied egg-rr92.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq 2.3 \cdot 10^{-239}:\\ \;\;\;\;y \cdot \left(\log z + 1\right)\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-127}:\\ \;\;\;\;x \cdot \left(0.5 - \frac{z \cdot y}{x}\right)\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-48}:\\ \;\;\;\;y \cdot \left(\log z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 0.5 - z \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 88.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \log z - z\\
t_1 := y \cdot \left(t\_0 + 1\right)\\
\mathbf{if}\;y \leq -2.35 \cdot 10^{+127}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 6.8 \cdot 10^{+117}:\\
\;\;\;\;x \cdot 0.5 + t\_0 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.35000000000000018e127 or 6.8000000000000002e117 < y

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.9%

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\left(1 + \log z\right) - z\right)}\right) \]
      2. associate--l+N/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \color{blue}{\left(\log z - z\right)}\right)\right) \]
      3. sub-negN/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \left(\log z + -1 \cdot \color{blue}{z}\right)\right)\right) \]
      5. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + 1 \cdot \color{blue}{\left(\log z + -1 \cdot z\right)}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \left(\mathsf{neg}\left(-1\right)\right) \cdot \left(\color{blue}{\log z} + -1 \cdot z\right)\right)\right) \]
      7. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 - \left(\mathsf{neg}\left(\left(\log z + -1 \cdot z\right)\right)\right)\right)\right) \]
      9. --lowering--.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\mathsf{neg}\left(\left(\log z + \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(z\right)\right) + \log z\right)\right)\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\log z\right)\right)}\right)\right)\right) \]
      13. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(z + \left(\mathsf{neg}\left(\color{blue}{\log z}\right)\right)\right)\right)\right) \]
      14. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(z - \color{blue}{\log z}\right)\right)\right) \]
      15. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \mathsf{\_.f64}\left(z, \color{blue}{\log z}\right)\right)\right) \]
      16. log-lowering-log.f6490.9%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \mathsf{\_.f64}\left(z, \mathsf{log.f64}\left(z\right)\right)\right)\right) \]
    7. Simplified90.9%

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

    if -2.35000000000000018e127 < y < 6.8000000000000002e117

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{x \cdot 0.5 + y \cdot \left(\left(1 + \log z\right) - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate--l+N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), y\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\log z, z\right), y\right)\right) \]
      10. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), y\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{log.f64}\left(z\right), z\right), y\right)\right) \]
    6. Applied egg-rr99.9%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(\frac{1}{2} \cdot x\right)}, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{log.f64}\left(z\right), z\right), y\right)\right) \]
    8. Step-by-step derivation
      1. *-lowering-*.f6491.1%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, x\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{log.f64}\left(z\right), z\right)}, y\right)\right) \]
    9. Simplified91.1%

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

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

Alternative 4: 85.5% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.28000000000000003e66 or 6.8000000000000002e117 < y

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.9%

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\left(1 + \log z\right) - z\right)}\right) \]
      2. associate--l+N/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \color{blue}{\left(\log z - z\right)}\right)\right) \]
      3. sub-negN/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \left(\log z + -1 \cdot \color{blue}{z}\right)\right)\right) \]
      5. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + 1 \cdot \color{blue}{\left(\log z + -1 \cdot z\right)}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \left(\mathsf{neg}\left(-1\right)\right) \cdot \left(\color{blue}{\log z} + -1 \cdot z\right)\right)\right) \]
      7. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 - \left(\mathsf{neg}\left(\left(\log z + -1 \cdot z\right)\right)\right)\right)\right) \]
      9. --lowering--.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\mathsf{neg}\left(\left(\log z + \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(z\right)\right) + \log z\right)\right)\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\log z\right)\right)}\right)\right)\right) \]
      13. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(z + \left(\mathsf{neg}\left(\color{blue}{\log z}\right)\right)\right)\right)\right) \]
      14. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(z - \color{blue}{\log z}\right)\right)\right) \]
      15. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \mathsf{\_.f64}\left(z, \color{blue}{\log z}\right)\right)\right) \]
      16. log-lowering-log.f6489.8%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \mathsf{\_.f64}\left(z, \mathsf{log.f64}\left(z\right)\right)\right)\right) \]
    7. Simplified89.8%

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

    if -1.28000000000000003e66 < y < 6.8000000000000002e117

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.9%

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \left(\mathsf{neg}\left(y \cdot z\right)\right)\right) \]
      2. neg-sub0N/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      4. *-lowering-*.f6488.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{z}\right)\right)\right) \]
    7. Simplified88.6%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(0 - y \cdot z\right)} \]
    8. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, z\right), y, \left(x \cdot \frac{1}{2}\right)\right) \]
      9. *-lowering-*.f6488.6%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{\_.f64}\left(0, z\right), y, \mathsf{*.f64}\left(x, \frac{1}{2}\right)\right) \]
    9. Applied egg-rr88.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.28 \cdot 10^{+66}:\\ \;\;\;\;y \cdot \left(\left(\log z - z\right) + 1\right)\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{+117}:\\ \;\;\;\;\mathsf{fma}\left(0 - z, y, x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(\log z - z\right) + 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 85.5% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq 6.8 \cdot 10^{+117}:\\
\;\;\;\;x \cdot 0.5 - z \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.3999999999999999e65 or 6.8000000000000002e117 < y

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.9%

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

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

        \[\leadsto \mathsf{*.f64}\left(y, \color{blue}{\left(\left(1 + \log z\right) - z\right)}\right) \]
      2. associate--l+N/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \color{blue}{\left(\log z - z\right)}\right)\right) \]
      3. sub-negN/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \left(\log z + -1 \cdot \color{blue}{z}\right)\right)\right) \]
      5. *-lft-identityN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + 1 \cdot \color{blue}{\left(\log z + -1 \cdot z\right)}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 + \left(\mathsf{neg}\left(-1\right)\right) \cdot \left(\color{blue}{\log z} + -1 \cdot z\right)\right)\right) \]
      7. cancel-sign-sub-invN/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \left(1 - \left(\mathsf{neg}\left(\left(\log z + -1 \cdot z\right)\right)\right)\right)\right) \]
      9. --lowering--.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\mathsf{neg}\left(\left(\log z + \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(z\right)\right) + \log z\right)\right)\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) + \color{blue}{\left(\mathsf{neg}\left(\log z\right)\right)}\right)\right)\right) \]
      13. remove-double-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(z + \left(\mathsf{neg}\left(\color{blue}{\log z}\right)\right)\right)\right)\right) \]
      14. sub-negN/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \left(z - \color{blue}{\log z}\right)\right)\right) \]
      15. --lowering--.f64N/A

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \mathsf{\_.f64}\left(z, \color{blue}{\log z}\right)\right)\right) \]
      16. log-lowering-log.f6489.8%

        \[\leadsto \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(1, \mathsf{\_.f64}\left(z, \mathsf{log.f64}\left(z\right)\right)\right)\right) \]
    7. Simplified89.8%

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

    if -3.3999999999999999e65 < y < 6.8000000000000002e117

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.9%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.9%

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \left(\mathsf{neg}\left(y \cdot z\right)\right)\right) \]
      2. neg-sub0N/A

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \color{blue}{\left(y \cdot z\right)}\right)\right) \]
      4. *-lowering-*.f6488.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{z}\right)\right)\right) \]
    7. Simplified88.6%

      \[\leadsto x \cdot 0.5 + \color{blue}{\left(0 - y \cdot z\right)} \]
    8. Step-by-step derivation
      1. sub0-negN/A

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

        \[\leadsto x \cdot \frac{1}{2} - \color{blue}{y \cdot z} \]
      3. +-lft-identityN/A

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

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(y \cdot z\right)}^{3}}{\color{blue}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)}} \]
      5. sqr-powN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(y \cdot z\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(y \cdot z\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      6. pow-prod-downN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(y \cdot z\right) \cdot \left(y \cdot z\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      7. sqr-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(\mathsf{neg}\left(y \cdot z\right)\right) \cdot \left(\mathsf{neg}\left(y \cdot z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      8. sub0-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(0 - y \cdot z\right) \cdot \left(\mathsf{neg}\left(y \cdot z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      9. sub0-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(0 - y \cdot z\right) \cdot \left(0 - y \cdot z\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      10. pow-prod-downN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(0 - y \cdot z\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - y \cdot z\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      11. sqr-powN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(0 - y \cdot z\right)}^{3}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      12. metadata-evalN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{0 + {\left(0 - y \cdot z\right)}^{3}}{\color{blue}{0} \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      13. sub0-negN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{0 + {\left(\mathsf{neg}\left(y \cdot z\right)\right)}^{3}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      14. cube-negN/A

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

        \[\leadsto x \cdot \frac{1}{2} - \frac{0 - {\left(y \cdot z\right)}^{3}}{\color{blue}{0 \cdot 0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      16. metadata-evalN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{\color{blue}{0} \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
      17. mul0-lftN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0\right)} \]
      18. fmm-defN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, \color{blue}{y \cdot z}, \mathsf{neg}\left(0\right)\right)} \]
      19. metadata-evalN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, y \cdot z, 0\right)} \]
      20. mul0-lftN/A

        \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, y \cdot z, 0 \cdot \left(y \cdot z\right)\right)} \]
    9. Applied egg-rr88.6%

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

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

Alternative 6: 99.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.8%

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \color{blue}{\log z}\right)\right)\right) \]
      3. log-lowering-log.f6499.3%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right)\right)\right) \]
    7. Simplified99.3%

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

    if 0.0420000000000000026 < 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. +-lowering-+.f64N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{x \cdot 0.5 + y \cdot \left(\left(1 + \log z\right) - z\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate--l+N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), y\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\log z, z\right), y\right)\right) \]
      10. log-lowering-log.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), y\right), \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{log.f64}\left(z\right), z\right), y\right)\right) \]
    6. Applied egg-rr100.0%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(\frac{1}{2} \cdot x\right)}, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{log.f64}\left(z\right), z\right), y\right)\right) \]
    8. Step-by-step derivation
      1. *-lowering-*.f6498.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, x\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{log.f64}\left(z\right), z\right)}, y\right)\right) \]
    9. Simplified98.8%

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

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

Alternative 7: 99.9% accurate, 1.0× speedup?

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

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

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

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

Alternative 8: 60.5% accurate, 11.1× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f6499.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified99.8%

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
    6. Step-by-step derivation
      1. *-lowering-*.f6451.9%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{x}\right) \]
    7. Simplified51.9%

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

    if 9e17 < 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. +-lowering-+.f64N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
      9. log-lowering-log.f64100.0%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \mathsf{neg}\left(y \cdot z\right) \]
      2. neg-sub0N/A

        \[\leadsto 0 - \color{blue}{y \cdot z} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(0, \color{blue}{\left(y \cdot z\right)}\right) \]
      4. *-lowering-*.f6474.4%

        \[\leadsto \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{z}\right)\right) \]
    7. Simplified74.4%

      \[\leadsto \color{blue}{0 - y \cdot z} \]
    8. Step-by-step derivation
      1. sub0-negN/A

        \[\leadsto \mathsf{neg}\left(y \cdot z\right) \]
      2. *-commutativeN/A

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

        \[\leadsto \mathsf{neg.f64}\left(\left(z \cdot y\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{neg.f64}\left(\left(y \cdot z\right)\right) \]
      5. *-lowering-*.f6474.4%

        \[\leadsto \mathsf{neg.f64}\left(\mathsf{*.f64}\left(y, z\right)\right) \]
    9. Applied egg-rr74.4%

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

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

Alternative 9: 75.5% accurate, 15.9× speedup?

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

\\
x \cdot 0.5 - z \cdot 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. +-lowering-+.f64N/A

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
    9. log-lowering-log.f6499.9%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
  3. Simplified99.9%

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \left(\mathsf{neg}\left(y \cdot z\right)\right)\right) \]
    2. neg-sub0N/A

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \color{blue}{\left(y \cdot z\right)}\right)\right) \]
    4. *-lowering-*.f6475.8%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(y, \color{blue}{z}\right)\right)\right) \]
  7. Simplified75.8%

    \[\leadsto x \cdot 0.5 + \color{blue}{\left(0 - y \cdot z\right)} \]
  8. Step-by-step derivation
    1. sub0-negN/A

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

      \[\leadsto x \cdot \frac{1}{2} - \color{blue}{y \cdot z} \]
    3. +-lft-identityN/A

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

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(y \cdot z\right)}^{3}}{\color{blue}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)}} \]
    5. sqr-powN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(y \cdot z\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(y \cdot z\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    6. pow-prod-downN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(y \cdot z\right) \cdot \left(y \cdot z\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    7. sqr-negN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(\mathsf{neg}\left(y \cdot z\right)\right) \cdot \left(\mathsf{neg}\left(y \cdot z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    8. sub0-negN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(0 - y \cdot z\right) \cdot \left(\mathsf{neg}\left(y \cdot z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    9. sub0-negN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(\left(0 - y \cdot z\right) \cdot \left(0 - y \cdot z\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    10. pow-prod-downN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(0 - y \cdot z\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - y \cdot z\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    11. sqr-powN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} + {\left(0 - y \cdot z\right)}^{3}}{0 \cdot \color{blue}{0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    12. metadata-evalN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{0 + {\left(0 - y \cdot z\right)}^{3}}{\color{blue}{0} \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    13. sub0-negN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{0 + {\left(\mathsf{neg}\left(y \cdot z\right)\right)}^{3}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    14. cube-negN/A

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

      \[\leadsto x \cdot \frac{1}{2} - \frac{0 - {\left(y \cdot z\right)}^{3}}{\color{blue}{0 \cdot 0} + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    16. metadata-evalN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{\color{blue}{0} \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0 \cdot \left(y \cdot z\right)\right)} \]
    17. mul0-lftN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \left(\left(y \cdot z\right) \cdot \left(y \cdot z\right) - 0\right)} \]
    18. fmm-defN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, \color{blue}{y \cdot z}, \mathsf{neg}\left(0\right)\right)} \]
    19. metadata-evalN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, y \cdot z, 0\right)} \]
    20. mul0-lftN/A

      \[\leadsto x \cdot \frac{1}{2} - \frac{{0}^{3} - {\left(y \cdot z\right)}^{3}}{0 \cdot 0 + \mathsf{fma}\left(y \cdot z, y \cdot z, 0 \cdot \left(y \cdot z\right)\right)} \]
  9. Applied egg-rr75.8%

    \[\leadsto \color{blue}{x \cdot 0.5 - z \cdot y} \]
  10. Add Preprocessing

Alternative 10: 40.6% accurate, 37.0× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\left(1 + \log z\right), z\right)\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \log z\right), z\right)\right)\right) \]
    9. log-lowering-log.f6499.9%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{*.f64}\left(x, \frac{1}{2}\right), \mathsf{*.f64}\left(y, \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{log.f64}\left(z\right)\right), z\right)\right)\right) \]
  3. Simplified99.9%

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

    \[\leadsto \color{blue}{\frac{1}{2} \cdot x} \]
  6. Step-by-step derivation
    1. *-lowering-*.f6439.6%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{x}\right) \]
  7. Simplified39.6%

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  8. Final simplification39.6%

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