From 4eb4e3485955f3b4af15a9c67635c71648ef6233 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 13 Mar 2004 15:31:40 +0000 Subject: [PATCH] Another page. --- doc/mad-manual.xml | 135 +++++++++++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 42 deletions(-) diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index e3576d6..314e345 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -3594,7 +3594,7 @@ values of a, b, and C are printed immediately after they are brought in to help in finding trouble spots during the development of the program (not as necessary here as in longer problems, but a good idea!). - + Flow Diagram: @@ -3603,13 +3603,13 @@ idea!). - + The Program: &quadratic; - + *DATA 4. -8. 4. 0 5. 10. @@ -3695,7 +3695,7 @@ original table had: The problem is to write a program to generate the entire "truth table" for the given expression T. - + Flow Diagram: @@ -3704,7 +3704,7 @@ table" for the given expression T. - + The Program: @@ -3726,7 +3726,7 @@ NORMAL MODE IS BOOLEAN instead of the BOOLEAN declaration. - + Example 3<emphasis role='note'>: Simpson's Rule approximation of a definite integral</emphasis> Problem: To approximate @@ -3764,7 +3764,7 @@ external function or an internal function. - + The Program: @@ -3775,11 +3775,11 @@ external function or an internal function. If, for some reason, the integral of sin 3x - cos(rx + 1) were needed if 0 ≤ x ≤ 3, and the integral of sin 3x - cos(rx) otherwise, the program might then be as follows: - + The Program: - + &simpsmain; @@ -3809,12 +3809,52 @@ READ READ FORMAT INPUTS,A,B,N,R FUNCTION NAME S - + Example 4<emphasis role='note'>: Find roots of a function by half-interval approximation</emphasis> - - - +Problem: To find a real solution (if it +exists) of the equation f(x) = 0 (where f is a continuous function) +obn an arbitrary interval [a, b], provided the roots (if there are +more than one) are at least ε apart. + +Analysis: We specify a, b, and ε as +parameters. The method used will be "half-interval convergence," in +which the function is evaluated at x -a, and then the interval is +scanned for a change of signA change of sign is +detected when the numbers involved have a negative +product. in the value of f(x). If no change odf sign +is found, the scanning is repeated with a step size for searching half +of the previous size. If the step size becomes smaller than ε, +and no change of sign is found, the process is terminated, and comment +is printed: "NO SOLUTION". + + +If a change of sign is found between xL +and xR, the value of f is computeed at +xM = (xL + +xR)/2, i.e. the midpoint of the interval of +uncertainty [xL, xR]. We +then determine which one of the intervals [xL, +xM]. [xM, +xR] now contains a change in sign. We then +compute the value of f at the midpoint of that smaller interval, etc., +until the interval being considered finally has length less that +ε, at which time either end may be taken as the solution with an +error less than ε. + +The method used here to handle the xM +cpomputation is perhaps not the most obvious one. It consists of +a simple loop in which the value of x is adjusted by h′ = -h/2, then +h′′ - h′/2 = h/4, etc., until h is small enough. The +adjustment of x is either to the left or to the right, depending on +the occurrence or non-occurrence, respectively, of a change of sign +between f(a) and f(x). + +It should be understood that this method may not find a root +which is one of a pair of roots which either coincide or are less that +ε apart. + + Flow diagram: @@ -3822,7 +3862,7 @@ READ READ FORMAT INPUTS,A,B,N,R - + Program: It is assumed here that f (referred to as F. in the program) will be defined as an internal @@ -3836,14 +3876,14 @@ programs were punched-card decks. An internal function definition was typically a single card that could be slipped anywhere into the program deck. - + &findroot; *DATA 1. 2. .01 - + Example 5<emphasis role='note'>: Compute the transpose of a matrix</emphasis> Problem: Find the transpose A' of an n×n @@ -3875,7 +3915,7 @@ argument in a function definition program. The function would be called with a statement of the form EXECUTE TRANS.(A, N). - + Example 6<emphasis role='note'>: Matrix multiplication</emphasis> Problem: Multiply the matrix A = @@ -3903,7 +3943,7 @@ of C is computed by the formula - + The Retrocomputing Museum implementation cannot yet compile this example. The problem is the EQUIVALENCE declaration; @@ -3914,7 +3954,7 @@ there is no general way to implement this in generated C. &matrixmult; - + * DATA 2 3 3 1. 2. 3. 4. 5. 6. @@ -3922,12 +3962,12 @@ there is no general way to implement this in generated C. 13. 14. 15. - + Example 7<emphasis role='note'>: Solve simultaneous linear equations</emphasis> - + Flow diagram: @@ -3936,13 +3976,13 @@ there is no general way to implement this in generated C. - + The Program: &jordan; - + * DATA 3 1. 1. 1. 6. -1. 0 @@ -3951,13 +3991,14 @@ there is no general way to implement this in generated C. - + Business Data Processing Examples Example 1<emphasis role='note'>: Payroll Processing</emphasis> - + + Flow diagram: @@ -3966,13 +4007,12 @@ there is no general way to implement this in generated C. - + The Program: &payroll; - * DATA GEORGE WASHINGTON 12345678 100. 4800. JOHN ADAMS 12345679 200. 4900. @@ -3981,12 +4021,11 @@ JAMES MADISON 12345681 200. 4700. JOHN QUINCY ADAMS 12345682 100. 300. - + Alternate Program: &altpayroll; - * DATA GEORGE WASHINGTON 12345678 100. 4800. JOHN ADAMS 12345679 200. 4900. @@ -3996,33 +4035,42 @@ JOHN QUINCY ADAMS 12345682 100. 300. + + + + + Example 2<emphasis role='note'>: Payroll Tape Processing</emphasis> - + + Flow diagram: + - - + + The Program: + &payrolltape; + Example 3<emphasis role='note'>: Mortgage Payment Processing</emphasis> - + - + Flow diagram: @@ -4031,14 +4079,16 @@ JOHN QUINCY ADAMS 12345682 100. 300. + + - - + + The Program: @@ -4046,11 +4096,12 @@ JOHN QUINCY ADAMS 12345682 100. 300. + Example 4<emphasis role='note'>: Actuarial computation</emphasis> - + Flow diagram: @@ -4059,7 +4110,7 @@ JOHN QUINCY ADAMS 12345682 100. 300. - + The Program: @@ -4092,7 +4143,7 @@ character per word in W(1)...W(L). - + &wordsearch; @@ -4119,7 +4170,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 @@ -4151,7 +4202,7 @@ recursive functions. &gcdfunc; - + Note: When called upon for a value, a function such as GCD, must have at least one argument (in this example @@ -4190,7 +4241,7 @@ arguments of recursive functions. &tschebfunc; - + A program which uses TSCHEB. is: -- 2.43.0