home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / C / ioccc / 1990 / theorem.hint < prev    next >
Encoding:
Text File  |  1992-10-18  |  2.5 KB  |  91 lines

  1. Best of Show: <theorem@blake.u.washington.edu> Adrian Mariano
  2.  
  3.     Adrian Mariano
  4.     University of Washington
  5.     2729 72nd Ave SE
  6.     Mercer Island, WA 98040
  7.     USA
  8.  
  9.  
  10. Judges' comments:
  11.  
  12.     The program's source implements four functions, all from the
  13.     same source file!
  14.  
  15.     Usage:
  16.  
  17.     theorem expression x1 x2 h y1
  18.  
  19.     where:
  20.         expression - function f(x,y)  (see below)
  21.         x1 - start of interval
  22.         x2 - end of interval
  23.         h - step size
  24.         y1 - initial value  (y(x1) == y1)
  25.  
  26.     When you compile theorem.c as is and run with 5 args, it numerically
  27.     solves the equation y'=f(x,y), with a step size of h, over the interval 
  28.     x=[x1,x2], with the initial condition of y(x1)=y1.
  29.  
  30.     The 'expression' f(x,y), is any function of 'x' and 'y' with the
  31.     operators:
  32.     
  33.         +    -    *    /    ^
  34.  
  35.     The symbol '^' is the power operator.  Note that it only supports
  36.     integer powers.  Also note that all expressions are evaluated strictly 
  37.     left to right.  (i.e., parenthesis aren't supported).
  38.  
  39.     Try running the program with the following args:
  40.  
  41.     theorem y 0 1 0.1 1
  42.     theorem 1/x 1 2 0.1 0
  43.     theorem 'x^2/y+x' 0 1 0.1 6
  44.     
  45.     But wait, there is more!  You also get, free of charge, a 
  46.     reversing filter!  Try:
  47.  
  48.     theorem -r 0 0 0 0 < theorem.c > sorter.c
  49.     
  50.     Still not impressed?  The author throws in for free, a 
  51.     sort program! Try:
  52.  
  53.     cc sorter.c -o sorter
  54.     ls | sorter
  55.     
  56.     This program is safe for home use as well.  The author has
  57.     included a safety feature in case you misplace the original
  58.     program source:
  59.  
  60.     sorter -r 0 0 0 0 < sorter.c > theorem_bkp.c
  61.     
  62.     And finally, as a special offer to users of this entry,
  63.     the author provides a Fibonacci sequence generator!  Try:
  64.  
  65.     sorter 0 0 0 0 < theorem.c > fibonacci.c
  66.     cc fibonacci.c -o fibonacci
  67.     fibonacci 1 1
  68.     fibonacci 2 1
  69.  
  70.     Program available 9 track and cartridge cassette.  Gensu knife
  71.     not included!  :-)
  72.  
  73.     When this program was first shown at the 1990 Summer Usenix 
  74.     conference, it received a standing ovation; a first for
  75.     a contest entry.
  76.  
  77.     It should be noted that the 4 trailing args '0 0 0 0', are
  78.     required on systems that dump core when NULL is dereferenced.
  79.  
  80.  
  81. Selected notes from the author:
  82.  
  83.     Differential equations are solved via the Runge-Kutta method, 
  84.     which guarantees local error proportional to h^5, and total
  85.     error across a finite interval is at most a constant times h^4.
  86.     
  87.     Sorting is accomplished with a standard shell sort.
  88.  
  89.     Note that the sorting and reversing is limited to files with 
  90.     fewer than 500 lines, each less than 99 characters long.  
  91.