# ?

Average Error: 0.1 → 0.1
Time: 9.3s
Precision: binary64
Cost: 13056

# ?

$-1000 \leq x \land x \leq 1000$
$\left|x\right| - \sqrt{{x}^{2} + 1}$
$\left|x\right| - \mathsf{hypot}\left(1, x\right)$
(FPCore (x) :precision binary64 (- (fabs x) (sqrt (+ (pow x 2.0) 1.0))))
(FPCore (x) :precision binary64 (- (fabs x) (hypot 1.0 x)))
double code(double x) {
return fabs(x) - sqrt((pow(x, 2.0) + 1.0));
}

double code(double x) {
return fabs(x) - hypot(1.0, x);
}

public static double code(double x) {
return Math.abs(x) - Math.sqrt((Math.pow(x, 2.0) + 1.0));
}

public static double code(double x) {
return Math.abs(x) - Math.hypot(1.0, x);
}

def code(x):
return math.fabs(x) - math.sqrt((math.pow(x, 2.0) + 1.0))

def code(x):
return math.fabs(x) - math.hypot(1.0, x)

function code(x)
return Float64(abs(x) - sqrt(Float64((x ^ 2.0) + 1.0)))
end

function code(x)
return Float64(abs(x) - hypot(1.0, x))
end

function tmp = code(x)
tmp = abs(x) - sqrt(((x ^ 2.0) + 1.0));
end

function tmp = code(x)
tmp = abs(x) - hypot(1.0, x);
end

code[x_] := N[(N[Abs[x], $MachinePrecision] - N[Sqrt[N[(N[Power[x, 2.0],$MachinePrecision] + 1.0), $MachinePrecision]],$MachinePrecision]), $MachinePrecision]  code[x_] := N[(N[Abs[x],$MachinePrecision] - N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]),$MachinePrecision]

\left|x\right| - \sqrt{{x}^{2} + 1}

\left|x\right| - \mathsf{hypot}\left(1, x\right)


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 0.1

$\left|x\right| - \sqrt{{x}^{2} + 1}$
2. Simplified0.1

$\leadsto \color{blue}{\left|x\right| - \mathsf{hypot}\left(1, x\right)}$
Proof
[Start]0.1 $\left|x\right| - \sqrt{{x}^{2} + 1}$ $\left|x\right| - \sqrt{\color{blue}{1 + {x}^{2}}}$ $\left|x\right| - \sqrt{1 + \color{blue}{x \cdot x}}$ $\left|x\right| - \color{blue}{\mathsf{hypot}\left(1, x\right)}$
3. Final simplification0.1

$\leadsto \left|x\right| - \mathsf{hypot}\left(1, x\right)$

# Alternatives

Alternative 1
Error0.8
Cost6976
$\left|x\right| - \left(1 + 0.5 \cdot \left(x \cdot x\right)\right)$
Alternative 2
Error0.9
Cost6784
$\frac{-1}{x + \mathsf{hypot}\left(1, x\right)}$
Alternative 3
Error0.9
Cost6656
$x - \mathsf{hypot}\left(1, x\right)$
Alternative 4
Error1.2
Cost6592
$\left|x\right| + -1$
Alternative 5
Error1.3
Cost576
$x - \left(1 + 0.5 \cdot \left(x \cdot x\right)\right)$
Alternative 6
Error1.5
Cost192
$x + -1$
Alternative 7
Error1.9
Cost64
$-1$

# Reproduce?

herbie shell --seed 1
(FPCore (x)
:name "abs(x) - sqrt(x^2 + 1)"
:precision binary64
:pre (and (<= -1000.0 x) (<= x 1000.0))
(- (fabs x) (sqrt (+ (pow x 2.0) 1.0))))