On Tue, Jan 29, 2013 at 8:01 PM, Jonathan <
gu...@uwosh.edu> wrote:
> For the record as I think about this. The way most scientists do this with
> a mixed number of significant digits (significant figures, SF) in the inputs
> is the following. Please note that for functions like sine, cosine, log and
> so on this is a little bit sloppy and proper interval arithmetic will
> sometimes give a different answer. In cases where we need to know the
> precision accurately, we will usually use statistical uncertainties in each
> parameter and propagate that through the calculation using the proper
> statistics (in most cases symmetric gaussian distributions are used).
Intervals work well, but it would be nice to propagate gaussians as
well. Also, when you write 2.0, I assume you mean 2.0000000, not 2.0
+/- 0.1, so the input is already ambiguous. Also, it's a bit ill-posed
because what is sin(2.0 * pi) to 3 digits of *relative* precision? How
much intermediate precision is needed to give the result?
sage: sin(2.0*pi).n(digits=300)
-2.50308811950890920759380853694117296639136107833060156907412891654218194458725365083409825978182567551756080480156467091775509964013759873633379261609983567926786122363484618232829973119909155267641397848002179036023558452211812394315755777568498955720109032866136031960197436308067649928573726528606e-301
which is correct to 300 absolute digits, but not 300 relative digits
of precision.
> sin(2.0*pi) to full precision then round to 2 SF to agree with the 2 SF on
> the 2.0. Best equivalent I can come up with in Sage is:
>
> sin(2.0*pi).n().n(digits = 2)
>
> Note this example only worries about SF for multiplication and does not
> properly account for how SF propagate through the sine function.
>
> Thinking out loud:
>
> Maybe a .n(SF=X) = .n().n(d=X) would be a good start on clarifying things.
> It still requires the user to decide on the significant figures.
Note that this still uses 53 bits to do the intermediate computation,
then at the end truncates to X digits. Of course if X > 15, this will
be wrong, and there's no tracking of the actual precision needed to
get the result to X digits of precision.
> Better yet would be .n(SF), gives the proper number of significant figures
> using interval arithmetic. Manual version of example above as I am not
> clear yet on how this is implemented in Sage...need to learn:
>
> sin(2.1*pi).n().n(digits=3) =0.309
> sin(1.9*pi).n().n(digits=3) =-0.309
>
> So uncertain in the first decimal place. Thus sin(2.0*pi).n(SF) = 0.0 ± 0.3
> (although we would not usually provide the ±0.3).
sage: a = RIF(2*pi); a
6.283185307179587?
sage: sin(RIF(2*pi))
0.?e-15
sage: sin(RIF(2*pi)) < 1e-100
False
sage: sin(RIF(2*pi)).endpoints()
(-2.44929359829471e-16, 6.43249059870655e-16)
sage: sin(RealIntervalField(10)(2*pi)) # 10 bits of prec
0.00?
sage: sin(RealIntervalField(10)(2*pi)).endpoints()
(-0.0020, 0.0059)
Note that intervals are provably correct at each step, but do not
represent a gaussian (there is zero chance that the value lies outside
the interval boundaries) and are thus often too inclusive (in an
iterative process, often you'll get that the result lies in
[-infinity, infinity], not so helpful).
- Robert