Development.Shake.Progress:message from shake-0.15.5

Percentage Accurate: 99.3% → 99.3%
Time: 3.4s
Alternatives: 5
Speedup: N/A×

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 5 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.3% 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.3% 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*99.8%

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

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

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

      \[\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. Add Preprocessing
  5. Final simplification99.9%

    \[\leadsto \frac{100}{\frac{y}{x} - -1} \]
  6. Add Preprocessing

Alternative 2: 71.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{+109}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -0.00018 \lor \neg \left(x \leq -4.6 \cdot 10^{-108}\right) \land x \leq 1.06 \cdot 10^{+53}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.65e+109)
   100.0
   (if (or (<= x -0.00018) (and (not (<= x -4.6e-108)) (<= x 1.06e+53)))
     (* 100.0 (/ x y))
     100.0)))
double code(double x, double y) {
	double tmp;
	if (x <= -1.65e+109) {
		tmp = 100.0;
	} else if ((x <= -0.00018) || (!(x <= -4.6e-108) && (x <= 1.06e+53))) {
		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 <= (-1.65d+109)) then
        tmp = 100.0d0
    else if ((x <= (-0.00018d0)) .or. (.not. (x <= (-4.6d-108))) .and. (x <= 1.06d+53)) 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 <= -1.65e+109) {
		tmp = 100.0;
	} else if ((x <= -0.00018) || (!(x <= -4.6e-108) && (x <= 1.06e+53))) {
		tmp = 100.0 * (x / y);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.65e+109:
		tmp = 100.0
	elif (x <= -0.00018) or (not (x <= -4.6e-108) and (x <= 1.06e+53)):
		tmp = 100.0 * (x / y)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.65e+109)
		tmp = 100.0;
	elseif ((x <= -0.00018) || (!(x <= -4.6e-108) && (x <= 1.06e+53)))
		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 <= -1.65e+109)
		tmp = 100.0;
	elseif ((x <= -0.00018) || (~((x <= -4.6e-108)) && (x <= 1.06e+53)))
		tmp = 100.0 * (x / y);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.65e+109], 100.0, If[Or[LessEqual[x, -0.00018], And[N[Not[LessEqual[x, -4.6e-108]], $MachinePrecision], LessEqual[x, 1.06e+53]]], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 100.0]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -0.00018 \lor \neg \left(x \leq -4.6 \cdot 10^{-108}\right) \land x \leq 1.06 \cdot 10^{+53}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.6499999999999999e109 or -1.80000000000000011e-4 < x < -4.59999999999999992e-108 or 1.05999999999999999e53 < x

    1. Initial program 99.0%

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

        \[\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. Add Preprocessing
    5. Taylor expanded in y around 0 82.7%

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

    if -1.6499999999999999e109 < x < -1.80000000000000011e-4 or -4.59999999999999992e-108 < x < 1.05999999999999999e53

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{+109}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -0.00018 \lor \neg \left(x \leq -4.6 \cdot 10^{-108}\right) \land x \leq 1.06 \cdot 10^{+53}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 71.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{+109}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -0.02:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-108}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+53}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.85e+109)
   100.0
   (if (<= x -0.02)
     (* 100.0 (/ x y))
     (if (<= x -4.8e-108)
       100.0
       (if (<= x 1.15e+53) (/ 100.0 (/ y x)) 100.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.85e+109) {
		tmp = 100.0;
	} else if (x <= -0.02) {
		tmp = 100.0 * (x / y);
	} else if (x <= -4.8e-108) {
		tmp = 100.0;
	} else if (x <= 1.15e+53) {
		tmp = 100.0 / (y / x);
	} 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.85d+109)) then
        tmp = 100.0d0
    else if (x <= (-0.02d0)) then
        tmp = 100.0d0 * (x / y)
    else if (x <= (-4.8d-108)) then
        tmp = 100.0d0
    else if (x <= 1.15d+53) then
        tmp = 100.0d0 / (y / x)
    else
        tmp = 100.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.85e+109) {
		tmp = 100.0;
	} else if (x <= -0.02) {
		tmp = 100.0 * (x / y);
	} else if (x <= -4.8e-108) {
		tmp = 100.0;
	} else if (x <= 1.15e+53) {
		tmp = 100.0 / (y / x);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.85e+109:
		tmp = 100.0
	elif x <= -0.02:
		tmp = 100.0 * (x / y)
	elif x <= -4.8e-108:
		tmp = 100.0
	elif x <= 1.15e+53:
		tmp = 100.0 / (y / x)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.85e+109)
		tmp = 100.0;
	elseif (x <= -0.02)
		tmp = Float64(100.0 * Float64(x / y));
	elseif (x <= -4.8e-108)
		tmp = 100.0;
	elseif (x <= 1.15e+53)
		tmp = Float64(100.0 / Float64(y / x));
	else
		tmp = 100.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.85e+109)
		tmp = 100.0;
	elseif (x <= -0.02)
		tmp = 100.0 * (x / y);
	elseif (x <= -4.8e-108)
		tmp = 100.0;
	elseif (x <= 1.15e+53)
		tmp = 100.0 / (y / x);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.85e+109], 100.0, If[LessEqual[x, -0.02], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.8e-108], 100.0, If[LessEqual[x, 1.15e+53], N[(100.0 / N[(y / x), $MachinePrecision]), $MachinePrecision], 100.0]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -0.02:\\
\;\;\;\;100 \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq -4.8 \cdot 10^{-108}:\\
\;\;\;\;100\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{+53}:\\
\;\;\;\;\frac{100}{\frac{y}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.8500000000000001e109 or -0.0200000000000000004 < x < -4.80000000000000034e-108 or 1.1500000000000001e53 < x

    1. Initial program 99.0%

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

        \[\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. Add Preprocessing
    5. Taylor expanded in y around 0 82.7%

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

    if -1.8500000000000001e109 < x < -0.0200000000000000004

    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*99.8%

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

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

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

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

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

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

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

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

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

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

    if -4.80000000000000034e-108 < x < 1.1500000000000001e53

    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*99.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{100 \cdot x}{y}} \]
      2. *-commutative82.8%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{100}}} \]
    7. Simplified82.7%

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

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

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

        \[\leadsto \color{blue}{\frac{100}{\frac{y}{x}}} \]
    10. Simplified82.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{+109}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -0.02:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-108}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+53}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 72.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+111}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -0.16:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-108}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+53}:\\ \;\;\;\;\frac{100 \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -2.5e+111)
   100.0
   (if (<= x -0.16)
     (* 100.0 (/ x y))
     (if (<= x -6.2e-108) 100.0 (if (<= x 1.5e+53) (/ (* 100.0 x) y) 100.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -2.5e+111) {
		tmp = 100.0;
	} else if (x <= -0.16) {
		tmp = 100.0 * (x / y);
	} else if (x <= -6.2e-108) {
		tmp = 100.0;
	} else if (x <= 1.5e+53) {
		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 <= (-2.5d+111)) then
        tmp = 100.0d0
    else if (x <= (-0.16d0)) then
        tmp = 100.0d0 * (x / y)
    else if (x <= (-6.2d-108)) then
        tmp = 100.0d0
    else if (x <= 1.5d+53) 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 <= -2.5e+111) {
		tmp = 100.0;
	} else if (x <= -0.16) {
		tmp = 100.0 * (x / y);
	} else if (x <= -6.2e-108) {
		tmp = 100.0;
	} else if (x <= 1.5e+53) {
		tmp = (100.0 * x) / y;
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -2.5e+111:
		tmp = 100.0
	elif x <= -0.16:
		tmp = 100.0 * (x / y)
	elif x <= -6.2e-108:
		tmp = 100.0
	elif x <= 1.5e+53:
		tmp = (100.0 * x) / y
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -2.5e+111)
		tmp = 100.0;
	elseif (x <= -0.16)
		tmp = Float64(100.0 * Float64(x / y));
	elseif (x <= -6.2e-108)
		tmp = 100.0;
	elseif (x <= 1.5e+53)
		tmp = Float64(Float64(100.0 * x) / y);
	else
		tmp = 100.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -2.5e+111)
		tmp = 100.0;
	elseif (x <= -0.16)
		tmp = 100.0 * (x / y);
	elseif (x <= -6.2e-108)
		tmp = 100.0;
	elseif (x <= 1.5e+53)
		tmp = (100.0 * x) / y;
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -2.5e+111], 100.0, If[LessEqual[x, -0.16], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6.2e-108], 100.0, If[LessEqual[x, 1.5e+53], N[(N[(100.0 * x), $MachinePrecision] / y), $MachinePrecision], 100.0]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -0.16:\\
\;\;\;\;100 \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq -6.2 \cdot 10^{-108}:\\
\;\;\;\;100\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{+53}:\\
\;\;\;\;\frac{100 \cdot x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.4999999999999998e111 or -0.160000000000000003 < x < -6.20000000000000028e-108 or 1.49999999999999999e53 < x

    1. Initial program 99.0%

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

        \[\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. Add Preprocessing
    5. Taylor expanded in y around 0 82.7%

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

    if -2.4999999999999998e111 < x < -0.160000000000000003

    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*99.8%

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

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

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

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

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

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

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

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

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

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

    if -6.20000000000000028e-108 < x < 1.49999999999999999e53

    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*99.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{100 \cdot x}{y}} \]
    7. Applied egg-rr82.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+111}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -0.16:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-108}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+53}:\\ \;\;\;\;\frac{100 \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 50.7% 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*99.8%

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

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

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

      \[\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. Add Preprocessing
  5. Taylor expanded in y around 0 51.3%

    \[\leadsto \color{blue}{100} \]
  6. Final simplification51.3%

    \[\leadsto 100 \]
  7. Add Preprocessing

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 2024020 
(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)))