Development.Shake.Progress:message from shake-0.15.5

Percentage Accurate: 99.5% → 99.7%
Time: 3.9s
Alternatives: 6
Speedup: 1.0×

Specification

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

\\
\frac{x \cdot 100}{x + y}
\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: 99.5% accurate, 1.0× speedup?

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

\\
\frac{x \cdot 100}{x + y}
\end{array}

Alternative 1: 99.7% accurate, 1.0× speedup?

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

\\
\frac{x}{\left(x + y\right) \cdot 0.01}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\frac{x \cdot 100}{x + y} \]
  2. Step-by-step derivation
    1. expm1-log1p-u98.3%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)\right)} \]
    2. expm1-udef65.6%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)} - 1} \]
    3. associate-/l*66.0%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{x + y}{100}}}\right)} - 1 \]
    4. div-inv66.0%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(x + y\right) \cdot \frac{1}{100}}}\right)} - 1 \]
    5. +-commutative66.0%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(y + x\right)} \cdot \frac{1}{100}}\right)} - 1 \]
    6. metadata-eval66.0%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot \color{blue}{0.01}}\right)} - 1 \]
  3. Applied egg-rr66.0%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)} - 1} \]
  4. Step-by-step derivation
    1. expm1-def98.7%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)\right)} \]
    2. expm1-log1p99.7%

      \[\leadsto \color{blue}{\frac{x}{\left(y + x\right) \cdot 0.01}} \]
  5. Simplified99.7%

    \[\leadsto \color{blue}{\frac{x}{\left(y + x\right) \cdot 0.01}} \]
  6. Final simplification99.7%

    \[\leadsto \frac{x}{\left(x + y\right) \cdot 0.01} \]

Alternative 2: 73.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-79} \lor \neg \left(x \leq 1.02 \cdot 10^{+18}\right) \land x \leq 1.4 \cdot 10^{+97}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -3.5e+38)
   100.0
   (if (or (<= x 2.8e-79) (and (not (<= x 1.02e+18)) (<= x 1.4e+97)))
     (* 100.0 (/ x y))
     100.0)))
double code(double x, double y) {
	double tmp;
	if (x <= -3.5e+38) {
		tmp = 100.0;
	} else if ((x <= 2.8e-79) || (!(x <= 1.02e+18) && (x <= 1.4e+97))) {
		tmp = 100.0 * (x / y);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-3.5d+38)) then
        tmp = 100.0d0
    else if ((x <= 2.8d-79) .or. (.not. (x <= 1.02d+18)) .and. (x <= 1.4d+97)) then
        tmp = 100.0d0 * (x / y)
    else
        tmp = 100.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -3.5e+38) {
		tmp = 100.0;
	} else if ((x <= 2.8e-79) || (!(x <= 1.02e+18) && (x <= 1.4e+97))) {
		tmp = 100.0 * (x / y);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -3.5e+38:
		tmp = 100.0
	elif (x <= 2.8e-79) or (not (x <= 1.02e+18) and (x <= 1.4e+97)):
		tmp = 100.0 * (x / y)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -3.5e+38)
		tmp = 100.0;
	elseif ((x <= 2.8e-79) || (!(x <= 1.02e+18) && (x <= 1.4e+97)))
		tmp = Float64(100.0 * Float64(x / y));
	else
		tmp = 100.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -3.5e+38)
		tmp = 100.0;
	elseif ((x <= 2.8e-79) || (~((x <= 1.02e+18)) && (x <= 1.4e+97)))
		tmp = 100.0 * (x / y);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -3.5e+38], 100.0, If[Or[LessEqual[x, 2.8e-79], And[N[Not[LessEqual[x, 1.02e+18]], $MachinePrecision], LessEqual[x, 1.4e+97]]], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 100.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{+38}:\\
\;\;\;\;100\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-79} \lor \neg \left(x \leq 1.02 \cdot 10^{+18}\right) \land x \leq 1.4 \cdot 10^{+97}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\

\mathbf{else}:\\
\;\;\;\;100\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.50000000000000002e38 or 2.80000000000000012e-79 < x < 1.02e18 or 1.4e97 < x

    1. Initial program 98.9%

      \[\frac{x \cdot 100}{x + y} \]
    2. Step-by-step derivation
      1. *-commutative98.9%

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

        \[\leadsto \color{blue}{\frac{100}{\frac{x + y}{x}}} \]
      3. +-commutative99.9%

        \[\leadsto \frac{100}{\frac{\color{blue}{y + x}}{x}} \]
      4. remove-double-neg99.9%

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

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

        \[\leadsto \frac{100}{\color{blue}{\frac{y}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg99.9%

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

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

        \[\leadsto \frac{100}{\frac{y}{x} - \color{blue}{-1}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{100}{\frac{y}{x} - -1}} \]
    4. Taylor expanded in y around 0 82.7%

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

    if -3.50000000000000002e38 < x < 2.80000000000000012e-79 or 1.02e18 < x < 1.4e97

    1. Initial program 99.8%

      \[\frac{x \cdot 100}{x + y} \]
    2. Step-by-step derivation
      1. *-commutative99.8%

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

        \[\leadsto \color{blue}{\frac{100}{\frac{x + y}{x}}} \]
      3. +-commutative98.0%

        \[\leadsto \frac{100}{\frac{\color{blue}{y + x}}{x}} \]
      4. remove-double-neg98.0%

        \[\leadsto \frac{100}{\frac{y + \color{blue}{\left(-\left(-x\right)\right)}}{x}} \]
      5. unsub-neg98.0%

        \[\leadsto \frac{100}{\frac{\color{blue}{y - \left(-x\right)}}{x}} \]
      6. div-sub98.0%

        \[\leadsto \frac{100}{\color{blue}{\frac{y}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg98.0%

        \[\leadsto \frac{100}{\frac{y}{x} - \color{blue}{\left(-\frac{x}{x}\right)}} \]
      8. *-inverses98.0%

        \[\leadsto \frac{100}{\frac{y}{x} - \left(-\color{blue}{1}\right)} \]
      9. metadata-eval98.0%

        \[\leadsto \frac{100}{\frac{y}{x} - \color{blue}{-1}} \]
    3. Simplified98.0%

      \[\leadsto \color{blue}{\frac{100}{\frac{y}{x} - -1}} \]
    4. Taylor expanded in y around inf 79.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-79} \lor \neg \left(x \leq 1.02 \cdot 10^{+18}\right) \land x \leq 1.4 \cdot 10^{+97}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]

Alternative 3: 73.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+35}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-79} \lor \neg \left(x \leq 3.7 \cdot 10^{+18}\right) \land x \leq 1.3 \cdot 10^{+97}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -4e+35)
   100.0
   (if (or (<= x 3.1e-79) (and (not (<= x 3.7e+18)) (<= x 1.3e+97)))
     (/ x (* y 0.01))
     100.0)))
double code(double x, double y) {
	double tmp;
	if (x <= -4e+35) {
		tmp = 100.0;
	} else if ((x <= 3.1e-79) || (!(x <= 3.7e+18) && (x <= 1.3e+97))) {
		tmp = x / (y * 0.01);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-4d+35)) then
        tmp = 100.0d0
    else if ((x <= 3.1d-79) .or. (.not. (x <= 3.7d+18)) .and. (x <= 1.3d+97)) then
        tmp = x / (y * 0.01d0)
    else
        tmp = 100.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -4e+35) {
		tmp = 100.0;
	} else if ((x <= 3.1e-79) || (!(x <= 3.7e+18) && (x <= 1.3e+97))) {
		tmp = x / (y * 0.01);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -4e+35:
		tmp = 100.0
	elif (x <= 3.1e-79) or (not (x <= 3.7e+18) and (x <= 1.3e+97)):
		tmp = x / (y * 0.01)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -4e+35)
		tmp = 100.0;
	elseif ((x <= 3.1e-79) || (!(x <= 3.7e+18) && (x <= 1.3e+97)))
		tmp = Float64(x / Float64(y * 0.01));
	else
		tmp = 100.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -4e+35)
		tmp = 100.0;
	elseif ((x <= 3.1e-79) || (~((x <= 3.7e+18)) && (x <= 1.3e+97)))
		tmp = x / (y * 0.01);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -4e+35], 100.0, If[Or[LessEqual[x, 3.1e-79], And[N[Not[LessEqual[x, 3.7e+18]], $MachinePrecision], LessEqual[x, 1.3e+97]]], N[(x / N[(y * 0.01), $MachinePrecision]), $MachinePrecision], 100.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+35}:\\
\;\;\;\;100\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-79} \lor \neg \left(x \leq 3.7 \cdot 10^{+18}\right) \land x \leq 1.3 \cdot 10^{+97}:\\
\;\;\;\;\frac{x}{y \cdot 0.01}\\

\mathbf{else}:\\
\;\;\;\;100\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.9999999999999999e35 or 3.0999999999999999e-79 < x < 3.7e18 or 1.3e97 < x

    1. Initial program 98.9%

      \[\frac{x \cdot 100}{x + y} \]
    2. Step-by-step derivation
      1. *-commutative98.9%

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

        \[\leadsto \color{blue}{\frac{100}{\frac{x + y}{x}}} \]
      3. +-commutative99.9%

        \[\leadsto \frac{100}{\frac{\color{blue}{y + x}}{x}} \]
      4. remove-double-neg99.9%

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

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

        \[\leadsto \frac{100}{\color{blue}{\frac{y}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg99.9%

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

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

        \[\leadsto \frac{100}{\frac{y}{x} - \color{blue}{-1}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{100}{\frac{y}{x} - -1}} \]
    4. Taylor expanded in y around 0 82.7%

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

    if -3.9999999999999999e35 < x < 3.0999999999999999e-79 or 3.7e18 < x < 1.3e97

    1. Initial program 99.8%

      \[\frac{x \cdot 100}{x + y} \]
    2. Step-by-step derivation
      1. expm1-log1p-u99.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)\right)} \]
      2. expm1-udef51.0%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)} - 1} \]
      3. associate-/l*51.0%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{x + y}{100}}}\right)} - 1 \]
      4. div-inv51.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(x + y\right) \cdot \frac{1}{100}}}\right)} - 1 \]
      5. +-commutative51.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(y + x\right)} \cdot \frac{1}{100}}\right)} - 1 \]
      6. metadata-eval51.0%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot \color{blue}{0.01}}\right)} - 1 \]
    3. Applied egg-rr51.0%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)\right)} \]
      2. expm1-log1p99.7%

        \[\leadsto \color{blue}{\frac{x}{\left(y + x\right) \cdot 0.01}} \]
    5. Simplified99.7%

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

      \[\leadsto \color{blue}{100 \cdot \frac{x}{y}} \]
    7. Step-by-step derivation
      1. metadata-eval79.1%

        \[\leadsto \color{blue}{\frac{1}{0.01}} \cdot \frac{x}{y} \]
      2. times-frac79.4%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{0.01 \cdot y}} \]
      3. *-commutative79.4%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{y \cdot 0.01}} \]
      4. *-lft-identity79.4%

        \[\leadsto \frac{\color{blue}{x}}{y \cdot 0.01} \]
    8. Simplified79.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+35}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-79} \lor \neg \left(x \leq 3.7 \cdot 10^{+18}\right) \land x \leq 1.3 \cdot 10^{+97}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]

Alternative 4: 73.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+35}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-79}:\\ \;\;\;\;\frac{x \cdot 100}{y}\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+18}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+97}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.2e+35)
   100.0
   (if (<= x 3.1e-79)
     (/ (* x 100.0) y)
     (if (<= x 3.7e+18) 100.0 (if (<= x 1.3e+97) (/ x (* y 0.01)) 100.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.2e+35) {
		tmp = 100.0;
	} else if (x <= 3.1e-79) {
		tmp = (x * 100.0) / y;
	} else if (x <= 3.7e+18) {
		tmp = 100.0;
	} else if (x <= 1.3e+97) {
		tmp = x / (y * 0.01);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (x <= (-1.2d+35)) then
        tmp = 100.0d0
    else if (x <= 3.1d-79) then
        tmp = (x * 100.0d0) / y
    else if (x <= 3.7d+18) then
        tmp = 100.0d0
    else if (x <= 1.3d+97) then
        tmp = x / (y * 0.01d0)
    else
        tmp = 100.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.2e+35) {
		tmp = 100.0;
	} else if (x <= 3.1e-79) {
		tmp = (x * 100.0) / y;
	} else if (x <= 3.7e+18) {
		tmp = 100.0;
	} else if (x <= 1.3e+97) {
		tmp = x / (y * 0.01);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.2e+35:
		tmp = 100.0
	elif x <= 3.1e-79:
		tmp = (x * 100.0) / y
	elif x <= 3.7e+18:
		tmp = 100.0
	elif x <= 1.3e+97:
		tmp = x / (y * 0.01)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.2e+35)
		tmp = 100.0;
	elseif (x <= 3.1e-79)
		tmp = Float64(Float64(x * 100.0) / y);
	elseif (x <= 3.7e+18)
		tmp = 100.0;
	elseif (x <= 1.3e+97)
		tmp = Float64(x / Float64(y * 0.01));
	else
		tmp = 100.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.2e+35)
		tmp = 100.0;
	elseif (x <= 3.1e-79)
		tmp = (x * 100.0) / y;
	elseif (x <= 3.7e+18)
		tmp = 100.0;
	elseif (x <= 1.3e+97)
		tmp = x / (y * 0.01);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.2e+35], 100.0, If[LessEqual[x, 3.1e-79], N[(N[(x * 100.0), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 3.7e+18], 100.0, If[LessEqual[x, 1.3e+97], N[(x / N[(y * 0.01), $MachinePrecision]), $MachinePrecision], 100.0]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2 \cdot 10^{+35}:\\
\;\;\;\;100\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-79}:\\
\;\;\;\;\frac{x \cdot 100}{y}\\

\mathbf{elif}\;x \leq 3.7 \cdot 10^{+18}:\\
\;\;\;\;100\\

\mathbf{elif}\;x \leq 1.3 \cdot 10^{+97}:\\
\;\;\;\;\frac{x}{y \cdot 0.01}\\

\mathbf{else}:\\
\;\;\;\;100\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.20000000000000007e35 or 3.0999999999999999e-79 < x < 3.7e18 or 1.3e97 < x

    1. Initial program 98.9%

      \[\frac{x \cdot 100}{x + y} \]
    2. Step-by-step derivation
      1. *-commutative98.9%

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

        \[\leadsto \color{blue}{\frac{100}{\frac{x + y}{x}}} \]
      3. +-commutative99.9%

        \[\leadsto \frac{100}{\frac{\color{blue}{y + x}}{x}} \]
      4. remove-double-neg99.9%

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

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

        \[\leadsto \frac{100}{\color{blue}{\frac{y}{x} - \frac{-x}{x}}} \]
      7. distribute-frac-neg99.9%

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

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

        \[\leadsto \frac{100}{\frac{y}{x} - \color{blue}{-1}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\frac{100}{\frac{y}{x} - -1}} \]
    4. Taylor expanded in y around 0 82.7%

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

    if -1.20000000000000007e35 < x < 3.0999999999999999e-79

    1. Initial program 99.8%

      \[\frac{x \cdot 100}{x + y} \]
    2. Step-by-step derivation
      1. expm1-log1p-u99.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)\right)} \]
      2. expm1-udef53.7%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)} - 1} \]
      3. associate-/l*53.7%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{x + y}{100}}}\right)} - 1 \]
      4. div-inv53.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(x + y\right) \cdot \frac{1}{100}}}\right)} - 1 \]
      5. +-commutative53.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(y + x\right)} \cdot \frac{1}{100}}\right)} - 1 \]
      6. metadata-eval53.7%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot \color{blue}{0.01}}\right)} - 1 \]
    3. Applied egg-rr53.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)\right)} \]
      2. expm1-log1p99.7%

        \[\leadsto \color{blue}{\frac{x}{\left(y + x\right) \cdot 0.01}} \]
    5. Simplified99.7%

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

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

        \[\leadsto \color{blue}{\frac{100 \cdot x}{y}} \]
    8. Simplified80.9%

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

    if 3.7e18 < x < 1.3e97

    1. Initial program 99.6%

      \[\frac{x \cdot 100}{x + y} \]
    2. Step-by-step derivation
      1. expm1-log1p-u98.9%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)\right)} \]
      2. expm1-udef34.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x \cdot 100}{x + y}\right)} - 1} \]
      3. associate-/l*34.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{x + y}{100}}}\right)} - 1 \]
      4. div-inv34.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(x + y\right) \cdot \frac{1}{100}}}\right)} - 1 \]
      5. +-commutative34.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\color{blue}{\left(y + x\right)} \cdot \frac{1}{100}}\right)} - 1 \]
      6. metadata-eval34.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot \color{blue}{0.01}}\right)} - 1 \]
    3. Applied egg-rr34.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)} - 1} \]
    4. Step-by-step derivation
      1. expm1-def99.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{\left(y + x\right) \cdot 0.01}\right)\right)} \]
      2. expm1-log1p99.8%

        \[\leadsto \color{blue}{\frac{x}{\left(y + x\right) \cdot 0.01}} \]
    5. Simplified99.8%

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

      \[\leadsto \color{blue}{100 \cdot \frac{x}{y}} \]
    7. Step-by-step derivation
      1. metadata-eval70.7%

        \[\leadsto \color{blue}{\frac{1}{0.01}} \cdot \frac{x}{y} \]
      2. times-frac70.7%

        \[\leadsto \color{blue}{\frac{1 \cdot x}{0.01 \cdot y}} \]
      3. *-commutative70.7%

        \[\leadsto \frac{1 \cdot x}{\color{blue}{y \cdot 0.01}} \]
      4. *-lft-identity70.7%

        \[\leadsto \frac{\color{blue}{x}}{y \cdot 0.01} \]
    8. Simplified70.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{+35}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-79}:\\ \;\;\;\;\frac{x \cdot 100}{y}\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+18}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+97}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]

Alternative 5: 99.2% accurate, 1.0× speedup?

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

\\
\frac{100}{\frac{y}{x} - -1}
\end{array}
Derivation
  1. Initial program 99.3%

    \[\frac{x \cdot 100}{x + y} \]
  2. Step-by-step derivation
    1. *-commutative99.3%

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

      \[\leadsto \color{blue}{\frac{100}{\frac{x + y}{x}}} \]
    3. +-commutative98.9%

      \[\leadsto \frac{100}{\frac{\color{blue}{y + x}}{x}} \]
    4. remove-double-neg98.9%

      \[\leadsto \frac{100}{\frac{y + \color{blue}{\left(-\left(-x\right)\right)}}{x}} \]
    5. unsub-neg98.9%

      \[\leadsto \frac{100}{\frac{\color{blue}{y - \left(-x\right)}}{x}} \]
    6. div-sub98.9%

      \[\leadsto \frac{100}{\color{blue}{\frac{y}{x} - \frac{-x}{x}}} \]
    7. distribute-frac-neg98.9%

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

      \[\leadsto \frac{100}{\frac{y}{x} - \left(-\color{blue}{1}\right)} \]
    9. metadata-eval98.9%

      \[\leadsto \frac{100}{\frac{y}{x} - \color{blue}{-1}} \]
  3. Simplified98.9%

    \[\leadsto \color{blue}{\frac{100}{\frac{y}{x} - -1}} \]
  4. Final simplification98.9%

    \[\leadsto \frac{100}{\frac{y}{x} - -1} \]

Alternative 6: 51.2% accurate, 7.0× speedup?

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

\\
100
\end{array}
Derivation
  1. Initial program 99.3%

    \[\frac{x \cdot 100}{x + y} \]
  2. Step-by-step derivation
    1. *-commutative99.3%

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

      \[\leadsto \color{blue}{\frac{100}{\frac{x + y}{x}}} \]
    3. +-commutative98.9%

      \[\leadsto \frac{100}{\frac{\color{blue}{y + x}}{x}} \]
    4. remove-double-neg98.9%

      \[\leadsto \frac{100}{\frac{y + \color{blue}{\left(-\left(-x\right)\right)}}{x}} \]
    5. unsub-neg98.9%

      \[\leadsto \frac{100}{\frac{\color{blue}{y - \left(-x\right)}}{x}} \]
    6. div-sub98.9%

      \[\leadsto \frac{100}{\color{blue}{\frac{y}{x} - \frac{-x}{x}}} \]
    7. distribute-frac-neg98.9%

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

      \[\leadsto \frac{100}{\frac{y}{x} - \left(-\color{blue}{1}\right)} \]
    9. metadata-eval98.9%

      \[\leadsto \frac{100}{\frac{y}{x} - \color{blue}{-1}} \]
  3. Simplified98.9%

    \[\leadsto \color{blue}{\frac{100}{\frac{y}{x} - -1}} \]
  4. Taylor expanded in y around 0 51.4%

    \[\leadsto \color{blue}{100} \]
  5. Final simplification51.4%

    \[\leadsto 100 \]

Developer target: 99.7% accurate, 0.8× speedup?

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

\\
\frac{x}{1} \cdot \frac{100}{x + y}
\end{array}

Reproduce

?
herbie shell --seed 2023334 
(FPCore (x y)
  :name "Development.Shake.Progress:message from shake-0.15.5"
  :precision binary64

  :herbie-target
  (* (/ x 1.0) (/ 100.0 (+ x y)))

  (/ (* x 100.0) (+ x y)))