From: Eric S. Raymond Date: Fri, 9 Apr 2004 15:54:22 +0000 (+0000) Subject: Befire starting Chapter IV. X-Git-Tag: 1.0~30 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=3359ee8e7c8348d0937a89f487ff0a3f5d2cfe95;p=mad.git Befire starting Chapter IV. --- diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index b6a83f6..9cf04fa 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -4437,11 +4437,11 @@ Mx/Nx, which is the annual premium payable for an entire life for $1 of whole life insurance, (2)Ax = Mx/Dx, which is the -single permium payable at age x for $1 of whole life insurance, and +single premium payable at age x for $1 of whole life insurance, and (2)ax = Nx/Dx, which is the present value at age x of a whole life annuity of $1, first payment -at age $x. +at age x. Printing of results is under the control of an input variable PRINT. Certain relationships must hold between some independently @@ -4483,8 +4483,12 @@ round-off, but they should differ by very little. &commutefunc; + + + + Symbol Manipulation and Recursive Function Examples <emphasis role='note'>Example 1: Find a word in a string</emphasis> @@ -4502,12 +4506,15 @@ character per word in W(1)...W(L). + + &wordsearch; + <emphasis role='note'>Example 2: Compute the factorial function</emphasis> Problem: Evaluate the recursive function, @@ -4529,7 +4536,7 @@ handled. &factfunc; - + In order to use this function, the calling program would have to specify a list for use in the SAVE and RESTORE stayements. The @@ -4540,6 +4547,7 @@ following is an example of a program which uses FACT. + <emphasis role='note'>Example 3: Compute greatest common divisor</emphasis> Problem: To find the greatest common @@ -4548,7 +4556,11 @@ divisor of two integers Y and Z. Analysis: The greatest common divisor is defined recursively by three equations - + + + + + Where REM.(A,B) is the remainder of A/B. This function expects the arguments to be found on the temporary storage list as the two @@ -4558,10 +4570,11 @@ efficient than the usuall way of defining functions, but serves to remove many pitfalls encountered in using dummy variables with recursive functions. + &gcdfunc; - + Note: When called upon for a value, a function such as GCD, must have at least one argument (in this example @@ -4575,6 +4588,8 @@ executed only once, either in the main program or in a subprogram(but before any use of SAVE or RESTORE), since the SAVE and RESTORE statements always refer to the current list. + + An example of a program using GCD. is: @@ -4582,13 +4597,18 @@ statements always refer to the current list. + <emphasis role='note'>Example 4: Evaluate Tschebychev polynomials</emphasis> Problem: To evaluate Tschebychev polynomials. Analysis: The Tschebychev polynomial T(N,X) is defined recursively as follows: - + + + + + It is important to understand that when an expression is written as an argument of a function its value is computed and stored in a @@ -4597,6 +4617,7 @@ used as the argument of the function. The implication of this use of a temporary location is that often expressions cannot be used as arguments of recursive functions. + &tschebfunc; @@ -4611,6 +4632,8 @@ arguments of recursive functions. + +