Numeric.SpecFunctions:choose from math-functions-0.1.5.2

Percentage Accurate: 84.8% → 94.7%
Time: 2.7s
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.8% 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: 94.7% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 9.99999999999999971e-29

    1. Initial program 87.6%

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

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

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

    if 9.99999999999999971e-29 < y

    1. Initial program 87.4%

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

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

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

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

Alternative 2: 70.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+43} \lor \neg \left(y \leq 110000 \lor \neg \left(y \leq 2.25 \cdot 10^{+80}\right) \land y \leq 2.2 \cdot 10^{+109}\right):\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -2.5e+43)
         (not
          (or (<= y 110000.0) (and (not (<= y 2.25e+80)) (<= y 2.2e+109)))))
   (* x (/ y z))
   x))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -2.5e+43) || !((y <= 110000.0) || (!(y <= 2.25e+80) && (y <= 2.2e+109)))) {
		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 ((y <= (-2.5d+43)) .or. (.not. (y <= 110000.0d0) .or. (.not. (y <= 2.25d+80)) .and. (y <= 2.2d+109))) 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 ((y <= -2.5e+43) || !((y <= 110000.0) || (!(y <= 2.25e+80) && (y <= 2.2e+109)))) {
		tmp = x * (y / z);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -2.5e+43) or not ((y <= 110000.0) or (not (y <= 2.25e+80) and (y <= 2.2e+109))):
		tmp = x * (y / z)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -2.5e+43) || !((y <= 110000.0) || (!(y <= 2.25e+80) && (y <= 2.2e+109))))
		tmp = Float64(x * Float64(y / z));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -2.5e+43) || ~(((y <= 110000.0) || (~((y <= 2.25e+80)) && (y <= 2.2e+109)))))
		tmp = x * (y / z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.5e+43], N[Not[Or[LessEqual[y, 110000.0], And[N[Not[LessEqual[y, 2.25e+80]], $MachinePrecision], LessEqual[y, 2.2e+109]]]], $MachinePrecision]], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+43} \lor \neg \left(y \leq 110000 \lor \neg \left(y \leq 2.25 \cdot 10^{+80}\right) \land y \leq 2.2 \cdot 10^{+109}\right):\\
\;\;\;\;x \cdot \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.5000000000000002e43 or 1.1e5 < y < 2.25000000000000003e80 or 2.1999999999999999e109 < y

    1. Initial program 91.2%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    3. Simplified90.5%

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    4. Taylor expanded in y around inf 77.7%

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

    if -2.5000000000000002e43 < y < 1.1e5 or 2.25000000000000003e80 < y < 2.1999999999999999e109

    1. Initial program 84.3%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    4. Taylor expanded in y around 0 81.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+43} \lor \neg \left(y \leq 110000 \lor \neg \left(y \leq 2.25 \cdot 10^{+80}\right) \land y \leq 2.2 \cdot 10^{+109}\right):\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 3: 71.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+43} \lor \neg \left(y \leq 780000\right) \land \left(y \leq 2.05 \cdot 10^{+80} \lor \neg \left(y \leq 1.78 \cdot 10^{+109}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -3.8e+43)
         (and (not (<= y 780000.0))
              (or (<= y 2.05e+80) (not (<= y 1.78e+109)))))
   (* y (/ x z))
   x))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.8e+43) || (!(y <= 780000.0) && ((y <= 2.05e+80) || !(y <= 1.78e+109)))) {
		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 ((y <= (-3.8d+43)) .or. (.not. (y <= 780000.0d0)) .and. (y <= 2.05d+80) .or. (.not. (y <= 1.78d+109))) 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 ((y <= -3.8e+43) || (!(y <= 780000.0) && ((y <= 2.05e+80) || !(y <= 1.78e+109)))) {
		tmp = y * (x / z);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -3.8e+43) or (not (y <= 780000.0) and ((y <= 2.05e+80) or not (y <= 1.78e+109))):
		tmp = y * (x / z)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -3.8e+43) || (!(y <= 780000.0) && ((y <= 2.05e+80) || !(y <= 1.78e+109))))
		tmp = Float64(y * Float64(x / z));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -3.8e+43) || (~((y <= 780000.0)) && ((y <= 2.05e+80) || ~((y <= 1.78e+109)))))
		tmp = y * (x / z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.8e+43], And[N[Not[LessEqual[y, 780000.0]], $MachinePrecision], Or[LessEqual[y, 2.05e+80], N[Not[LessEqual[y, 1.78e+109]], $MachinePrecision]]]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+43} \lor \neg \left(y \leq 780000\right) \land \left(y \leq 2.05 \cdot 10^{+80} \lor \neg \left(y \leq 1.78 \cdot 10^{+109}\right)\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.80000000000000008e43 or 7.8e5 < y < 2.05000000000000001e80 or 1.7800000000000001e109 < y

    1. Initial program 91.2%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    3. Simplified90.5%

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    4. Taylor expanded in y around inf 82.3%

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

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

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

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

    if -3.80000000000000008e43 < y < 7.8e5 or 2.05000000000000001e80 < y < 1.7800000000000001e109

    1. Initial program 84.3%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    4. Taylor expanded in y around 0 81.5%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification83.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+43} \lor \neg \left(y \leq 780000\right) \land \left(y \leq 2.05 \cdot 10^{+80} \lor \neg \left(y \leq 1.78 \cdot 10^{+109}\right)\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 4: 72.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+45}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;y \leq 0.032:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{+80} \lor \neg \left(y \leq 1.78 \cdot 10^{+109}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2.2e+45)
   (/ (* y x) z)
   (if (<= y 0.032)
     x
     (if (or (<= y 2.25e+80) (not (<= y 1.78e+109))) (* y (/ x z)) x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.2e+45) {
		tmp = (y * x) / z;
	} else if (y <= 0.032) {
		tmp = x;
	} else if ((y <= 2.25e+80) || !(y <= 1.78e+109)) {
		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 (y <= (-2.2d+45)) then
        tmp = (y * x) / z
    else if (y <= 0.032d0) then
        tmp = x
    else if ((y <= 2.25d+80) .or. (.not. (y <= 1.78d+109))) 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 (y <= -2.2e+45) {
		tmp = (y * x) / z;
	} else if (y <= 0.032) {
		tmp = x;
	} else if ((y <= 2.25e+80) || !(y <= 1.78e+109)) {
		tmp = y * (x / z);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2.2e+45:
		tmp = (y * x) / z
	elif y <= 0.032:
		tmp = x
	elif (y <= 2.25e+80) or not (y <= 1.78e+109):
		tmp = y * (x / z)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2.2e+45)
		tmp = Float64(Float64(y * x) / z);
	elseif (y <= 0.032)
		tmp = x;
	elseif ((y <= 2.25e+80) || !(y <= 1.78e+109))
		tmp = Float64(y * Float64(x / z));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2.2e+45)
		tmp = (y * x) / z;
	elseif (y <= 0.032)
		tmp = x;
	elseif ((y <= 2.25e+80) || ~((y <= 1.78e+109)))
		tmp = y * (x / z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2.2e+45], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 0.032], x, If[Or[LessEqual[y, 2.25e+80], N[Not[LessEqual[y, 1.78e+109]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], x]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 0.032:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 2.25 \cdot 10^{+80} \lor \neg \left(y \leq 1.78 \cdot 10^{+109}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\

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


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

    1. Initial program 96.1%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    4. Taylor expanded in y around inf 83.4%

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

    if -2.2e45 < y < 0.032000000000000001 or 2.25000000000000003e80 < y < 1.7800000000000001e109

    1. Initial program 84.3%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    4. Taylor expanded in y around 0 81.5%

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

    if 0.032000000000000001 < y < 2.25000000000000003e80 or 1.7800000000000001e109 < y

    1. Initial program 87.2%

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

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    3. Simplified88.5%

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
    4. Taylor expanded in y around inf 81.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+45}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;y \leq 0.032:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{+80} \lor \neg \left(y \leq 1.78 \cdot 10^{+109}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 96.0% accurate, 1.0× speedup?

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

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

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

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

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

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

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 87.6%

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

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

    \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
  4. Taylor expanded in y around 0 50.5%

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

    \[\leadsto x \]

Developer target: 96.5% 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 2023271 
(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))