If you want, you can approximate ε: func ε() float64 { x := float64(1.0) for ...
15 years, 6 months ago
(2010-01-29 22:25:03 UTC)
#4
If you want, you can approximate ε:
func ε() float64 {
x := float64(1.0)
for {
x = x * 0.5
if (1.0 + (x*0.5)) == 1.0 { break }
}
return x
}
P.S.
Perhaps a math.ε constant should be defined in the math pkg.
Many numerical methods rely on ε for speed-vs-accuracy.
On Fri, Jan 29, 2010 at 14:25, James Tomaschke <gith.tech@gmail.com> wrote: > If you want, ...
15 years, 6 months ago
(2010-01-29 22:32:55 UTC)
#5
On Fri, Jan 29, 2010 at 14:25, James Tomaschke <gith.tech@gmail.com> wrote:
> If you want, you can approximate ε:
>
Having approximated it (or just computed it and written
down the constant) I don't understand what you are
suggesting we do with it.
Russ
Russ Cox wrote: > Having approximated it (or just computed it and written > down ...
15 years, 6 months ago
(2010-01-29 22:50:25 UTC)
#6
Russ Cox wrote:
> Having approximated it (or just computed it and written
> down the constant) I don't understand what you are
> suggesting we do with it.
>
> Russ
>
func veryclose(a, b float64) bool { return tolerance(a, b, ε) }
> > func veryclose(a, b float64) bool { return tolerance(a, b, ε) } > Given ...
15 years, 6 months ago
(2010-01-29 22:58:12 UTC)
#7
>
> func veryclose(a, b float64) bool { return tolerance(a, b, ε) }
>
Given your definition of ε, tolerance(a, b, ε) is just a == b.
Some tests do check a == b, but that's not what veryclose
is for; veryclose is intentionally more lenient.
Russ
Russ Cox wrote: > Given your definition of ε, tolerance(a, b, ε) is just a ...
15 years, 6 months ago
(2010-01-29 23:57:33 UTC)
#8
Russ Cox wrote:
> Given your definition of ε, tolerance(a, b, ε) is just a == b.
> Some tests do check a == b, but that's not what veryclose
> is for; veryclose is intentionally more lenient.
>
> Russ
Sure, 2ε on my platform (~4.44e-16) is essentially the 4e-16 constant
you are using.
The essence of my suggestion is that instead of relaxing the test from
veryclose() to close(), veryclose() could be modified as to take into
consideration the platform's ε.
Perhaps 1e-14 is close() enough.
> > Sure, 2ε on my platform (~4.44e-16) is essentially the 4e-16 constant > you ...
15 years, 6 months ago
(2010-01-30 00:41:55 UTC)
#9
>
> Sure, 2ε on my platform (~4.44e-16) is essentially the 4e-16 constant
> you are using.
>
> The essence of my suggestion is that instead of relaxing the test from
> veryclose() to close(), veryclose() could be modified as to take into
> consideration the platform's ε.
>
It's not platform-specific. No matter what the platform, these
are 64-bit IEEE-754 floating point values.
Russ
Russ Cox wrote: > It's not platform-specific. No matter what the platform, these > are ...
15 years, 6 months ago
(2010-01-30 02:34:21 UTC)
#10
Russ Cox wrote:
> It's not platform-specific. No matter what the platform, these
> are 64-bit IEEE-754 floating point values.
>
> Russ
>
Oh my mistake, thought there was some non-standard hardware problems.
The only thing else I can think of:
fldcw $27F
It's been a long time since I've done any 387.
Issue 196063: code review 196063: math: Change veryclose to close for Sinh and Exp tests.
(Closed)
Created 15 years, 6 months ago by dho
Modified 15 years, 6 months ago
Reviewers:
Base URL:
Comments: 0