Development.Shake.Progress:message from shake-0.15.5

Percentage Accurate: 99.4% → 99.7%
Time: 5.8s
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.4% 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} \\ x \cdot \frac{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(x * Float64(100.0 / Float64(x + y)))
end
function tmp = code(x, y)
	tmp = x * (100.0 / (x + y));
end
code[x_, y_] := N[(x * N[(100.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\frac{x \cdot 100}{x + y} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/l*99.8%

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

      \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
  4. Applied egg-rr99.8%

    \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
  5. Final simplification99.8%

    \[\leadsto x \cdot \frac{100}{x + y} \]
  6. Add Preprocessing

Alternative 2: 75.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;x \leq -1.05 \cdot 10^{+36} \lor \neg \left(x \leq -16500000000\right) \land x \leq 5.8 \cdot 10^{+51}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.20000000000000019e64 or -1.05000000000000002e36 < x < -1.65e10 or 5.7999999999999997e51 < x

    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.9%

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

      \[\leadsto \color{blue}{100 \cdot \frac{x}{x + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 86.7%

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

    if -3.20000000000000019e64 < x < -1.05000000000000002e36 or -1.65e10 < x < 5.7999999999999997e51

    1. Initial program 99.6%

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

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

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

      \[\leadsto \color{blue}{100 \cdot \frac{x}{x + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 80.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+64}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{+36} \lor \neg \left(x \leq -16500000000\right) \land x \leq 5.8 \cdot 10^{+51}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+64}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -2.95 \cdot 10^{+39}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -15500000000:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+54}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -5e+64)
   100.0
   (if (<= x -2.95e+39)
     (* 100.0 (/ x y))
     (if (<= x -15500000000.0)
       100.0
       (if (<= x 2.2e+54) (* x (/ 100.0 y)) 100.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -5e+64) {
		tmp = 100.0;
	} else if (x <= -2.95e+39) {
		tmp = 100.0 * (x / y);
	} else if (x <= -15500000000.0) {
		tmp = 100.0;
	} else if (x <= 2.2e+54) {
		tmp = x * (100.0 / 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 <= (-5d+64)) then
        tmp = 100.0d0
    else if (x <= (-2.95d+39)) then
        tmp = 100.0d0 * (x / y)
    else if (x <= (-15500000000.0d0)) then
        tmp = 100.0d0
    else if (x <= 2.2d+54) then
        tmp = x * (100.0d0 / y)
    else
        tmp = 100.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -5e+64) {
		tmp = 100.0;
	} else if (x <= -2.95e+39) {
		tmp = 100.0 * (x / y);
	} else if (x <= -15500000000.0) {
		tmp = 100.0;
	} else if (x <= 2.2e+54) {
		tmp = x * (100.0 / y);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -5e+64:
		tmp = 100.0
	elif x <= -2.95e+39:
		tmp = 100.0 * (x / y)
	elif x <= -15500000000.0:
		tmp = 100.0
	elif x <= 2.2e+54:
		tmp = x * (100.0 / y)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -5e+64)
		tmp = 100.0;
	elseif (x <= -2.95e+39)
		tmp = Float64(100.0 * Float64(x / y));
	elseif (x <= -15500000000.0)
		tmp = 100.0;
	elseif (x <= 2.2e+54)
		tmp = Float64(x * Float64(100.0 / y));
	else
		tmp = 100.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -5e+64)
		tmp = 100.0;
	elseif (x <= -2.95e+39)
		tmp = 100.0 * (x / y);
	elseif (x <= -15500000000.0)
		tmp = 100.0;
	elseif (x <= 2.2e+54)
		tmp = x * (100.0 / y);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -5e+64], 100.0, If[LessEqual[x, -2.95e+39], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -15500000000.0], 100.0, If[LessEqual[x, 2.2e+54], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2.95 \cdot 10^{+39}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\

\mathbf{elif}\;x \leq -15500000000:\\
\;\;\;\;100\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5e64 or -2.94999999999999983e39 < x < -1.55e10 or 2.1999999999999999e54 < x

    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.9%

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

      \[\leadsto \color{blue}{100 \cdot \frac{x}{x + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 86.7%

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

    if -5e64 < x < -2.94999999999999983e39

    1. Initial program 99.6%

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

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

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

      \[\leadsto \color{blue}{100 \cdot \frac{x}{x + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around 0 86.3%

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

    if -1.55e10 < x < 2.1999999999999999e54

    1. Initial program 99.6%

      \[\frac{x \cdot 100}{x + y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-/l*99.7%

        \[\leadsto \color{blue}{x \cdot \frac{100}{x + y}} \]
      2. *-commutative99.7%

        \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
    5. Taylor expanded in x around 0 80.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{+64}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -2.95 \cdot 10^{+39}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq -15500000000:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+54}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+65}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+32}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq -880000000:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+51}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= x -1.6e+65)
   100.0
   (if (<= x -2e+32)
     (/ 100.0 (/ y x))
     (if (<= x -880000000.0)
       100.0
       (if (<= x 1.5e+51) (* x (/ 100.0 y)) 100.0)))))
double code(double x, double y) {
	double tmp;
	if (x <= -1.6e+65) {
		tmp = 100.0;
	} else if (x <= -2e+32) {
		tmp = 100.0 / (y / x);
	} else if (x <= -880000000.0) {
		tmp = 100.0;
	} else if (x <= 1.5e+51) {
		tmp = x * (100.0 / 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.6d+65)) then
        tmp = 100.0d0
    else if (x <= (-2d+32)) then
        tmp = 100.0d0 / (y / x)
    else if (x <= (-880000000.0d0)) then
        tmp = 100.0d0
    else if (x <= 1.5d+51) then
        tmp = x * (100.0d0 / y)
    else
        tmp = 100.0d0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (x <= -1.6e+65) {
		tmp = 100.0;
	} else if (x <= -2e+32) {
		tmp = 100.0 / (y / x);
	} else if (x <= -880000000.0) {
		tmp = 100.0;
	} else if (x <= 1.5e+51) {
		tmp = x * (100.0 / y);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if x <= -1.6e+65:
		tmp = 100.0
	elif x <= -2e+32:
		tmp = 100.0 / (y / x)
	elif x <= -880000000.0:
		tmp = 100.0
	elif x <= 1.5e+51:
		tmp = x * (100.0 / y)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if (x <= -1.6e+65)
		tmp = 100.0;
	elseif (x <= -2e+32)
		tmp = Float64(100.0 / Float64(y / x));
	elseif (x <= -880000000.0)
		tmp = 100.0;
	elseif (x <= 1.5e+51)
		tmp = Float64(x * Float64(100.0 / y));
	else
		tmp = 100.0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (x <= -1.6e+65)
		tmp = 100.0;
	elseif (x <= -2e+32)
		tmp = 100.0 / (y / x);
	elseif (x <= -880000000.0)
		tmp = 100.0;
	elseif (x <= 1.5e+51)
		tmp = x * (100.0 / y);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[x, -1.6e+65], 100.0, If[LessEqual[x, -2e+32], N[(100.0 / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -880000000.0], 100.0, If[LessEqual[x, 1.5e+51], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -2 \cdot 10^{+32}:\\
\;\;\;\;\frac{100}{\frac{y}{x}}\\

\mathbf{elif}\;x \leq -880000000:\\
\;\;\;\;100\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.60000000000000003e65 or -2.00000000000000011e32 < x < -8.8e8 or 1.5e51 < x

    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.9%

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

      \[\leadsto \color{blue}{100 \cdot \frac{x}{x + y}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 86.7%

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

    if -1.60000000000000003e65 < x < -2.00000000000000011e32

    1. Initial program 99.6%

      \[\frac{x \cdot 100}{x + y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-/l*99.6%

        \[\leadsto \color{blue}{x \cdot \frac{100}{x + y}} \]
      2. *-commutative99.6%

        \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
    4. Applied egg-rr99.6%

      \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
    5. Taylor expanded in x around 0 86.3%

      \[\leadsto \color{blue}{\frac{100}{y}} \cdot x \]
    6. Step-by-step derivation
      1. div-inv86.3%

        \[\leadsto \color{blue}{\left(100 \cdot \frac{1}{y}\right)} \cdot x \]
      2. associate-*l*85.9%

        \[\leadsto \color{blue}{100 \cdot \left(\frac{1}{y} \cdot x\right)} \]
      3. associate-/r/86.3%

        \[\leadsto 100 \cdot \color{blue}{\frac{1}{\frac{y}{x}}} \]
      4. un-div-inv86.7%

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

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

    if -8.8e8 < x < 1.5e51

    1. Initial program 99.6%

      \[\frac{x \cdot 100}{x + y} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-/l*99.7%

        \[\leadsto \color{blue}{x \cdot \frac{100}{x + y}} \]
      2. *-commutative99.7%

        \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{100}{x + y} \cdot x} \]
    5. Taylor expanded in x around 0 80.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+65}:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+32}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq -880000000:\\ \;\;\;\;100\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+51}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.7% accurate, 1.0× speedup?

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

\\
100 \cdot \frac{x}{x + y}
\end{array}
Derivation
  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.7%

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

    \[\leadsto \color{blue}{100 \cdot \frac{x}{x + y}} \]
  4. Add Preprocessing
  5. Final simplification99.7%

    \[\leadsto 100 \cdot \frac{x}{x + y} \]
  6. Add Preprocessing

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

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

    \[\leadsto \color{blue}{100 \cdot \frac{x}{x + y}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 50.6%

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

    \[\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 2024075 
(FPCore (x y)
  :name "Development.Shake.Progress:message from shake-0.15.5"
  :precision binary64

  :alt
  (* (/ x 1.0) (/ 100.0 (+ x y)))

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