Numeric.SpecFunctions:choose from math-functions-0.1.5.2

Percentage Accurate: 84.6% → 95.9%
Time: 5.4s
Alternatives: 6
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 6 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.6% 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: 95.9% accurate, 0.1× speedup?

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

\\
\mathsf{fma}\left(x, \frac{y}{z}, x\right)
\end{array}
Derivation
  1. Initial program 84.6%

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

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

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

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

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

      \[\leadsto y \cdot \frac{x}{z} - \color{blue}{\frac{x}{z} \cdot \left(-z\right)} \]
    6. remove-double-neg77.8%

      \[\leadsto y \cdot \frac{x}{z} - \frac{x}{\color{blue}{-\left(-z\right)}} \cdot \left(-z\right) \]
    7. distribute-frac-neg277.8%

      \[\leadsto y \cdot \frac{x}{z} - \color{blue}{\left(-\frac{x}{-z}\right)} \cdot \left(-z\right) \]
    8. distribute-frac-neg77.8%

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

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

      \[\leadsto y \cdot \frac{x}{z} - \color{blue}{\left(-x\right) \cdot \frac{-z}{-z}} \]
    11. *-inverses94.8%

      \[\leadsto y \cdot \frac{x}{z} - \left(-x\right) \cdot \color{blue}{1} \]
    12. *-rgt-identity94.8%

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} - \left(-x\right) \]
    16. fma-neg96.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, -\left(-x\right)\right)} \]
    17. remove-double-neg96.9%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, x\right)} \]
  4. Add Preprocessing
  5. Final simplification96.9%

    \[\leadsto \mathsf{fma}\left(x, \frac{y}{z}, x\right) \]
  6. Add Preprocessing

Alternative 2: 70.3% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 1.22 \cdot 10^{+60}:\\
\;\;\;\;x \cdot \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.7500000000000001e93 or 1.21999999999999995e60 < z

    1. Initial program 66.9%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
      3. distribute-lft-neg-in100.0%

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

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

        \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
      6. remove-double-neg100.0%

        \[\leadsto \left(-x\right) \cdot \frac{y + \color{blue}{\left(-\left(-z\right)\right)}}{-z} \]
      7. unsub-neg100.0%

        \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
      8. div-sub100.0%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)} \]
      9. *-inverses100.0%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
      10. metadata-eval100.0%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
      11. sub-neg100.0%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} + \left(-\left(--1\right)\right)\right)} \]
      12. metadata-eval100.0%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \left(-\color{blue}{1}\right)\right) \]
      13. metadata-eval100.0%

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

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
      15. distribute-lft-neg-out100.0%

        \[\leadsto \color{blue}{\left(-x \cdot \frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
      16. distribute-rgt-neg-out100.0%

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
      18. remove-double-neg100.0%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
      19. distribute-lft-neg-in100.0%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{\left(-x \cdot -1\right)} \]
      20. distribute-rgt-neg-in100.0%

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

        \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} + \left(--1\right)\right)} \]
      22. sub-neg100.0%

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

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

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

    if -3.7500000000000001e93 < z < 1.21999999999999995e60

    1. Initial program 94.8%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg95.2%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
      3. distribute-lft-neg-in95.2%

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

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

        \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
      6. remove-double-neg95.2%

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

        \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
      8. div-sub95.2%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)} \]
      9. *-inverses95.2%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
      10. metadata-eval95.2%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
      11. sub-neg95.2%

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

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

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \color{blue}{-1}\right) \]
      14. distribute-lft-in95.2%

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
      15. distribute-lft-neg-out95.2%

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

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
      18. remove-double-neg95.2%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
      19. distribute-lft-neg-in95.2%

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

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x \cdot \left(--1\right)} \]
      21. distribute-lft-in95.2%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.75 \cdot 10^{+93}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.22 \cdot 10^{+60}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 72.2% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq 2.9 \cdot 10^{+60}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.54999999999999996e94 or 2.9e60 < z

    1. Initial program 66.9%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg100.0%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
      3. distribute-lft-neg-in100.0%

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

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

        \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
      6. remove-double-neg100.0%

        \[\leadsto \left(-x\right) \cdot \frac{y + \color{blue}{\left(-\left(-z\right)\right)}}{-z} \]
      7. unsub-neg100.0%

        \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
      8. div-sub100.0%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)} \]
      9. *-inverses100.0%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
      10. metadata-eval100.0%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
      11. sub-neg100.0%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} + \left(-\left(--1\right)\right)\right)} \]
      12. metadata-eval100.0%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \left(-\color{blue}{1}\right)\right) \]
      13. metadata-eval100.0%

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

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
      15. distribute-lft-neg-out100.0%

        \[\leadsto \color{blue}{\left(-x \cdot \frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
      16. distribute-rgt-neg-out100.0%

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
      18. remove-double-neg100.0%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
      19. distribute-lft-neg-in100.0%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{\left(-x \cdot -1\right)} \]
      20. distribute-rgt-neg-in100.0%

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

        \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} + \left(--1\right)\right)} \]
      22. sub-neg100.0%

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

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

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

    if -1.54999999999999996e94 < z < 2.9e60

    1. Initial program 94.8%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg95.2%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
      3. distribute-lft-neg-in95.2%

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

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

        \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
      6. remove-double-neg95.2%

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

        \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
      8. div-sub95.2%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)} \]
      9. *-inverses95.2%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
      10. metadata-eval95.2%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
      11. sub-neg95.2%

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

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

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \color{blue}{-1}\right) \]
      14. distribute-lft-in95.2%

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
      15. distribute-lft-neg-out95.2%

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

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
      18. remove-double-neg95.2%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
      19. distribute-lft-neg-in95.2%

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

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x \cdot \left(--1\right)} \]
      21. distribute-lft-in95.2%

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

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

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

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

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

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
    7. Applied egg-rr74.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{+94}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+60}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 71.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+117}:\\
\;\;\;\;y \cdot \frac{x}{z}\\

\mathbf{elif}\;y \leq 6 \cdot 10^{-34}:\\
\;\;\;\;x\\

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


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

    1. Initial program 89.0%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg92.7%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
      3. distribute-lft-neg-in92.7%

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

        \[\leadsto \color{blue}{\left(-x\right) \cdot \left(-\frac{y + z}{z}\right)} \]
      5. distribute-frac-neg292.7%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
      6. remove-double-neg92.7%

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

        \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
      8. div-sub92.7%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)} \]
      9. *-inverses92.7%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
      10. metadata-eval92.7%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
      11. sub-neg92.7%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} + \left(-\left(--1\right)\right)\right)} \]
      12. metadata-eval92.7%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \left(-\color{blue}{1}\right)\right) \]
      13. metadata-eval92.7%

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

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
      15. distribute-lft-neg-out92.7%

        \[\leadsto \color{blue}{\left(-x \cdot \frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
      16. distribute-rgt-neg-out92.7%

        \[\leadsto \color{blue}{x \cdot \left(-\frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
      17. distribute-frac-neg292.7%

        \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
      18. remove-double-neg92.7%

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

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

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

        \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} + \left(--1\right)\right)} \]
      22. sub-neg92.7%

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

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

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

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

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

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

    if -3.8000000000000002e117 < y < 6e-34

    1. Initial program 80.7%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg99.9%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
      3. distribute-lft-neg-in99.9%

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

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

        \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
      6. remove-double-neg99.9%

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

        \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
      8. div-sub99.9%

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

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
      10. metadata-eval99.9%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
      11. sub-neg99.9%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} + \left(-\left(--1\right)\right)\right)} \]
      12. metadata-eval99.9%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \left(-\color{blue}{1}\right)\right) \]
      13. metadata-eval99.9%

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

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

        \[\leadsto \color{blue}{\left(-x \cdot \frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
      16. distribute-rgt-neg-out99.9%

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

        \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
      18. remove-double-neg99.9%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
      19. distribute-lft-neg-in99.9%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{\left(-x \cdot -1\right)} \]
      20. distribute-rgt-neg-in99.9%

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

        \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} + \left(--1\right)\right)} \]
      22. sub-neg99.9%

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

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

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

    if 6e-34 < y

    1. Initial program 88.3%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg94.8%

        \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
      3. distribute-lft-neg-in94.8%

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

        \[\leadsto \color{blue}{\left(-x\right) \cdot \left(-\frac{y + z}{z}\right)} \]
      5. distribute-frac-neg294.8%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
      6. remove-double-neg94.8%

        \[\leadsto \left(-x\right) \cdot \frac{y + \color{blue}{\left(-\left(-z\right)\right)}}{-z} \]
      7. unsub-neg94.8%

        \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
      8. div-sub94.8%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)} \]
      9. *-inverses94.8%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
      10. metadata-eval94.8%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
      11. sub-neg94.8%

        \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} + \left(-\left(--1\right)\right)\right)} \]
      12. metadata-eval94.8%

        \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \left(-\color{blue}{1}\right)\right) \]
      13. metadata-eval94.8%

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

        \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
      15. distribute-lft-neg-out94.8%

        \[\leadsto \color{blue}{\left(-x \cdot \frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
      16. distribute-rgt-neg-out94.8%

        \[\leadsto \color{blue}{x \cdot \left(-\frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
      17. distribute-frac-neg294.8%

        \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
      18. remove-double-neg94.8%

        \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
      19. distribute-lft-neg-in94.8%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{\left(-x \cdot -1\right)} \]
      20. distribute-rgt-neg-in94.8%

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

        \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} + \left(--1\right)\right)} \]
      22. sub-neg94.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+117}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 95.9% accurate, 1.0× speedup?

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

\\
x \cdot \left(\frac{y}{z} - -1\right)
\end{array}
Derivation
  1. Initial program 84.6%

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

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    2. remove-double-neg96.9%

      \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
    3. distribute-lft-neg-in96.9%

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

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

      \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
    6. remove-double-neg96.9%

      \[\leadsto \left(-x\right) \cdot \frac{y + \color{blue}{\left(-\left(-z\right)\right)}}{-z} \]
    7. unsub-neg96.9%

      \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
    8. div-sub96.9%

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

      \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
    10. metadata-eval96.9%

      \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
    11. sub-neg96.9%

      \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} + \left(-\left(--1\right)\right)\right)} \]
    12. metadata-eval96.9%

      \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \left(-\color{blue}{1}\right)\right) \]
    13. metadata-eval96.9%

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

      \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
    15. distribute-lft-neg-out96.9%

      \[\leadsto \color{blue}{\left(-x \cdot \frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
    16. distribute-rgt-neg-out96.9%

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

      \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
    18. remove-double-neg96.9%

      \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
    19. distribute-lft-neg-in96.9%

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{\left(-x \cdot -1\right)} \]
    20. distribute-rgt-neg-in96.9%

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} + \left(--1\right)\right)} \]
    22. sub-neg96.9%

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

    \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
  4. Add Preprocessing
  5. Final simplification96.9%

    \[\leadsto x \cdot \left(\frac{y}{z} - -1\right) \]
  6. Add Preprocessing

Alternative 6: 50.3% 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 84.6%

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

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    2. remove-double-neg96.9%

      \[\leadsto \color{blue}{\left(-\left(-x\right)\right)} \cdot \frac{y + z}{z} \]
    3. distribute-lft-neg-in96.9%

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

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

      \[\leadsto \left(-x\right) \cdot \color{blue}{\frac{y + z}{-z}} \]
    6. remove-double-neg96.9%

      \[\leadsto \left(-x\right) \cdot \frac{y + \color{blue}{\left(-\left(-z\right)\right)}}{-z} \]
    7. unsub-neg96.9%

      \[\leadsto \left(-x\right) \cdot \frac{\color{blue}{y - \left(-z\right)}}{-z} \]
    8. div-sub96.9%

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

      \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{1}\right) \]
    10. metadata-eval96.9%

      \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right) \]
    11. sub-neg96.9%

      \[\leadsto \left(-x\right) \cdot \color{blue}{\left(\frac{y}{-z} + \left(-\left(--1\right)\right)\right)} \]
    12. metadata-eval96.9%

      \[\leadsto \left(-x\right) \cdot \left(\frac{y}{-z} + \left(-\color{blue}{1}\right)\right) \]
    13. metadata-eval96.9%

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

      \[\leadsto \color{blue}{\left(-x\right) \cdot \frac{y}{-z} + \left(-x\right) \cdot -1} \]
    15. distribute-lft-neg-out96.9%

      \[\leadsto \color{blue}{\left(-x \cdot \frac{y}{-z}\right)} + \left(-x\right) \cdot -1 \]
    16. distribute-rgt-neg-out96.9%

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

      \[\leadsto x \cdot \color{blue}{\frac{y}{-\left(-z\right)}} + \left(-x\right) \cdot -1 \]
    18. remove-double-neg96.9%

      \[\leadsto x \cdot \frac{y}{\color{blue}{z}} + \left(-x\right) \cdot -1 \]
    19. distribute-lft-neg-in96.9%

      \[\leadsto x \cdot \frac{y}{z} + \color{blue}{\left(-x \cdot -1\right)} \]
    20. distribute-rgt-neg-in96.9%

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} + \left(--1\right)\right)} \]
    22. sub-neg96.9%

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

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification45.2%

    \[\leadsto x \]
  7. Add Preprocessing

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 2024046 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :alt
  (/ x (/ z (+ y z)))

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