diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-08-14 22:47:31 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-08-14 22:47:31 +0300 |
commit | 3b23e177cd166e96c700379491b4a99bddf9aa4d (patch) | |
tree | 2d87fcb8a9872faa8c93d1f5d7103da6a855bff7 /doc/gawk.texi | |
parent | 63aeb055437534122ddb774b7eecc261ab6e592a (diff) | |
download | egawk-3b23e177cd166e96c700379491b4a99bddf9aa4d.tar.gz egawk-3b23e177cd166e96c700379491b4a99bddf9aa4d.tar.bz2 egawk-3b23e177cd166e96c700379491b4a99bddf9aa4d.zip |
Fix math bug in the doc.
Diffstat (limited to 'doc/gawk.texi')
-rw-r--r-- | doc/gawk.texi | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/doc/gawk.texi b/doc/gawk.texi index 672b6f34..40b85aae 100644 --- a/doc/gawk.texi +++ b/doc/gawk.texi @@ -18955,9 +18955,24 @@ in the previous example can be enhanced by using the following simple algebraic transformation: @example -(sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + x) +(sqrt(x * x + 1) - 1) / x = x / (sqrt(x * x + 1) + 1) +@end example + +@noindent +After making this, change the program does converge to +@value{PI} in under 30 iterations: + +@example +$ @kbd{gawk -f /tmp/pi2.awk} +@print{} 3.215390309173473 +@print{} 3.159659942097501 +@print{} 3.146086215131436 +@print{} 3.142714599645370 +@print{} 3.141873049979825 +@dots{} +@print{} 3.141592653589797 +@print{} 3.141592653589797 @end example -@c FIXME: Show new program and results There is no need to be unduly suspicious about the results from floating-point arithmetic. The lesson to remember is that |