| Alternative 1 | |
|---|---|
| Error | 0.01% |
| Cost | 6720 |
\[\sqrt{1 - x \cdot x}
\]
(FPCore (x) :precision binary64 (sqrt (- 1.0 (* x x))))
(FPCore (x) :precision binary64 (exp (* (log1p (- (* x x))) 0.5)))
double code(double x) {
return sqrt((1.0 - (x * x)));
}
double code(double x) {
return exp((log1p(-(x * x)) * 0.5));
}
public static double code(double x) {
return Math.sqrt((1.0 - (x * x)));
}
public static double code(double x) {
return Math.exp((Math.log1p(-(x * x)) * 0.5));
}
def code(x): return math.sqrt((1.0 - (x * x)))
def code(x): return math.exp((math.log1p(-(x * x)) * 0.5))
function code(x) return sqrt(Float64(1.0 - Float64(x * x))) end
function code(x) return exp(Float64(log1p(Float64(-Float64(x * x))) * 0.5)) end
code[x_] := N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Exp[N[(N[Log[1 + (-N[(x * x), $MachinePrecision])], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]
\sqrt{1 - x \cdot x}
e^{\mathsf{log1p}\left(-x \cdot x\right) \cdot 0.5}
Results
Initial program 0.01
Applied egg-rr0
Final simplification0
| Alternative 1 | |
|---|---|
| Error | 0.01% |
| Cost | 6720 |
| Alternative 2 | |
|---|---|
| Error | 0.46% |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Error | 1.02% |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x)
:name "Diagrams.TwoD.Ellipse:ellipse from diagrams-lib-1.3.0.3"
:precision binary64
(sqrt (- 1.0 (* x x))))