Numeric.SpecFunctions:choose from math-functions-0.1.5.2

Percentage Accurate: 85.0% → 96.1%
Time: 4.0s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot \left(y + z\right)}{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(Float64(x * Float64(y + z)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * (y + z)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

\\
\frac{x \cdot \left(y + z\right)}{z}
\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 8 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: 85.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot \left(y + z\right)}{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(Float64(x * Float64(y + z)) / z)
end
function tmp = code(x, y, z)
	tmp = (x * (y + z)) / z;
end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 96.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.9 \cdot 10^{+179}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 3.89999999999999974e179

    1. Initial program 83.8%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified84.7%

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

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

        \[\leadsto \frac{x}{\frac{z}{\color{blue}{z + y}}} \]
    5. Applied egg-rr98.2%

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

    if 3.89999999999999974e179 < y

    1. Initial program 96.3%

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

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

Alternative 2: 90.1% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.6 \cdot 10^{+118}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 7.8 \cdot 10^{+179}:\\
\;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.6e118 or 7.79999999999999947e179 < z

    1. Initial program 63.1%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified67.5%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    4. Taylor expanded in z around inf 94.1%

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

    if -6.6e118 < z < 7.79999999999999947e179

    1. Initial program 92.4%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified91.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.6 \cdot 10^{+118}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{+179}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 3: 71.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-49}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 14500000000000:\\
\;\;\;\;x \cdot \frac{y}{z}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.79999999999999997e-49 or 1.45e13 < z

    1. Initial program 79.7%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified79.5%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    4. Taylor expanded in z around inf 80.1%

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

    if -2.79999999999999997e-49 < z < 1.45e13

    1. Initial program 91.2%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified92.2%

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

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

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

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

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

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

Alternative 4: 73.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{-50}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 15500000000000:\\
\;\;\;\;y \cdot \frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.4000000000000003e-50 or 1.55e13 < z

    1. Initial program 79.7%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified79.5%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    4. Taylor expanded in z around inf 80.1%

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

    if -8.4000000000000003e-50 < z < 1.55e13

    1. Initial program 91.2%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified92.2%

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

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

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

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

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

Alternative 5: 73.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{-49}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 12600000000000:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.1999999999999999e-49 or 1.26e13 < z

    1. Initial program 79.7%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified79.5%

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    4. Taylor expanded in z around inf 80.1%

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

    if -2.1999999999999999e-49 < z < 1.26e13

    1. Initial program 91.2%

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

        \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    3. Simplified92.2%

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

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

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

Alternative 6: 96.0% accurate, 1.0× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
    2. distribute-rgt-in81.4%

      \[\leadsto \color{blue}{y \cdot \frac{x}{z} + z \cdot \frac{x}{z}} \]
    3. *-commutative81.4%

      \[\leadsto y \cdot \frac{x}{z} + \color{blue}{\frac{x}{z} \cdot z} \]
    4. associate-/r/94.2%

      \[\leadsto y \cdot \frac{x}{z} + \color{blue}{\frac{x}{\frac{z}{z}}} \]
    5. *-inverses94.2%

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

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} + x \]
    8. *-commutative93.7%

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} + x \]
    10. fma-def96.2%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, x\right)} \]
  4. Step-by-step derivation
    1. fma-udef96.2%

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

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

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

Alternative 7: 96.3% accurate, 1.0× speedup?

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

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

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

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

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

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

      \[\leadsto \frac{x}{\frac{z}{\color{blue}{z + y}}} \]
  5. Applied egg-rr96.2%

    \[\leadsto \color{blue}{\frac{x}{\frac{z}{z + y}}} \]
  6. Final simplification96.2%

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

Alternative 8: 51.1% accurate, 7.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 85.1%

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

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

    \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)} \]
  4. Taylor expanded in z around inf 53.8%

    \[\leadsto \color{blue}{x} \]
  5. Final simplification53.8%

    \[\leadsto x \]

Developer target: 96.3% accurate, 1.0× speedup?

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

\\
\frac{x}{\frac{z}{y + z}}
\end{array}

Reproduce

?
herbie shell --seed 2023192 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

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