Alternative 1 | |
---|---|
Error | 0.8 |
Cost | 6976 |
\[\left|x\right| - \left(1 + 0.5 \cdot \left(x \cdot x\right)\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)
Results
Initial program 0.1
Simplified0.1
[Start]0.1 | \[ \left|x\right| - \sqrt{{x}^{2} + 1}
\] |
---|---|
+-commutative [=>]0.1 | \[ \left|x\right| - \sqrt{\color{blue}{1 + {x}^{2}}}
\] |
unpow2 [=>]0.1 | \[ \left|x\right| - \sqrt{1 + \color{blue}{x \cdot x}}
\] |
hypot-1-def [=>]0.1 | \[ \left|x\right| - \color{blue}{\mathsf{hypot}\left(1, x\right)}
\] |
Final simplification0.1
Alternative 1 | |
---|---|
Error | 0.8 |
Cost | 6976 |
Alternative 2 | |
---|---|
Error | 0.9 |
Cost | 6784 |
Alternative 3 | |
---|---|
Error | 0.9 |
Cost | 6656 |
Alternative 4 | |
---|---|
Error | 1.2 |
Cost | 6592 |
Alternative 5 | |
---|---|
Error | 1.3 |
Cost | 576 |
Alternative 6 | |
---|---|
Error | 1.5 |
Cost | 192 |
Alternative 7 | |
---|---|
Error | 1.9 |
Cost | 64 |
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))))