Average Error: 0.0 → 0.0
Time: 787.0ms
Precision: binary64
\[\begin{array}{l} \mathbf{if}\;x \lt 1.00000000000000005 \cdot 10^{-4}:\\ \;\;\;\;1 + 0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;x \lt 1.00000000000000005 \cdot 10^{-4}:\\ \;\;\;\;1 + 0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;x \lt 1.00000000000000005 \cdot 10^{-4}:\\
\;\;\;\;1 + 0.5 \cdot x\\

\mathbf{else}:\\
\;\;\;\;\sqrt{1 + x}\\

\end{array}
\begin{array}{l}
\mathbf{if}\;x \lt 1.00000000000000005 \cdot 10^{-4}:\\
\;\;\;\;1 + 0.5 \cdot x\\

\mathbf{else}:\\
\;\;\;\;\sqrt{1 + x}\\

\end{array}
double code(double x) {
	double VAR;
	if ((x < 0.0001)) {
		VAR = ((double) (1.0 + ((double) (0.5 * x))));
	} else {
		VAR = ((double) sqrt(((double) (1.0 + x))));
	}
	return VAR;
}
double code(double x) {
	double VAR;
	if ((x < 0.0001)) {
		VAR = ((double) (1.0 + ((double) (0.5 * x))));
	} else {
		VAR = ((double) sqrt(((double) (1.0 + x))));
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\begin{array}{l} \mathbf{if}\;x \lt 1.00000000000000005 \cdot 10^{-4}:\\ \;\;\;\;1 + 0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x}\\ \end{array}\]
  2. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \lt 1.00000000000000005 \cdot 10^{-4}:\\ \;\;\;\;1 + 0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x}\\ \end{array}\]

Reproduce

herbie shell --seed 2020152 
(FPCore (x)
  :name "(if (< x 1/10000) (+ 1 (* 1/2 x)) (sqrt (+ 1 x)))"
  :precision binary64
  (if (< x 0.0001) (+ 1.0 (* 0.5 x)) (sqrt (+ 1.0 x))))