Routines |
Prev: 14298 | Up: Map | Next: 14387 |
The address of this routine is found in the table of addresses. It is called via the calculator literal 36 by the routine at asn. It is also called indirectly via fp_calc_2.
This subroutine handles the function ATN X and is the last of the four routines that use the series generator to produce Chebyshev polynomials. It returns a real number between -π/2 and π/2, which is equal to the value in radians of the angle whose tan is X.
The approximation to ATN X is found as follows:
i. The values W and Y are found for three cases of X, such that:
In each case, -1<=Y<=1, as required for the series to converge.
ii. The argument Z is formed, such that:
iii. The series generator is used to produce the required function.
iv. Finally a simple multiplication and addition give ATN X.
|
||||||||
Perform step i.
|
||||||||
atn | 14306 | CALL re_stack | Use the full floating-point form of X. | |||||
14309 | LD A,(HL) | Fetch the exponent of X. | ||||||
14310 | CP 129 | Jump forward for case i: Y=X. | ||||||
14312 | JR C,SMALL | |||||||
14314 | RST 40 | X | ||||||
14315 | DEFB 161 | stk_one: X, 1 | ||||||
14316 | DEFB 27 | negate: X, -1 | ||||||
14317 | DEFB 1 | exchange: -1, X | ||||||
14318 | DEFB 5 | division: -1/X | ||||||
14319 | DEFB 49 | duplicate: -1/X, -1/X | ||||||
14320 | DEFB 54 | less_0: -1/X, (1/0) | ||||||
14321 | DEFB 163 | stk_pi_2: -1/X, (1/0), π/2 | ||||||
14322 | DEFB 1 | exchange: -1/X, π/2, (1/0) | ||||||
14323 | DEFB 0 | jump_true to CASES for case ii: -1/X, π/2 | ||||||
14324 | DEFB 6 | |||||||
14325 | DEFB 27 | negate: -1/X, -π/2 | ||||||
14326 | DEFB 51 | jump to CASES for case iii: -1/X, -π/2 | ||||||
14327 | DEFB 3 | |||||||
SMALL | 14328 | RST 40 | ||||||
14329 | DEFB 160 | stk_zero: Y, 0; continue for case i: W=0 | ||||||
Perform step ii.
|
||||||||
CASES | 14330 | DEFB 1 | exchange: W, Y | |||||
14331 | DEFB 49 | duplicate: W, Y, Y | ||||||
14332 | DEFB 49 | duplicate: W, Y, Y, Y | ||||||
14333 | DEFB 4 | multiply: W, Y, Y*Y | ||||||
14334 | DEFB 49 | duplicate: W, Y, Y*Y, Y*Y | ||||||
14335 | DEFB 15 | addition: W, Y, 2*Y*Y | ||||||
14336 | DEFB 161 | stk_one: W, Y, 2*Y*Y, 1 | ||||||
14337 | DEFB 3 | subtract: W, Y, 2*Y*Y-1=Z | ||||||
Perform step iii, passing to the series generator the parameter '12', and the twelve constants required.
|
||||||||
14338 | DEFB 140 | series_0C: W, Y, Z | ||||||
14339 | DEFB 16,178 | |||||||
14341 | DEFB 19,14 | |||||||
14343 | DEFB 85,228,141 | |||||||
14346 | DEFB 88,57,188 | |||||||
14349 | DEFB 91,152,253 | |||||||
14352 | DEFB 158,0,54,117 | |||||||
14356 | DEFB 160,219,232,180 | |||||||
14360 | DEFB 99,66,196 | |||||||
14363 | DEFB 230,181,9,54,190 | |||||||
14368 | DEFB 233,54,115,27,93 | |||||||
14373 | DEFB 236,216,222,99,190 | |||||||
14378 | DEFB 240,97,161,179,12 | |||||||
At the end of the last loop the 'last value' is:
Perform step iv.
|
||||||||
14383 | DEFB 4 | multiply: W, ATN X (case i) or W, ATN (-1/X) (cases ii and iii) | ||||||
14384 | DEFB 15 | addition: ATN X (all cases now) | ||||||
14385 | DEFB 56 | end_calc | ||||||
14386 | RET | Finished: 'last value'=ATN X. |
Prev: 14298 | Up: Map | Next: 14387 |