Average Error: 0.0 → 0.0
Time: 8.9s
Precision: 64
$0.0 \lt x \lt 10$
$\begin{array}{l} \mathbf{if}\;x \lt 1.000000000000000047921736023859295983129 \cdot 10^{-4}:\\ \;\;\;\;1 + 0.5 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x}\\ \end{array}$
$\begin{array}{l} \mathbf{if}\;x \lt 1.000000000000000047921736023859295983129 \cdot 10^{-4}:\\ \;\;\;\;1 + x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x}\\ \end{array}$
\begin{array}{l}
\mathbf{if}\;x \lt 1.000000000000000047921736023859295983129 \cdot 10^{-4}:\\
\;\;\;\;1 + 0.5 \cdot x\\

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

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

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

\end{array}
double f(double x) {
double r6253827 = x;
double r6253828 = 0.0001;
bool r6253829 = r6253827 < r6253828;
double r6253830 = 1.0;
double r6253831 = 0.5;
double r6253832 = r6253831 * r6253827;
double r6253833 = r6253830 + r6253832;
double r6253834 = r6253830 + r6253827;
double r6253835 = sqrt(r6253834);
double r6253836 = r6253829 ? r6253833 : r6253835;
return r6253836;
}


double f(double x) {
double r6253837 = x;
double r6253838 = 0.0001;
bool r6253839 = r6253837 < r6253838;
double r6253840 = 1.0;
double r6253841 = 0.5;
double r6253842 = r6253837 * r6253841;
double r6253843 = r6253840 + r6253842;
double r6253844 = r6253840 + r6253837;
double r6253845 = sqrt(r6253844);
double r6253846 = r6253839 ? r6253843 : r6253845;
return r6253846;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 0.0

$\begin{array}{l} \mathbf{if}\;x \lt 1.000000000000000047921736023859295983129 \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.000000000000000047921736023859295983129 \cdot 10^{-4}:\\ \;\;\;\;1 + x \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x}\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x)
:name "squareRoot3Invalid"
:pre (< 0.0 x 10.0)
(if (< x 0.0001) (+ 1.0 (* 0.5 x)) (sqrt (+ 1.0 x))))