?

Average Error: 32.2 → 0
Time: 3.0s
Precision: binary64
Cost: 196

?

\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-311}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
(FPCore (x) :precision binary64 (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))
(FPCore (x) :precision binary64 (if (<= x -5e-311) 2.0 0.0))
double code(double x) {
	return (x / x) - ((1.0 / x) * sqrt((x * x)));
}
double code(double x) {
	double tmp;
	if (x <= -5e-311) {
		tmp = 2.0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x / x) - ((1.0d0 / x) * sqrt((x * x)))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-5d-311)) then
        tmp = 2.0d0
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	return (x / x) - ((1.0 / x) * Math.sqrt((x * x)));
}
public static double code(double x) {
	double tmp;
	if (x <= -5e-311) {
		tmp = 2.0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x):
	return (x / x) - ((1.0 / x) * math.sqrt((x * x)))
def code(x):
	tmp = 0
	if x <= -5e-311:
		tmp = 2.0
	else:
		tmp = 0.0
	return tmp
function code(x)
	return Float64(Float64(x / x) - Float64(Float64(1.0 / x) * sqrt(Float64(x * x))))
end
function code(x)
	tmp = 0.0
	if (x <= -5e-311)
		tmp = 2.0;
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp = code(x)
	tmp = (x / x) - ((1.0 / x) * sqrt((x * x)));
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -5e-311)
		tmp = 2.0;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_] := N[(N[(x / x), $MachinePrecision] - N[(N[(1.0 / x), $MachinePrecision] * N[Sqrt[N[(x * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := If[LessEqual[x, -5e-311], 2.0, 0.0]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-311}:\\
\;\;\;\;2\\

\mathbf{else}:\\
\;\;\;\;0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original32.2
Target0
Herbie0
\[\begin{array}{l} \mathbf{if}\;x < 0:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if x < -5.00000000000023e-311

    1. Initial program 27.9

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x} \]
    2. Taylor expanded in x around -inf 0

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

    if -5.00000000000023e-311 < x

    1. Initial program 36.5

      \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x} \]
    2. Taylor expanded in x around 0 0

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-311}:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternatives

Alternative 1
Error31.3
Cost64
\[0 \]

Error

Reproduce?

herbie shell --seed 2023067 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

  :herbie-target
  (if (< x 0.0) 2.0 0.0)

  (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))