Average Error: 0.4 → 11.8
Time: 3.1s
Precision: binary64
\[\frac{x \cdot 100}{x + y} \]
\[\begin{array}{l} t_0 := \frac{100}{x + y}\\ t_1 := x \cdot t_0\\ \mathbf{if}\;y \leq 2.9324058059803696 \cdot 10^{-145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.1419780404580396 \cdot 10^{+122}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 4.404093813874534 \cdot 10^{+150}:\\ \;\;\;\;x \cdot \left|t_0\right|\\ \mathbf{elif}\;y \leq 6.770638945663061 \cdot 10^{+203}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 1.4672009052933056 \cdot 10^{+225}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.0463059399122565 \cdot 10^{+295}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 100\right) \cdot \frac{1}{x + y}\\ \end{array} \]
\frac{x \cdot 100}{x + y}
\begin{array}{l}
t_0 := \frac{100}{x + y}\\
t_1 := x \cdot t_0\\
\mathbf{if}\;y \leq 2.9324058059803696 \cdot 10^{-145}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.1419780404580396 \cdot 10^{+122}:\\
\;\;\;\;100\\

\mathbf{elif}\;y \leq 4.404093813874534 \cdot 10^{+150}:\\
\;\;\;\;x \cdot \left|t_0\right|\\

\mathbf{elif}\;y \leq 6.770638945663061 \cdot 10^{+203}:\\
\;\;\;\;100\\

\mathbf{elif}\;y \leq 1.4672009052933056 \cdot 10^{+225}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 4.0463059399122565 \cdot 10^{+295}:\\
\;\;\;\;100\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 100\right) \cdot \frac{1}{x + y}\\


\end{array}
(FPCore (x y) :precision binary64 (/ (* x 100.0) (+ x y)))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (/ 100.0 (+ x y))) (t_1 (* x t_0)))
   (if (<= y 2.9324058059803696e-145)
     t_1
     (if (<= y 1.1419780404580396e+122)
       100.0
       (if (<= y 4.404093813874534e+150)
         (* x (fabs t_0))
         (if (<= y 6.770638945663061e+203)
           100.0
           (if (<= y 1.4672009052933056e+225)
             t_1
             (if (<= y 4.0463059399122565e+295)
               100.0
               (* (* x 100.0) (/ 1.0 (+ x y)))))))))))
double code(double x, double y) {
	return (x * 100.0) / (x + y);
}
double code(double x, double y) {
	double t_0 = 100.0 / (x + y);
	double t_1 = x * t_0;
	double tmp;
	if (y <= 2.9324058059803696e-145) {
		tmp = t_1;
	} else if (y <= 1.1419780404580396e+122) {
		tmp = 100.0;
	} else if (y <= 4.404093813874534e+150) {
		tmp = x * fabs(t_0);
	} else if (y <= 6.770638945663061e+203) {
		tmp = 100.0;
	} else if (y <= 1.4672009052933056e+225) {
		tmp = t_1;
	} else if (y <= 4.0463059399122565e+295) {
		tmp = 100.0;
	} else {
		tmp = (x * 100.0) * (1.0 / (x + y));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.4
Target0.2
Herbie11.8
\[\frac{x}{1} \cdot \frac{100}{x + y} \]

Derivation

  1. Split input into 4 regimes
  2. if y < 2.9324058059803696e-145 or 6.77063894566306107e203 < y < 1.4672009052933056e225

    1. Initial program 0.4

      \[\frac{x \cdot 100}{x + y} \]
    2. Applied egg-rr0.2

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

    if 2.9324058059803696e-145 < y < 1.1419780404580396e122 or 4.4040938138745338e150 < y < 6.77063894566306107e203 or 1.4672009052933056e225 < y < 4.0463059399122565e295

    1. Initial program 0.3

      \[\frac{x \cdot 100}{x + y} \]
    2. Taylor expanded in x around inf 37.9

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

    if 1.1419780404580396e122 < y < 4.4040938138745338e150

    1. Initial program 0.2

      \[\frac{x \cdot 100}{x + y} \]
    2. Applied egg-rr0.2

      \[\leadsto \color{blue}{x \cdot \frac{100}{x + y}} \]
    3. Applied egg-rr9.5

      \[\leadsto x \cdot \color{blue}{\left|\frac{100}{x + y}\right|} \]

    if 4.0463059399122565e295 < y

    1. Initial program 0.2

      \[\frac{x \cdot 100}{x + y} \]
    2. Applied egg-rr0.2

      \[\leadsto \color{blue}{\left(x \cdot 100\right) \cdot \frac{1}{x + y}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification11.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2.9324058059803696 \cdot 10^{-145}:\\ \;\;\;\;x \cdot \frac{100}{x + y}\\ \mathbf{elif}\;y \leq 1.1419780404580396 \cdot 10^{+122}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 4.404093813874534 \cdot 10^{+150}:\\ \;\;\;\;x \cdot \left|\frac{100}{x + y}\right|\\ \mathbf{elif}\;y \leq 6.770638945663061 \cdot 10^{+203}:\\ \;\;\;\;100\\ \mathbf{elif}\;y \leq 1.4672009052933056 \cdot 10^{+225}:\\ \;\;\;\;x \cdot \frac{100}{x + y}\\ \mathbf{elif}\;y \leq 4.0463059399122565 \cdot 10^{+295}:\\ \;\;\;\;100\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 100\right) \cdot \frac{1}{x + y}\\ \end{array} \]

Reproduce

herbie shell --seed 2022127 
(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)))