Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2

Percentage Accurate: 84.0% → 96.9%
Time: 10.6s
Alternatives: 7
Speedup: 1.0×

Specification

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

\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 84.0% accurate, 1.0× speedup?

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

\\
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\end{array}

Alternative 1: 96.9% accurate, 1.0× speedup?

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

\\
\frac{\frac{y}{z} \cdot \frac{x}{z}}{z + 1}
\end{array}
Derivation
  1. Initial program 85.8%

    \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
  2. Step-by-step derivation
    1. associate-/r*86.9%

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}} \]
  3. Simplified86.9%

    \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}} \]
  4. Step-by-step derivation
    1. *-commutative86.9%

      \[\leadsto \frac{\frac{\color{blue}{y \cdot x}}{z \cdot z}}{z + 1} \]
    2. times-frac97.6%

      \[\leadsto \frac{\color{blue}{\frac{y}{z} \cdot \frac{x}{z}}}{z + 1} \]
  5. Applied egg-rr97.6%

    \[\leadsto \frac{\color{blue}{\frac{y}{z} \cdot \frac{x}{z}}}{z + 1} \]
  6. Final simplification97.6%

    \[\leadsto \frac{\frac{y}{z} \cdot \frac{x}{z}}{z + 1} \]

Alternative 2: 90.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z + 1\right) \cdot \left(z \cdot z\right)\\ \mathbf{if}\;t_0 \leq -20000000 \lor \neg \left(t_0 \leq 5 \cdot 10^{-117}\right):\\ \;\;\;\;\frac{y \cdot x}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (+ z 1.0) (* z z))))
   (if (or (<= t_0 -20000000.0) (not (<= t_0 5e-117)))
     (/ (* y x) t_0)
     (/ (/ x z) (/ z y)))))
double code(double x, double y, double z) {
	double t_0 = (z + 1.0) * (z * z);
	double tmp;
	if ((t_0 <= -20000000.0) || !(t_0 <= 5e-117)) {
		tmp = (y * x) / t_0;
	} else {
		tmp = (x / 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) :: t_0
    real(8) :: tmp
    t_0 = (z + 1.0d0) * (z * z)
    if ((t_0 <= (-20000000.0d0)) .or. (.not. (t_0 <= 5d-117))) then
        tmp = (y * x) / t_0
    else
        tmp = (x / z) / (z / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (z + 1.0) * (z * z);
	double tmp;
	if ((t_0 <= -20000000.0) || !(t_0 <= 5e-117)) {
		tmp = (y * x) / t_0;
	} else {
		tmp = (x / z) / (z / y);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (z + 1.0) * (z * z)
	tmp = 0
	if (t_0 <= -20000000.0) or not (t_0 <= 5e-117):
		tmp = (y * x) / t_0
	else:
		tmp = (x / z) / (z / y)
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(z + 1.0) * Float64(z * z))
	tmp = 0.0
	if ((t_0 <= -20000000.0) || !(t_0 <= 5e-117))
		tmp = Float64(Float64(y * x) / t_0);
	else
		tmp = Float64(Float64(x / z) / Float64(z / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (z + 1.0) * (z * z);
	tmp = 0.0;
	if ((t_0 <= -20000000.0) || ~((t_0 <= 5e-117)))
		tmp = (y * x) / t_0;
	else
		tmp = (x / z) / (z / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z + 1.0), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -20000000.0], N[Not[LessEqual[t$95$0, 5e-117]], $MachinePrecision]], N[(N[(y * x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(x / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(z + 1\right) \cdot \left(z \cdot z\right)\\
\mathbf{if}\;t_0 \leq -20000000 \lor \neg \left(t_0 \leq 5 \cdot 10^{-117}\right):\\
\;\;\;\;\frac{y \cdot x}{t_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 z z) (+.f64 z 1)) < -2e7 or 5e-117 < (*.f64 (*.f64 z z) (+.f64 z 1))

    1. Initial program 89.7%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]

    if -2e7 < (*.f64 (*.f64 z z) (+.f64 z 1)) < 5e-117

    1. Initial program 80.3%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*l*80.3%

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

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

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

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

        \[\leadsto \frac{y}{\frac{\color{blue}{\left(z + 1\right) \cdot z}}{\frac{x}{z}}} \]
      6. distribute-lft1-in90.5%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z + z}}{\frac{x}{z}}} \]
      7. fma-def90.5%

        \[\leadsto \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, z\right)}}{\frac{x}{z}}} \]
    3. Simplified90.5%

      \[\leadsto \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(z, z, z\right)}{\frac{x}{z}}}} \]
    4. Taylor expanded in z around 0 82.1%

      \[\leadsto \frac{y}{\color{blue}{\frac{{z}^{2}}{x}}} \]
    5. Step-by-step derivation
      1. unpow282.1%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z}}{x}} \]
      2. associate-*r/90.4%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    6. Simplified90.4%

      \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    7. Step-by-step derivation
      1. associate-/l/97.9%

        \[\leadsto \color{blue}{\frac{\frac{y}{\frac{z}{x}}}{z}} \]
      2. un-div-inv97.9%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{1}{\frac{z}{x}}}}{z} \]
      3. clear-num97.9%

        \[\leadsto \frac{y \cdot \color{blue}{\frac{x}{z}}}{z} \]
      4. div-inv97.8%

        \[\leadsto \color{blue}{\left(y \cdot \frac{x}{z}\right) \cdot \frac{1}{z}} \]
      5. associate-*r/89.7%

        \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \cdot \frac{1}{z} \]
    8. Applied egg-rr89.7%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z} \cdot \frac{1}{z}} \]
    9. Step-by-step derivation
      1. *-commutative89.7%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \cdot \frac{1}{z} \]
      2. associate-/l*97.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \cdot \frac{1}{z} \]
      3. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{1}{z}}{\frac{z}{y}}} \]
      4. div-inv99.9%

        \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{z}{y}} \]
    10. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{\frac{z}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification93.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(z + 1\right) \cdot \left(z \cdot z\right) \leq -20000000 \lor \neg \left(\left(z + 1\right) \cdot \left(z \cdot z\right) \leq 5 \cdot 10^{-117}\right):\\ \;\;\;\;\frac{y \cdot x}{\left(z + 1\right) \cdot \left(z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\ \end{array} \]

Alternative 3: 92.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z + 1\right) \cdot \left(z \cdot z\right)\\ \mathbf{if}\;t_0 \leq -20000000:\\ \;\;\;\;\frac{y \cdot \frac{x}{z \cdot z}}{z + 1}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{-117}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{t_0}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (+ z 1.0) (* z z))))
   (if (<= t_0 -20000000.0)
     (/ (* y (/ x (* z z))) (+ z 1.0))
     (if (<= t_0 5e-117) (/ (/ x z) (/ z y)) (/ (* y x) t_0)))))
double code(double x, double y, double z) {
	double t_0 = (z + 1.0) * (z * z);
	double tmp;
	if (t_0 <= -20000000.0) {
		tmp = (y * (x / (z * z))) / (z + 1.0);
	} else if (t_0 <= 5e-117) {
		tmp = (x / z) / (z / y);
	} else {
		tmp = (y * x) / 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 = (z + 1.0d0) * (z * z)
    if (t_0 <= (-20000000.0d0)) then
        tmp = (y * (x / (z * z))) / (z + 1.0d0)
    else if (t_0 <= 5d-117) then
        tmp = (x / z) / (z / y)
    else
        tmp = (y * x) / t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (z + 1.0) * (z * z);
	double tmp;
	if (t_0 <= -20000000.0) {
		tmp = (y * (x / (z * z))) / (z + 1.0);
	} else if (t_0 <= 5e-117) {
		tmp = (x / z) / (z / y);
	} else {
		tmp = (y * x) / t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (z + 1.0) * (z * z)
	tmp = 0
	if t_0 <= -20000000.0:
		tmp = (y * (x / (z * z))) / (z + 1.0)
	elif t_0 <= 5e-117:
		tmp = (x / z) / (z / y)
	else:
		tmp = (y * x) / t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(z + 1.0) * Float64(z * z))
	tmp = 0.0
	if (t_0 <= -20000000.0)
		tmp = Float64(Float64(y * Float64(x / Float64(z * z))) / Float64(z + 1.0));
	elseif (t_0 <= 5e-117)
		tmp = Float64(Float64(x / z) / Float64(z / y));
	else
		tmp = Float64(Float64(y * x) / t_0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (z + 1.0) * (z * z);
	tmp = 0.0;
	if (t_0 <= -20000000.0)
		tmp = (y * (x / (z * z))) / (z + 1.0);
	elseif (t_0 <= 5e-117)
		tmp = (x / z) / (z / y);
	else
		tmp = (y * x) / t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z + 1.0), $MachinePrecision] * N[(z * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20000000.0], N[(N[(y * N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-117], N[(N[(x / z), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(z + 1\right) \cdot \left(z \cdot z\right)\\
\mathbf{if}\;t_0 \leq -20000000:\\
\;\;\;\;\frac{y \cdot \frac{x}{z \cdot z}}{z + 1}\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{-117}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 z z) (+.f64 z 1)) < -2e7

    1. Initial program 84.0%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-/r*85.9%

        \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}} \]
    3. Simplified85.9%

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}} \]
    4. Step-by-step derivation
      1. associate-*l/94.7%

        \[\leadsto \frac{\color{blue}{\frac{x}{z \cdot z} \cdot y}}{z + 1} \]
    5. Applied egg-rr94.7%

      \[\leadsto \frac{\color{blue}{\frac{x}{z \cdot z} \cdot y}}{z + 1} \]

    if -2e7 < (*.f64 (*.f64 z z) (+.f64 z 1)) < 5e-117

    1. Initial program 80.3%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*l*80.3%

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

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

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

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

        \[\leadsto \frac{y}{\frac{\color{blue}{\left(z + 1\right) \cdot z}}{\frac{x}{z}}} \]
      6. distribute-lft1-in90.5%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z + z}}{\frac{x}{z}}} \]
      7. fma-def90.5%

        \[\leadsto \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, z\right)}}{\frac{x}{z}}} \]
    3. Simplified90.5%

      \[\leadsto \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(z, z, z\right)}{\frac{x}{z}}}} \]
    4. Taylor expanded in z around 0 82.1%

      \[\leadsto \frac{y}{\color{blue}{\frac{{z}^{2}}{x}}} \]
    5. Step-by-step derivation
      1. unpow282.1%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z}}{x}} \]
      2. associate-*r/90.4%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    6. Simplified90.4%

      \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    7. Step-by-step derivation
      1. associate-/l/97.9%

        \[\leadsto \color{blue}{\frac{\frac{y}{\frac{z}{x}}}{z}} \]
      2. un-div-inv97.9%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{1}{\frac{z}{x}}}}{z} \]
      3. clear-num97.9%

        \[\leadsto \frac{y \cdot \color{blue}{\frac{x}{z}}}{z} \]
      4. div-inv97.8%

        \[\leadsto \color{blue}{\left(y \cdot \frac{x}{z}\right) \cdot \frac{1}{z}} \]
      5. associate-*r/89.7%

        \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \cdot \frac{1}{z} \]
    8. Applied egg-rr89.7%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z} \cdot \frac{1}{z}} \]
    9. Step-by-step derivation
      1. *-commutative89.7%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \cdot \frac{1}{z} \]
      2. associate-/l*97.8%

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \cdot \frac{1}{z} \]
      3. associate-*l/99.9%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{1}{z}}{\frac{z}{y}}} \]
      4. div-inv99.9%

        \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{z}{y}} \]
    10. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{\frac{z}{y}}} \]

    if 5e-117 < (*.f64 (*.f64 z z) (+.f64 z 1))

    1. Initial program 93.8%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification96.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(z + 1\right) \cdot \left(z \cdot z\right) \leq -20000000:\\ \;\;\;\;\frac{y \cdot \frac{x}{z \cdot z}}{z + 1}\\ \mathbf{elif}\;\left(z + 1\right) \cdot \left(z \cdot z\right) \leq 5 \cdot 10^{-117}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{\left(z + 1\right) \cdot \left(z \cdot z\right)}\\ \end{array} \]

Alternative 4: 77.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -1 \cdot 10^{-9}:\\
\;\;\;\;\frac{-x}{\left(z \cdot z\right) \cdot \frac{-1}{y}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.00000000000000006e-9

    1. Initial program 87.1%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*l*87.1%

        \[\leadsto \frac{x \cdot y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
      2. times-frac92.1%

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

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

        \[\leadsto \color{blue}{\frac{y}{\frac{z \cdot \left(z + 1\right)}{\frac{x}{z}}}} \]
      5. *-commutative91.6%

        \[\leadsto \frac{y}{\frac{\color{blue}{\left(z + 1\right) \cdot z}}{\frac{x}{z}}} \]
      6. distribute-lft1-in91.6%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z + z}}{\frac{x}{z}}} \]
      7. fma-def91.6%

        \[\leadsto \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, z\right)}}{\frac{x}{z}}} \]
    3. Simplified91.6%

      \[\leadsto \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(z, z, z\right)}{\frac{x}{z}}}} \]
    4. Taylor expanded in z around 0 63.2%

      \[\leadsto \frac{y}{\color{blue}{\frac{{z}^{2}}{x}}} \]
    5. Step-by-step derivation
      1. unpow263.2%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z}}{x}} \]
      2. associate-*r/53.5%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    6. Simplified53.5%

      \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    7. Step-by-step derivation
      1. associate-/l/49.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{\frac{z}{x}}}{z}} \]
      2. un-div-inv48.6%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{1}{\frac{z}{x}}}}{z} \]
      3. clear-num48.6%

        \[\leadsto \frac{y \cdot \color{blue}{\frac{x}{z}}}{z} \]
      4. div-inv48.5%

        \[\leadsto \color{blue}{\left(y \cdot \frac{x}{z}\right) \cdot \frac{1}{z}} \]
      5. associate-*r/51.1%

        \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \cdot \frac{1}{z} \]
    8. Applied egg-rr51.1%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z} \cdot \frac{1}{z}} \]
    9. Step-by-step derivation
      1. *-commutative51.1%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \cdot \frac{1}{z} \]
      2. associate-/l*52.1%

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \cdot \frac{1}{z} \]
      3. associate-*l/49.5%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{1}{z}}{\frac{z}{y}}} \]
      4. div-inv49.5%

        \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{z}{y}} \]
      5. frac-2neg49.5%

        \[\leadsto \frac{\color{blue}{\frac{-x}{-z}}}{\frac{z}{y}} \]
      6. div-inv49.5%

        \[\leadsto \frac{\color{blue}{\left(-x\right) \cdot \frac{1}{-z}}}{\frac{z}{y}} \]
      7. associate-/l*64.4%

        \[\leadsto \color{blue}{\frac{-x}{\frac{\frac{z}{y}}{\frac{1}{-z}}}} \]
      8. neg-mul-164.4%

        \[\leadsto \frac{-x}{\frac{\frac{z}{y}}{\frac{1}{\color{blue}{-1 \cdot z}}}} \]
      9. metadata-eval64.4%

        \[\leadsto \frac{-x}{\frac{\frac{z}{y}}{\frac{1}{\color{blue}{\left(-1\right)} \cdot z}}} \]
      10. associate-/r*64.4%

        \[\leadsto \frac{-x}{\frac{\frac{z}{y}}{\color{blue}{\frac{\frac{1}{-1}}{z}}}} \]
      11. metadata-eval64.4%

        \[\leadsto \frac{-x}{\frac{\frac{z}{y}}{\frac{\frac{1}{\color{blue}{-1}}}{z}}} \]
      12. metadata-eval64.4%

        \[\leadsto \frac{-x}{\frac{\frac{z}{y}}{\frac{\color{blue}{-1}}{z}}} \]
    10. Applied egg-rr64.4%

      \[\leadsto \color{blue}{\frac{-x}{\frac{\frac{z}{y}}{\frac{-1}{z}}}} \]
    11. Step-by-step derivation
      1. clear-num64.4%

        \[\leadsto \frac{-x}{\frac{\color{blue}{\frac{1}{\frac{y}{z}}}}{\frac{-1}{z}}} \]
      2. associate-/l/64.4%

        \[\leadsto \frac{-x}{\color{blue}{\frac{1}{\frac{-1}{z} \cdot \frac{y}{z}}}} \]
      3. associate-/r*64.4%

        \[\leadsto \frac{-x}{\color{blue}{\frac{\frac{1}{\frac{-1}{z}}}{\frac{y}{z}}}} \]
      4. associate-/r/64.4%

        \[\leadsto \frac{-x}{\frac{\color{blue}{\frac{1}{-1} \cdot z}}{\frac{y}{z}}} \]
      5. metadata-eval64.4%

        \[\leadsto \frac{-x}{\frac{\color{blue}{-1} \cdot z}{\frac{y}{z}}} \]
      6. div-inv64.4%

        \[\leadsto \frac{-x}{\frac{-1 \cdot z}{\color{blue}{y \cdot \frac{1}{z}}}} \]
      7. times-frac68.3%

        \[\leadsto \frac{-x}{\color{blue}{\frac{-1}{y} \cdot \frac{z}{\frac{1}{z}}}} \]
      8. associate-/r/68.3%

        \[\leadsto \frac{-x}{\frac{-1}{y} \cdot \color{blue}{\left(\frac{z}{1} \cdot z\right)}} \]
      9. /-rgt-identity68.3%

        \[\leadsto \frac{-x}{\frac{-1}{y} \cdot \left(\color{blue}{z} \cdot z\right)} \]
    12. Applied egg-rr68.3%

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

    if -1.00000000000000006e-9 < (*.f64 x y)

    1. Initial program 85.3%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*l*85.3%

        \[\leadsto \frac{x \cdot y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
      2. times-frac97.9%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \frac{y}{z \cdot \left(z + 1\right)}} \]
      3. *-commutative97.9%

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

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

        \[\leadsto \frac{y}{\frac{\color{blue}{\left(z + 1\right) \cdot z}}{\frac{x}{z}}} \]
      6. distribute-lft1-in92.1%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z + z}}{\frac{x}{z}}} \]
      7. fma-def92.1%

        \[\leadsto \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, z\right)}}{\frac{x}{z}}} \]
    3. Simplified92.1%

      \[\leadsto \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(z, z, z\right)}{\frac{x}{z}}}} \]
    4. Taylor expanded in z around 0 75.5%

      \[\leadsto \frac{y}{\color{blue}{\frac{{z}^{2}}{x}}} \]
    5. Step-by-step derivation
      1. unpow275.5%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z}}{x}} \]
      2. associate-*r/80.0%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    6. Simplified80.0%

      \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    7. Step-by-step derivation
      1. associate-/l/83.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{\frac{z}{x}}}{z}} \]
      2. un-div-inv83.8%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{1}{\frac{z}{x}}}}{z} \]
      3. clear-num83.8%

        \[\leadsto \frac{y \cdot \color{blue}{\frac{x}{z}}}{z} \]
      4. div-inv83.8%

        \[\leadsto \color{blue}{\left(y \cdot \frac{x}{z}\right) \cdot \frac{1}{z}} \]
      5. associate-*r/78.6%

        \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \cdot \frac{1}{z} \]
    8. Applied egg-rr78.6%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z} \cdot \frac{1}{z}} \]
    9. Step-by-step derivation
      1. *-commutative78.6%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \cdot \frac{1}{z} \]
      2. associate-/l*83.6%

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \cdot \frac{1}{z} \]
      3. associate-*l/85.3%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{1}{z}}{\frac{z}{y}}} \]
      4. div-inv85.3%

        \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{z}{y}} \]
    10. Applied egg-rr85.3%

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{\frac{z}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.7%

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

Alternative 5: 76.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \cdot x \leq -2 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \frac{y}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= (* y x) -2e-14) (* x (/ y (* z z))) (* (/ y z) (/ x z))))
double code(double x, double y, double z) {
	double tmp;
	if ((y * x) <= -2e-14) {
		tmp = x * (y / (z * z));
	} else {
		tmp = (y / z) * (x / z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y * x) <= (-2d-14)) then
        tmp = x * (y / (z * z))
    else
        tmp = (y / z) * (x / z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y * x) <= -2e-14) {
		tmp = x * (y / (z * z));
	} else {
		tmp = (y / z) * (x / z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y * x) <= -2e-14:
		tmp = x * (y / (z * z))
	else:
		tmp = (y / z) * (x / z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (Float64(y * x) <= -2e-14)
		tmp = Float64(x * Float64(y / Float64(z * z)));
	else
		tmp = Float64(Float64(y / z) * Float64(x / z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y * x) <= -2e-14)
		tmp = x * (y / (z * z));
	else
		tmp = (y / z) * (x / z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[N[(y * x), $MachinePrecision], -2e-14], N[(x * N[(y / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -2 \cdot 10^{-14}:\\
\;\;\;\;x \cdot \frac{y}{z \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -2e-14

    1. Initial program 87.3%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*r/90.2%

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

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
      3. associate-/r*93.0%

        \[\leadsto x \cdot \color{blue}{\frac{\frac{y}{z}}{z \cdot \left(z + 1\right)}} \]
      4. *-commutative93.0%

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

        \[\leadsto x \cdot \frac{\frac{y}{z}}{\color{blue}{z \cdot z + z}} \]
      6. fma-def93.0%

        \[\leadsto x \cdot \frac{\frac{y}{z}}{\color{blue}{\mathsf{fma}\left(z, z, z\right)}} \]
    3. Simplified93.0%

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

      \[\leadsto x \cdot \color{blue}{\frac{y}{{z}^{2}}} \]
    5. Step-by-step derivation
      1. unpow268.9%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z}} \]
    6. Simplified68.9%

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

    if -2e-14 < (*.f64 x y)

    1. Initial program 85.2%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*l*85.2%

        \[\leadsto \frac{x \cdot y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
      2. times-frac97.9%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \frac{y}{z \cdot \left(z + 1\right)}} \]
      3. *-commutative97.9%

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

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

        \[\leadsto \frac{y}{\frac{\color{blue}{\left(z + 1\right) \cdot z}}{\frac{x}{z}}} \]
      6. distribute-lft1-in92.0%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z + z}}{\frac{x}{z}}} \]
      7. fma-def92.0%

        \[\leadsto \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, z\right)}}{\frac{x}{z}}} \]
    3. Simplified92.0%

      \[\leadsto \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(z, z, z\right)}{\frac{x}{z}}}} \]
    4. Taylor expanded in z around 0 75.4%

      \[\leadsto \frac{y}{\color{blue}{\frac{{z}^{2}}{x}}} \]
    5. Step-by-step derivation
      1. unpow275.4%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z}}{x}} \]
      2. associate-*r/79.9%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    6. Simplified79.9%

      \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    7. Step-by-step derivation
      1. associate-*r/75.4%

        \[\leadsto \frac{y}{\color{blue}{\frac{z \cdot z}{x}}} \]
      2. associate-/l*73.6%

        \[\leadsto \color{blue}{\frac{y \cdot x}{z \cdot z}} \]
      3. frac-times85.2%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{x}{z}} \]
    8. Applied egg-rr85.2%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot \frac{x}{z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot x \leq -2 \cdot 10^{-14}:\\ \;\;\;\;x \cdot \frac{y}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{z}\\ \end{array} \]

Alternative 6: 77.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -1 \cdot 10^{-9}:\\
\;\;\;\;x \cdot \frac{y}{z \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.00000000000000006e-9

    1. Initial program 87.1%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*r/90.0%

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

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
      3. associate-/r*92.9%

        \[\leadsto x \cdot \color{blue}{\frac{\frac{y}{z}}{z \cdot \left(z + 1\right)}} \]
      4. *-commutative92.9%

        \[\leadsto x \cdot \frac{\frac{y}{z}}{\color{blue}{\left(z + 1\right) \cdot z}} \]
      5. distribute-lft1-in92.9%

        \[\leadsto x \cdot \frac{\frac{y}{z}}{\color{blue}{z \cdot z + z}} \]
      6. fma-def92.9%

        \[\leadsto x \cdot \frac{\frac{y}{z}}{\color{blue}{\mathsf{fma}\left(z, z, z\right)}} \]
    3. Simplified92.9%

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

      \[\leadsto x \cdot \color{blue}{\frac{y}{{z}^{2}}} \]
    5. Step-by-step derivation
      1. unpow268.5%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z}} \]
    6. Simplified68.5%

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

    if -1.00000000000000006e-9 < (*.f64 x y)

    1. Initial program 85.3%

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Step-by-step derivation
      1. associate-*l*85.3%

        \[\leadsto \frac{x \cdot y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
      2. times-frac97.9%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \frac{y}{z \cdot \left(z + 1\right)}} \]
      3. *-commutative97.9%

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

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

        \[\leadsto \frac{y}{\frac{\color{blue}{\left(z + 1\right) \cdot z}}{\frac{x}{z}}} \]
      6. distribute-lft1-in92.1%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z + z}}{\frac{x}{z}}} \]
      7. fma-def92.1%

        \[\leadsto \frac{y}{\frac{\color{blue}{\mathsf{fma}\left(z, z, z\right)}}{\frac{x}{z}}} \]
    3. Simplified92.1%

      \[\leadsto \color{blue}{\frac{y}{\frac{\mathsf{fma}\left(z, z, z\right)}{\frac{x}{z}}}} \]
    4. Taylor expanded in z around 0 75.5%

      \[\leadsto \frac{y}{\color{blue}{\frac{{z}^{2}}{x}}} \]
    5. Step-by-step derivation
      1. unpow275.5%

        \[\leadsto \frac{y}{\frac{\color{blue}{z \cdot z}}{x}} \]
      2. associate-*r/80.0%

        \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    6. Simplified80.0%

      \[\leadsto \frac{y}{\color{blue}{z \cdot \frac{z}{x}}} \]
    7. Step-by-step derivation
      1. associate-/l/83.8%

        \[\leadsto \color{blue}{\frac{\frac{y}{\frac{z}{x}}}{z}} \]
      2. un-div-inv83.8%

        \[\leadsto \frac{\color{blue}{y \cdot \frac{1}{\frac{z}{x}}}}{z} \]
      3. clear-num83.8%

        \[\leadsto \frac{y \cdot \color{blue}{\frac{x}{z}}}{z} \]
      4. div-inv83.8%

        \[\leadsto \color{blue}{\left(y \cdot \frac{x}{z}\right) \cdot \frac{1}{z}} \]
      5. associate-*r/78.6%

        \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \cdot \frac{1}{z} \]
    8. Applied egg-rr78.6%

      \[\leadsto \color{blue}{\frac{y \cdot x}{z} \cdot \frac{1}{z}} \]
    9. Step-by-step derivation
      1. *-commutative78.6%

        \[\leadsto \frac{\color{blue}{x \cdot y}}{z} \cdot \frac{1}{z} \]
      2. associate-/l*83.6%

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} \cdot \frac{1}{z} \]
      3. associate-*l/85.3%

        \[\leadsto \color{blue}{\frac{x \cdot \frac{1}{z}}{\frac{z}{y}}} \]
      4. div-inv85.3%

        \[\leadsto \frac{\color{blue}{\frac{x}{z}}}{\frac{z}{y}} \]
    10. Applied egg-rr85.3%

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{\frac{z}{y}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot x \leq -1 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \frac{y}{z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z}{y}}\\ \end{array} \]

Alternative 7: 73.1% accurate, 1.6× speedup?

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

\\
x \cdot \frac{y}{z \cdot z}
\end{array}
Derivation
  1. Initial program 85.8%

    \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
  2. Step-by-step derivation
    1. associate-*r/87.8%

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

      \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot \left(z \cdot \left(z + 1\right)\right)}} \]
    3. associate-/r*94.0%

      \[\leadsto x \cdot \color{blue}{\frac{\frac{y}{z}}{z \cdot \left(z + 1\right)}} \]
    4. *-commutative94.0%

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

      \[\leadsto x \cdot \frac{\frac{y}{z}}{\color{blue}{z \cdot z + z}} \]
    6. fma-def94.0%

      \[\leadsto x \cdot \frac{\frac{y}{z}}{\color{blue}{\mathsf{fma}\left(z, z, z\right)}} \]
  3. Simplified94.0%

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

    \[\leadsto x \cdot \color{blue}{\frac{y}{{z}^{2}}} \]
  5. Step-by-step derivation
    1. unpow274.3%

      \[\leadsto x \cdot \frac{y}{\color{blue}{z \cdot z}} \]
  6. Simplified74.3%

    \[\leadsto x \cdot \color{blue}{\frac{y}{z \cdot z}} \]
  7. Final simplification74.3%

    \[\leadsto x \cdot \frac{y}{z \cdot z} \]

Developer target: 95.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z < 249.6182814532307:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (< z 249.6182814532307)
   (/ (* y (/ x z)) (+ z (* z z)))
   (/ (* (/ (/ y z) (+ 1.0 z)) x) z)))
double code(double x, double y, double z) {
	double tmp;
	if (z < 249.6182814532307) {
		tmp = (y * (x / z)) / (z + (z * z));
	} else {
		tmp = (((y / z) / (1.0 + z)) * x) / z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z < 249.6182814532307d0) then
        tmp = (y * (x / z)) / (z + (z * z))
    else
        tmp = (((y / z) / (1.0d0 + z)) * x) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z < 249.6182814532307) {
		tmp = (y * (x / z)) / (z + (z * z));
	} else {
		tmp = (((y / z) / (1.0 + z)) * x) / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z < 249.6182814532307:
		tmp = (y * (x / z)) / (z + (z * z))
	else:
		tmp = (((y / z) / (1.0 + z)) * x) / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z < 249.6182814532307)
		tmp = Float64(Float64(y * Float64(x / z)) / Float64(z + Float64(z * z)));
	else
		tmp = Float64(Float64(Float64(Float64(y / z) / Float64(1.0 + z)) * x) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z < 249.6182814532307)
		tmp = (y * (x / z)) / (z + (z * z));
	else
		tmp = (((y / z) / (1.0 + z)) * x) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Less[z, 249.6182814532307], N[(N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision] / N[(z + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / z), $MachinePrecision] / N[(1.0 + z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z < 249.6182814532307:\\
\;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2023297 
(FPCore (x y z)
  :name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1.0 z)) x) z))

  (/ (* x y) (* (* z z) (+ z 1.0))))