Development.Shake.Progress:message from shake-0.15.5

Percentage Accurate: 99.3% → 99.7%
Time: 4.2s
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.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.7% accurate, 1.0× speedup?

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

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

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

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

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

    \[\leadsto \frac{x}{\frac{x + y}{100}} \]

Alternative 2: 72.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-120} \lor \neg \left(y \leq 3.9 \cdot 10^{+37}\right) \land \left(y \leq 4.4 \cdot 10^{+102} \lor \neg \left(y \leq 3.8 \cdot 10^{+142}\right)\right):\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -2.7e-120)
         (and (not (<= y 3.9e+37)) (or (<= y 4.4e+102) (not (<= y 3.8e+142)))))
   (* x (/ 100.0 y))
   100.0))
double code(double x, double y) {
	double tmp;
	if ((y <= -2.7e-120) || (!(y <= 3.9e+37) && ((y <= 4.4e+102) || !(y <= 3.8e+142)))) {
		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 ((y <= (-2.7d-120)) .or. (.not. (y <= 3.9d+37)) .and. (y <= 4.4d+102) .or. (.not. (y <= 3.8d+142))) 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 ((y <= -2.7e-120) || (!(y <= 3.9e+37) && ((y <= 4.4e+102) || !(y <= 3.8e+142)))) {
		tmp = x * (100.0 / y);
	} else {
		tmp = 100.0;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -2.7e-120) or (not (y <= 3.9e+37) and ((y <= 4.4e+102) or not (y <= 3.8e+142))):
		tmp = x * (100.0 / y)
	else:
		tmp = 100.0
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -2.7e-120) || (!(y <= 3.9e+37) && ((y <= 4.4e+102) || !(y <= 3.8e+142))))
		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 ((y <= -2.7e-120) || (~((y <= 3.9e+37)) && ((y <= 4.4e+102) || ~((y <= 3.8e+142)))))
		tmp = x * (100.0 / y);
	else
		tmp = 100.0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -2.7e-120], And[N[Not[LessEqual[y, 3.9e+37]], $MachinePrecision], Or[LessEqual[y, 4.4e+102], N[Not[LessEqual[y, 3.8e+142]], $MachinePrecision]]]], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-120} \lor \neg \left(y \leq 3.9 \cdot 10^{+37}\right) \land \left(y \leq 4.4 \cdot 10^{+102} \lor \neg \left(y \leq 3.8 \cdot 10^{+142}\right)\right):\\
\;\;\;\;x \cdot \frac{100}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.6999999999999999e-120 or 3.8999999999999999e37 < y < 4.40000000000000015e102 or 3.7999999999999999e142 < y

    1. Initial program 99.1%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{x + y}{100}}} \]
    4. Step-by-step derivation
      1. clear-num98.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{x + y}{100}}{x}}} \]
      2. associate-/r/99.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{x + y}{100}} \cdot x} \]
      3. clear-num99.7%

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

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

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

    if -2.6999999999999999e-120 < y < 3.8999999999999999e37 or 4.40000000000000015e102 < y < 3.7999999999999999e142

    1. Initial program 99.0%

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

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

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

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

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

      \[\leadsto \color{blue}{100} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification78.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-120} \lor \neg \left(y \leq 3.9 \cdot 10^{+37}\right) \land \left(y \leq 4.4 \cdot 10^{+102} \lor \neg \left(y \leq 3.8 \cdot 10^{+142}\right)\right):\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]

Alternative 3: 72.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{100}{y}\\ \mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+45}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+101}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* x (/ 100.0 y))))
   (if (<= y -2.7e-120)
     t_0
     (if (<= y 2.4e+45)
       100.0
       (if (<= y 3.2e+101)
         (* 100.0 (/ x y))
         (if (<= y 2.6e+142) 100.0 t_0))))))
double code(double x, double y) {
	double t_0 = x * (100.0 / y);
	double tmp;
	if (y <= -2.7e-120) {
		tmp = t_0;
	} else if (y <= 2.4e+45) {
		tmp = 100.0;
	} else if (y <= 3.2e+101) {
		tmp = 100.0 * (x / y);
	} else if (y <= 2.6e+142) {
		tmp = 100.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (100.0d0 / y)
    if (y <= (-2.7d-120)) then
        tmp = t_0
    else if (y <= 2.4d+45) then
        tmp = 100.0d0
    else if (y <= 3.2d+101) then
        tmp = 100.0d0 * (x / y)
    else if (y <= 2.6d+142) then
        tmp = 100.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double t_0 = x * (100.0 / y);
	double tmp;
	if (y <= -2.7e-120) {
		tmp = t_0;
	} else if (y <= 2.4e+45) {
		tmp = 100.0;
	} else if (y <= 3.2e+101) {
		tmp = 100.0 * (x / y);
	} else if (y <= 2.6e+142) {
		tmp = 100.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x * (100.0 / y)
	tmp = 0
	if y <= -2.7e-120:
		tmp = t_0
	elif y <= 2.4e+45:
		tmp = 100.0
	elif y <= 3.2e+101:
		tmp = 100.0 * (x / y)
	elif y <= 2.6e+142:
		tmp = 100.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x * Float64(100.0 / y))
	tmp = 0.0
	if (y <= -2.7e-120)
		tmp = t_0;
	elseif (y <= 2.4e+45)
		tmp = 100.0;
	elseif (y <= 3.2e+101)
		tmp = Float64(100.0 * Float64(x / y));
	elseif (y <= 2.6e+142)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x * (100.0 / y);
	tmp = 0.0;
	if (y <= -2.7e-120)
		tmp = t_0;
	elseif (y <= 2.4e+45)
		tmp = 100.0;
	elseif (y <= 3.2e+101)
		tmp = 100.0 * (x / y);
	elseif (y <= 2.6e+142)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.7e-120], t$95$0, If[LessEqual[y, 2.4e+45], 100.0, If[LessEqual[y, 3.2e+101], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+142], 100.0, t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{100}{y}\\
\mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 2.4 \cdot 10^{+45}:\\
\;\;\;\;100\\

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

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\
\;\;\;\;100\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.6999999999999999e-120 or 2.60000000000000021e142 < y

    1. Initial program 99.0%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{x + y}{100}}} \]
    4. Step-by-step derivation
      1. clear-num98.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{x + y}{100}}{x}}} \]
      2. associate-/r/99.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{x + y}{100}} \cdot x} \]
      3. clear-num99.7%

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

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

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

    if -2.6999999999999999e-120 < y < 2.39999999999999989e45 or 3.20000000000000005e101 < y < 2.60000000000000021e142

    1. Initial program 99.0%

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

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

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

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

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

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

    if 2.39999999999999989e45 < y < 3.20000000000000005e101

    1. Initial program 100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+45}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+101}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \end{array} \]

Alternative 4: 72.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+101}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 100}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (<= y -2.7e-120)
   (* x (/ 100.0 y))
   (if (<= y 6.5e+38)
     100.0
     (if (<= y 3.4e+101)
       (* 100.0 (/ x y))
       (if (<= y 2.6e+142) 100.0 (/ (* x 100.0) y))))))
double code(double x, double y) {
	double tmp;
	if (y <= -2.7e-120) {
		tmp = x * (100.0 / y);
	} else if (y <= 6.5e+38) {
		tmp = 100.0;
	} else if (y <= 3.4e+101) {
		tmp = 100.0 * (x / y);
	} else if (y <= 2.6e+142) {
		tmp = 100.0;
	} else {
		tmp = (x * 100.0) / y;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if (y <= (-2.7d-120)) then
        tmp = x * (100.0d0 / y)
    else if (y <= 6.5d+38) then
        tmp = 100.0d0
    else if (y <= 3.4d+101) then
        tmp = 100.0d0 * (x / y)
    else if (y <= 2.6d+142) then
        tmp = 100.0d0
    else
        tmp = (x * 100.0d0) / y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if (y <= -2.7e-120) {
		tmp = x * (100.0 / y);
	} else if (y <= 6.5e+38) {
		tmp = 100.0;
	} else if (y <= 3.4e+101) {
		tmp = 100.0 * (x / y);
	} else if (y <= 2.6e+142) {
		tmp = 100.0;
	} else {
		tmp = (x * 100.0) / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if y <= -2.7e-120:
		tmp = x * (100.0 / y)
	elif y <= 6.5e+38:
		tmp = 100.0
	elif y <= 3.4e+101:
		tmp = 100.0 * (x / y)
	elif y <= 2.6e+142:
		tmp = 100.0
	else:
		tmp = (x * 100.0) / y
	return tmp
function code(x, y)
	tmp = 0.0
	if (y <= -2.7e-120)
		tmp = Float64(x * Float64(100.0 / y));
	elseif (y <= 6.5e+38)
		tmp = 100.0;
	elseif (y <= 3.4e+101)
		tmp = Float64(100.0 * Float64(x / y));
	elseif (y <= 2.6e+142)
		tmp = 100.0;
	else
		tmp = Float64(Float64(x * 100.0) / y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if (y <= -2.7e-120)
		tmp = x * (100.0 / y);
	elseif (y <= 6.5e+38)
		tmp = 100.0;
	elseif (y <= 3.4e+101)
		tmp = 100.0 * (x / y);
	elseif (y <= 2.6e+142)
		tmp = 100.0;
	else
		tmp = (x * 100.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[LessEqual[y, -2.7e-120], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.5e+38], 100.0, If[LessEqual[y, 3.4e+101], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+142], 100.0, N[(N[(x * 100.0), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\
\;\;\;\;x \cdot \frac{100}{y}\\

\mathbf{elif}\;y \leq 6.5 \cdot 10^{+38}:\\
\;\;\;\;100\\

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

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\
\;\;\;\;100\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 100}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.6999999999999999e-120

    1. Initial program 98.6%

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{x + y}{100}}} \]
    4. Step-by-step derivation
      1. clear-num97.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{x + y}{100}}{x}}} \]
      2. associate-/r/99.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{x + y}{100}} \cdot x} \]
      3. clear-num99.7%

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

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

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

    if -2.6999999999999999e-120 < y < 6.5e38 or 3.40000000000000017e101 < y < 2.60000000000000021e142

    1. Initial program 99.0%

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

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

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

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

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

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

    if 6.5e38 < y < 3.40000000000000017e101

    1. Initial program 100.0%

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

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

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

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

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

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

    if 2.60000000000000021e142 < y

    1. Initial program 99.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{100 \cdot x}{y}} \]
    6. Simplified94.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\ \;\;\;\;x \cdot \frac{100}{y}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+101}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 100}{y}\\ \end{array} \]

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

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

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

    \[\leadsto \color{blue}{\frac{x}{\frac{x + y}{100}}} \]
  4. Step-by-step derivation
    1. clear-num99.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{x + y}{100}}{x}}} \]
    2. associate-/r/99.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{x + y}{100}} \cdot x} \]
    3. clear-num99.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{100} \]
  5. Final simplification47.3%

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