home *** CD-ROM | disk | FTP | other *** search
/ Outlet 52 / outlet-52.mgt / e6 < prev    next >
Text File  |  2021-04-18  |  20KB  |  10 lines

  1.         Finds EXP X, ie e to the power X.                               The number e is just the number 2.718281828...d, the    "exponential constant" - easy to remember, because of the       repeated "1828" - but it has the unique property that the       differential of e**x is e**x, which makes it amazingly useful inthe differential calculus and related topics, including advancedtrigonometry and statistics. For this reason e was made the baseof the "natural logarithms" LN x, ie if y = LN x then x = e**y.         It has nothing much to do with E-format numbers; in bothcases E stands for "exponent".                                          In hex e is 2.ADF85458...h, as a full FP number it is 822D F8 54 58. Unlike the other important "transcendental number" pi, it isn't included as a Spectrum function, but if required ina BASIC program it is easily got as EXP 1.                              The subroutine breaks down the calculation of e**X into a series of steps, some of them quite simple:                        1. First find Y = X/LN 2, ie multiply X by the FP form 81  38 AA 3B 29 which represents 1/LN 2. The result we are looking  for will be 2**Y; for                                                                 if Y = X/LN 2, then                                                X = Y LN 2, and                                              e**X = [e**(LN 2)]**Y.                            But e**(LN 2) = 2; this is what LN 2 means, so                                e**X = 2**Y.                                   2. Split Y into an integer part N, which may be negative,  and a positive fractional part W.                                                  Since Y = N + W,                                                   2**Y = 2**N * 2**W.                            3. 2**Y will be easy if we can find 2**W - just a matter ofadding positive or negative N to the exponent of the FP form for2**W. N is parked in the calculator memory for the moment.           4. 2**W requires Chebyshev polynomials. W is a positive    fraction, ie between zero and one, and 2**W is found by using   the series generator 3449 series-08 with eight Chebyshev        constants and a "reduced argument" Z = 2*W - 1, which is betweenminus one and one.                                                      [The notes don't explain the reduced argument; this     presumably fits a standard Chebyshev polynomial calculation fromthe reference on page 223, see under Chebyshev polynomials.]            The Chebyshev constants used are:                                          FP form          Decimal                                     1. 63 36            0.000000001                                 2. 68 65 66         0.000000053                                 3. 6D 78 65 40      0.000001851                                 4. 72 60 32 C9      0.000053453                                 5. 77 21 F7 AF 24   0.001235714                                 6. 7B 2F B0 B0 14   0.021446556                                 7. 7E 7E BB 94 58   0.248762434                                 8. 81 3A 7E F8 CF   1.456999875                      5. Recover N and add it to the exponent byte of 2**W: this is the result required.                                                Input parameters: X is the last value on the calculator  stack; it must be on the calculator stack even for direct calls.       Action: use the calculator to restack X in full format;  unnecessarily, as the multiply operation will do this again             - put 1/LN 2 on the stack and multiply to get Y                 - get N = INT Y and put it in mem-3                             - take N from Y to get W; even if Y is negative, INT Y  is still less than Y, so N is positive in any case                      - calculate the "reduced argument" Z = 2*W - 1                  - calculate the Chebyshev result with the constants     shown above; the result is 2**W                                         - get N from mem-3                                              - exit from the calculator; N is on top of the stack and2**W below it                                                           - call 2DD5 FP TO A to get N into the A register                - if FP TO A returns with NZ jump on to N NEGTV; N is   negative                                                                - if FP TO A returns with C report "Number too big"; N  is too big for a single register, ie N > 255d                           - (N positive and N < 256d) add N to the exponent byte  of 2**W on the stack; this isn't a true exponent, but the true  exponent plus 80h/128d                                                  - if this comes out less than 256d jump on to RESULT OK         - (result exponent more than 256d in FP form) report    "Number too big"; the result exponent is more than 127d as a    true exponent.                                                         _3705_N_NEGTV: if FP TO A returned with carry jump on to RSLT ZERO; ABS N was too big for the A register, eg EXP -300.   This isn't an error but an "underflow" - the answer is zero,    within the margins of error                                             - take the FP form exponent of 2**W from ABS N                  - if this doesn't set carry jump on to RSLT ZERO; ABS N is at least 80h bigger than the true exponent, and as N is      negative this means underflow again                                     - (result ABS N - FP exponent, no carry) negate this    result; now FP exponent minus ABS N, which since N is negative  is the result exponent.          AUTOLOAD   ?W╦\WCONTENTS  └ !╦\!H&LOOKAHED.#ªç  OUTCLASS.#        └eç  LOOKOUT .#
  2. ⁿNç  OUTBOARD.# α Θç  LETTERS1.#Ç└   Ω:ç  EDIT'L  .#0= ç  ULASNOW       °a ╦\a `"CAROLS    Gⁿ       Aî╦\Aî`"SILENITE          ⁿ╧╓\╧`"SANTA     KÇÇα      ⁿ ▀ö╦\▀öOUTPUT  .#'■ç  TOPCAL     0≡ ⁿ≡∩>╦\∩>`"BB3.MAS   α▒╦\▒`"DRIVENO   !°ä╦\ä`"INDEXΣ    #p└(╦\(  LADYCLIP  Ç ╦\6BLASTIT   %   >,╦\,(#XMASWISH  )Ç√
  3. ╦\√
  4. (#XMAS      *└  Q'╦\Q'`"COMPASS   ,≡ ?%!╦\%!FINST'N  .#(Çδç  ADDENDER.#
  5. .└└`╡ç  XMASS.EXE +.     =UÇ  ROMBLAST.T2    pY}  MAP       3Ç ? ╦  LETTERS2.#"4└    ═Aç  LETTERC1.#"8■       Cç  LETTERC2.#;≡   ¬9ç  c6        (*  ⁿ   N(á  e3        (BÇ    ■M(á  e4        'FÇ    ?₧M(á  e5        (J    ≡    N(á                    a(á           e6        (N
  6. α    ?0N(á                    a(á0           f1        'â└    ?àM(á                    a(áà           f2        'ç└    ?KM(á                    a(áK           f3        (ï└    ╓M(á                    a(á╓           f4        (ÅÇ     ┤M(á                    a(á┤           f5        (ô     ╘M(á                    a(á╘           g1        'ù■    {M(á                    a(á{           g2        (¢■    ╧M(á                    a(á╧           i1        (ƒⁿ    N(á                    a(á           i2        'ú°    êM(á                    a(áê           i3        (º°    ≥M(á                    a(á≥           i4        (½≡    6N(á                    a(á6           k1        (»α    ?¡M(á                    a(á¡           k2        
  7. │    └ ┼(á                    a(á┼           k3        '┤
  8. ■        M(á                    a(á               k4        (╕
  9. ■    ⁿM(á                    a(áⁿ           l1        (╜ⁿ    τM(á                    a(áτ           l2        (┴°    ±M(á                    a(á±           l3        (┼≡    «M(á                    a(á«           l4        '╔α    M(á                    a(á           ADDENDER.#
  10. J└α╡ç