Numeric.SpecFunctions:choose from math-functions-0.1.5.2

Percentage Accurate: 83.9% → 95.1%
Time: 3.8s
Alternatives: 7
Speedup: 0.8×

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 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: 83.9% 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.1% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.5999999999999997e166

    1. Initial program 96.6%

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

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

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

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

    if -3.5999999999999997e166 < y

    1. Initial program 80.8%

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

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

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

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

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

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

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

Alternative 2: 89.1% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;z \leq -1.75 \cdot 10^{-147}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -2.5 \cdot 10^{-284}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;z \leq 3.6 \cdot 10^{+117}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.99999999999999981e158 or 3.60000000000000013e117 < z

    1. Initial program 62.2%

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

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

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

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

    if -3.99999999999999981e158 < z < -1.75000000000000002e-147 or -2.49999999999999987e-284 < z < 3.60000000000000013e117

    1. Initial program 90.5%

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

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

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

    if -1.75000000000000002e-147 < z < -2.49999999999999987e-284

    1. Initial program 93.4%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+158}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-147}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-284}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{+117}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 3: 67.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+118} \lor \neg \left(y \leq 3 \cdot 10^{+172}\right):\\
\;\;\;\;x \cdot \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3e118 or 2.9999999999999999e172 < y

    1. Initial program 91.2%

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

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

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

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

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

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

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

    if -3e118 < y < 2.9999999999999999e172

    1. Initial program 79.8%

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

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

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

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

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

Alternative 4: 69.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+94} \lor \neg \left(y \leq 1.05 \cdot 10^{+173}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.04999999999999995e94 or 1.05e173 < y

    1. Initial program 89.7%

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

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

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

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

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

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

    if -1.04999999999999995e94 < y < 1.05e173

    1. Initial program 79.9%

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

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

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

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

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

Alternative 5: 69.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;y \leq 3 \cdot 10^{+172}:\\
\;\;\;\;x\\

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


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

    1. Initial program 92.3%

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

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

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

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

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

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

    if -1.05e88 < y < 2.9999999999999999e172

    1. Initial program 79.9%

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

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

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

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

    if 2.9999999999999999e172 < y

    1. Initial program 84.7%

      \[\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 77.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+88}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+172}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternative 6: 69.3% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;y \leq 3 \cdot 10^{+172}:\\
\;\;\;\;x\\

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


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

    1. Initial program 92.3%

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

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

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

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

    if -3.99999999999999984e88 < y < 2.9999999999999999e172

    1. Initial program 79.9%

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

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

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

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

    if 2.9999999999999999e172 < y

    1. Initial program 84.7%

      \[\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 77.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4 \cdot 10^{+88}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;y \leq 3 \cdot 10^{+172}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternative 7: 51.8% 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 82.8%

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

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

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

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

    \[\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 2023230 
(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))