Development.Shake.Progress:message from shake-0.15.5

Percentage Accurate: 99.3% → 99.7%
Time: 3.3s
Alternatives: 7
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 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 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.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+112} \lor \neg \left(y \leq -1.65 \cdot 10^{+39} \lor \neg \left(y \leq -4.5 \cdot 10^{-64}\right) \land \left(y \leq 4.1 \cdot 10^{-12} \lor \neg \left(y \leq 3.3 \cdot 10^{+26}\right) \land y \leq 5.6 \cdot 10^{+53}\right)\right):\\
\;\;\;\;100 \cdot \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.99999999999999994e112 or -1.6500000000000001e39 < y < -4.5000000000000001e-64 or 4.0999999999999999e-12 < y < 3.29999999999999993e26 or 5.6e53 < y

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

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

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

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

    if -6.99999999999999994e112 < y < -1.6500000000000001e39 or -4.5000000000000001e-64 < y < 4.0999999999999999e-12 or 3.29999999999999993e26 < y < 5.6e53

    1. Initial program 98.3%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7 \cdot 10^{+112} \lor \neg \left(y \leq -1.65 \cdot 10^{+39} \lor \neg \left(y \leq -4.5 \cdot 10^{-64}\right) \land \left(y \leq 4.1 \cdot 10^{-12} \lor \neg \left(y \leq 3.3 \cdot 10^{+26}\right) \land y \leq 5.6 \cdot 10^{+53}\right)\right):\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;100\\ \end{array} \]

Alternative 3: 72.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 100 \cdot \frac{x}{y}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.1 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-12}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+19}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{+57}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (* 100.0 (/ x y))))
   (if (<= y -4.6e+108)
     t_0
     (if (<= y -2.1e+38)
       100.0
       (if (<= y -4e-63)
         t_0
         (if (<= y 4.2e-12)
           100.0
           (if (<= y 7.2e+19)
             (/ 100.0 (/ y x))
             (if (<= y 1.46e+57) 100.0 t_0))))))))
double code(double x, double y) {
	double t_0 = 100.0 * (x / y);
	double tmp;
	if (y <= -4.6e+108) {
		tmp = t_0;
	} else if (y <= -2.1e+38) {
		tmp = 100.0;
	} else if (y <= -4e-63) {
		tmp = t_0;
	} else if (y <= 4.2e-12) {
		tmp = 100.0;
	} else if (y <= 7.2e+19) {
		tmp = 100.0 / (y / x);
	} else if (y <= 1.46e+57) {
		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 = 100.0d0 * (x / y)
    if (y <= (-4.6d+108)) then
        tmp = t_0
    else if (y <= (-2.1d+38)) then
        tmp = 100.0d0
    else if (y <= (-4d-63)) then
        tmp = t_0
    else if (y <= 4.2d-12) then
        tmp = 100.0d0
    else if (y <= 7.2d+19) then
        tmp = 100.0d0 / (y / x)
    else if (y <= 1.46d+57) 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 = 100.0 * (x / y);
	double tmp;
	if (y <= -4.6e+108) {
		tmp = t_0;
	} else if (y <= -2.1e+38) {
		tmp = 100.0;
	} else if (y <= -4e-63) {
		tmp = t_0;
	} else if (y <= 4.2e-12) {
		tmp = 100.0;
	} else if (y <= 7.2e+19) {
		tmp = 100.0 / (y / x);
	} else if (y <= 1.46e+57) {
		tmp = 100.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = 100.0 * (x / y)
	tmp = 0
	if y <= -4.6e+108:
		tmp = t_0
	elif y <= -2.1e+38:
		tmp = 100.0
	elif y <= -4e-63:
		tmp = t_0
	elif y <= 4.2e-12:
		tmp = 100.0
	elif y <= 7.2e+19:
		tmp = 100.0 / (y / x)
	elif y <= 1.46e+57:
		tmp = 100.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(100.0 * Float64(x / y))
	tmp = 0.0
	if (y <= -4.6e+108)
		tmp = t_0;
	elseif (y <= -2.1e+38)
		tmp = 100.0;
	elseif (y <= -4e-63)
		tmp = t_0;
	elseif (y <= 4.2e-12)
		tmp = 100.0;
	elseif (y <= 7.2e+19)
		tmp = Float64(100.0 / Float64(y / x));
	elseif (y <= 1.46e+57)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = 100.0 * (x / y);
	tmp = 0.0;
	if (y <= -4.6e+108)
		tmp = t_0;
	elseif (y <= -2.1e+38)
		tmp = 100.0;
	elseif (y <= -4e-63)
		tmp = t_0;
	elseif (y <= 4.2e-12)
		tmp = 100.0;
	elseif (y <= 7.2e+19)
		tmp = 100.0 / (y / x);
	elseif (y <= 1.46e+57)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+108], t$95$0, If[LessEqual[y, -2.1e+38], 100.0, If[LessEqual[y, -4e-63], t$95$0, If[LessEqual[y, 4.2e-12], 100.0, If[LessEqual[y, 7.2e+19], N[(100.0 / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.46e+57], 100.0, t$95$0]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -4 \cdot 10^{-63}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{-12}:\\
\;\;\;\;100\\

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

\mathbf{elif}\;y \leq 1.46 \cdot 10^{+57}:\\
\;\;\;\;100\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.5999999999999998e108 or -2.1e38 < y < -4.00000000000000027e-63 or 1.46e57 < y

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

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

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

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

    if -4.5999999999999998e108 < y < -2.1e38 or -4.00000000000000027e-63 < y < 4.19999999999999988e-12 or 7.2e19 < y < 1.46e57

    1. Initial program 98.3%

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

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

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

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

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

    if 4.19999999999999988e-12 < y < 7.2e19

    1. Initial program 98.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -2.1 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-63}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-12}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+19}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 1.46 \cdot 10^{+57}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \end{array} \]

Alternative 4: 72.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{y \cdot 0.01}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-14}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+25}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+53}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ x (* y 0.01))))
   (if (<= y -4.6e+108)
     (* 100.0 (/ x y))
     (if (<= y -5.8e+38)
       100.0
       (if (<= y -3.9e-63)
         t_0
         (if (<= y 4e-14)
           100.0
           (if (<= y 1.15e+25)
             (/ 100.0 (/ y x))
             (if (<= y 5.4e+53) 100.0 t_0))))))))
double code(double x, double y) {
	double t_0 = x / (y * 0.01);
	double tmp;
	if (y <= -4.6e+108) {
		tmp = 100.0 * (x / y);
	} else if (y <= -5.8e+38) {
		tmp = 100.0;
	} else if (y <= -3.9e-63) {
		tmp = t_0;
	} else if (y <= 4e-14) {
		tmp = 100.0;
	} else if (y <= 1.15e+25) {
		tmp = 100.0 / (y / x);
	} else if (y <= 5.4e+53) {
		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 / (y * 0.01d0)
    if (y <= (-4.6d+108)) then
        tmp = 100.0d0 * (x / y)
    else if (y <= (-5.8d+38)) then
        tmp = 100.0d0
    else if (y <= (-3.9d-63)) then
        tmp = t_0
    else if (y <= 4d-14) then
        tmp = 100.0d0
    else if (y <= 1.15d+25) then
        tmp = 100.0d0 / (y / x)
    else if (y <= 5.4d+53) 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 / (y * 0.01);
	double tmp;
	if (y <= -4.6e+108) {
		tmp = 100.0 * (x / y);
	} else if (y <= -5.8e+38) {
		tmp = 100.0;
	} else if (y <= -3.9e-63) {
		tmp = t_0;
	} else if (y <= 4e-14) {
		tmp = 100.0;
	} else if (y <= 1.15e+25) {
		tmp = 100.0 / (y / x);
	} else if (y <= 5.4e+53) {
		tmp = 100.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = x / (y * 0.01)
	tmp = 0
	if y <= -4.6e+108:
		tmp = 100.0 * (x / y)
	elif y <= -5.8e+38:
		tmp = 100.0
	elif y <= -3.9e-63:
		tmp = t_0
	elif y <= 4e-14:
		tmp = 100.0
	elif y <= 1.15e+25:
		tmp = 100.0 / (y / x)
	elif y <= 5.4e+53:
		tmp = 100.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(x / Float64(y * 0.01))
	tmp = 0.0
	if (y <= -4.6e+108)
		tmp = Float64(100.0 * Float64(x / y));
	elseif (y <= -5.8e+38)
		tmp = 100.0;
	elseif (y <= -3.9e-63)
		tmp = t_0;
	elseif (y <= 4e-14)
		tmp = 100.0;
	elseif (y <= 1.15e+25)
		tmp = Float64(100.0 / Float64(y / x));
	elseif (y <= 5.4e+53)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = x / (y * 0.01);
	tmp = 0.0;
	if (y <= -4.6e+108)
		tmp = 100.0 * (x / y);
	elseif (y <= -5.8e+38)
		tmp = 100.0;
	elseif (y <= -3.9e-63)
		tmp = t_0;
	elseif (y <= 4e-14)
		tmp = 100.0;
	elseif (y <= 1.15e+25)
		tmp = 100.0 / (y / x);
	elseif (y <= 5.4e+53)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * 0.01), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+108], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.8e+38], 100.0, If[LessEqual[y, -3.9e-63], t$95$0, If[LessEqual[y, 4e-14], 100.0, If[LessEqual[y, 1.15e+25], N[(100.0 / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.4e+53], 100.0, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x}{y \cdot 0.01}\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\

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

\mathbf{elif}\;y \leq -3.9 \cdot 10^{-63}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 4 \cdot 10^{-14}:\\
\;\;\;\;100\\

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

\mathbf{elif}\;y \leq 5.4 \cdot 10^{+53}:\\
\;\;\;\;100\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.5999999999999998e108

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

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

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

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

    if -4.5999999999999998e108 < y < -5.80000000000000013e38 or -3.90000000000000022e-63 < y < 4e-14 or 1.1499999999999999e25 < y < 5.40000000000000039e53

    1. Initial program 98.3%

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

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

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

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

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

    if -5.80000000000000013e38 < y < -3.90000000000000022e-63 or 5.40000000000000039e53 < y

    1. Initial program 99.7%

      \[\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. Taylor expanded in x around 0 75.3%

      \[\leadsto \frac{x}{\color{blue}{0.01 \cdot y}} \]
    5. Step-by-step derivation
      1. *-commutative75.3%

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

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

    if 4e-14 < y < 1.1499999999999999e25

    1. Initial program 98.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\ \;\;\;\;100 \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-63}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-14}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+25}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+53}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \end{array} \]

Alternative 5: 72.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{x}{0.01}}{y}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-64}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-14}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 7.7 \cdot 10^{+28}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+55}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ (/ x 0.01) y)))
   (if (<= y -4.6e+108)
     t_0
     (if (<= y -4.6e+38)
       100.0
       (if (<= y -4.8e-64)
         (/ x (* y 0.01))
         (if (<= y 4e-14)
           100.0
           (if (<= y 7.7e+28)
             (/ 100.0 (/ y x))
             (if (<= y 4.2e+55) 100.0 t_0))))))))
double code(double x, double y) {
	double t_0 = (x / 0.01) / y;
	double tmp;
	if (y <= -4.6e+108) {
		tmp = t_0;
	} else if (y <= -4.6e+38) {
		tmp = 100.0;
	} else if (y <= -4.8e-64) {
		tmp = x / (y * 0.01);
	} else if (y <= 4e-14) {
		tmp = 100.0;
	} else if (y <= 7.7e+28) {
		tmp = 100.0 / (y / x);
	} else if (y <= 4.2e+55) {
		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 / 0.01d0) / y
    if (y <= (-4.6d+108)) then
        tmp = t_0
    else if (y <= (-4.6d+38)) then
        tmp = 100.0d0
    else if (y <= (-4.8d-64)) then
        tmp = x / (y * 0.01d0)
    else if (y <= 4d-14) then
        tmp = 100.0d0
    else if (y <= 7.7d+28) then
        tmp = 100.0d0 / (y / x)
    else if (y <= 4.2d+55) 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 / 0.01) / y;
	double tmp;
	if (y <= -4.6e+108) {
		tmp = t_0;
	} else if (y <= -4.6e+38) {
		tmp = 100.0;
	} else if (y <= -4.8e-64) {
		tmp = x / (y * 0.01);
	} else if (y <= 4e-14) {
		tmp = 100.0;
	} else if (y <= 7.7e+28) {
		tmp = 100.0 / (y / x);
	} else if (y <= 4.2e+55) {
		tmp = 100.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y):
	t_0 = (x / 0.01) / y
	tmp = 0
	if y <= -4.6e+108:
		tmp = t_0
	elif y <= -4.6e+38:
		tmp = 100.0
	elif y <= -4.8e-64:
		tmp = x / (y * 0.01)
	elif y <= 4e-14:
		tmp = 100.0
	elif y <= 7.7e+28:
		tmp = 100.0 / (y / x)
	elif y <= 4.2e+55:
		tmp = 100.0
	else:
		tmp = t_0
	return tmp
function code(x, y)
	t_0 = Float64(Float64(x / 0.01) / y)
	tmp = 0.0
	if (y <= -4.6e+108)
		tmp = t_0;
	elseif (y <= -4.6e+38)
		tmp = 100.0;
	elseif (y <= -4.8e-64)
		tmp = Float64(x / Float64(y * 0.01));
	elseif (y <= 4e-14)
		tmp = 100.0;
	elseif (y <= 7.7e+28)
		tmp = Float64(100.0 / Float64(y / x));
	elseif (y <= 4.2e+55)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y)
	t_0 = (x / 0.01) / y;
	tmp = 0.0;
	if (y <= -4.6e+108)
		tmp = t_0;
	elseif (y <= -4.6e+38)
		tmp = 100.0;
	elseif (y <= -4.8e-64)
		tmp = x / (y * 0.01);
	elseif (y <= 4e-14)
		tmp = 100.0;
	elseif (y <= 7.7e+28)
		tmp = 100.0 / (y / x);
	elseif (y <= 4.2e+55)
		tmp = 100.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := Block[{t$95$0 = N[(N[(x / 0.01), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -4.6e+108], t$95$0, If[LessEqual[y, -4.6e+38], 100.0, If[LessEqual[y, -4.8e-64], N[(x / N[(y * 0.01), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e-14], 100.0, If[LessEqual[y, 7.7e+28], N[(100.0 / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.2e+55], 100.0, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\frac{x}{0.01}}{y}\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq -4.8 \cdot 10^{-64}:\\
\;\;\;\;\frac{x}{y \cdot 0.01}\\

\mathbf{elif}\;y \leq 4 \cdot 10^{-14}:\\
\;\;\;\;100\\

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

\mathbf{elif}\;y \leq 4.2 \cdot 10^{+55}:\\
\;\;\;\;100\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.5999999999999998e108 or 4.2000000000000001e55 < y

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot x}{0.01 \cdot y}} \]
      3. *-un-lft-identity84.6%

        \[\leadsto \frac{\color{blue}{x}}{0.01 \cdot y} \]
      4. associate-/r*84.8%

        \[\leadsto \color{blue}{\frac{\frac{x}{0.01}}{y}} \]
    6. Applied egg-rr84.8%

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

    if -4.5999999999999998e108 < y < -4.6000000000000002e38 or -4.79999999999999997e-64 < y < 4e-14 or 7.6999999999999997e28 < y < 4.2000000000000001e55

    1. Initial program 98.3%

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

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

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

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

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

    if -4.6000000000000002e38 < y < -4.79999999999999997e-64

    1. Initial program 99.8%

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

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

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

      \[\leadsto \frac{x}{\color{blue}{0.01 \cdot y}} \]
    5. Step-by-step derivation
      1. *-commutative64.4%

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

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

    if 4e-14 < y < 7.6999999999999997e28

    1. Initial program 98.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+108}:\\ \;\;\;\;\frac{\frac{x}{0.01}}{y}\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{+38}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-64}:\\ \;\;\;\;\frac{x}{y \cdot 0.01}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-14}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 7.7 \cdot 10^{+28}:\\ \;\;\;\;\frac{100}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+55}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{0.01}}{y}\\ \end{array} \]

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

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

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

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

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

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

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

Alternative 7: 51.0% 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{\color{blue}{100 \cdot x}}{x + y} \]
    2. associate-/l*99.3%

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

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

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

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