in reply to In theory, theory and practice are the same...
in thread Binomial Expansion
While Perl no longer display integers without using exponential notation at 18!, when I tried to get a mistake in the display, I couldn't. Except for the fact that Perl did not like displaying large numbers, the results are right.
In retrospect I shouldn't be surprised at this. After all the internal calculation is carried out at a higher accuracy than what is displayed. Since the calculation is pretty short, roundoff errors are not readily visible. And testing this is pretty simple:
To find a disagreement between theory and practice I had to go to 28 choose 14. Which was off from being an integer by about 1 part in a hundred million.#! /usr/bin/perl my ($n, $m) = @ARGV; my $ans = fact($n)/fact($m)/fact($n-$m); my $err = $ans - sprintf("%.0f", $ans); print "$n choose $m: $ans (error $err)\n"; sub fact { my $fact = 1; $fact *= $_ for 1..$_[0]; $fact; }
Sorry tye, but I find that error tolerable. For a simple example the formula works in this case, even though theoretically in practice it should show some difference between theory and practice.
OTOH I can guarantee you that trying to invert a 10x10 matrix using Cramer's formula is going to be a better example. For an nxn matrix you get n! terms being added and subtracted from each other. It doesn't take a large n to make that rather slow, and to get insane roundoff errors...
|
---|
Replies are listed 'Best First'. | |
---|---|
(tye)Re3: In theory, theory and practice are the same...
by tye (Sage) on Apr 01, 2001 at 08:09 UTC | |
by tilly (Archbishop) on Apr 01, 2001 at 18:56 UTC | |
Re: Re (tilly) 1: In theory, theory and practice are the same...
by ariels (Curate) on Apr 11, 2001 at 10:55 UTC |