diff options
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 |