home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / cnc.zip / CNC.DOC next >
Text File  |  1990-03-24  |  11KB  |  235 lines

  1.  
  2.     Complex Number Calculator version 1.0 by Robert G. Kaires on 3/24/90
  3.  
  4. SHAREWARE
  5.  
  6. If you find this program useful, please register. Registration is only $15.
  7. Your payment is appreciated and necessary for the continued support and
  8. upgrade of this product. If you register you will be put on the mailing list
  9. for future upgrades. Please send your registration fee to: (also questions,
  10. comments)
  11.  
  12. Robert G. Kaires
  13. 609 Glover Dr.
  14. Runnemede, NJ  08078
  15.  
  16. INCLUDE A SELF-ADDRESSED, STAMPED ENVELOPE IF YOU WANT A REPLY AND ARE NOT A
  17. REGISTERED USER.
  18.  
  19. Anyone wishing a disk mailed to them with the latest version of this program
  20. send $5 to the above address requesting a copy of CNC (you do not have to
  21. be a registered user).
  22.  
  23. Other shareware products from R.G.Kaires
  24.  
  25. Function Plotter 4.0, (plots functions and data) registration $20, disk $5
  26.  
  27. PRELIMINARY
  28.  
  29. The symbol "i" is used to denote the unit imaginary constant and is equal to
  30. the square root of -1. The symbol "z" denotes a complex variable and
  31. z(t) = x(t) + i * y(t). As you can see x(t) is the real part, and y(t) is the
  32. complex part of the complex number, respectively. The symbol "t" is used to
  33. denote a real parameter and will be useful in the discussion of numerical
  34. integration.
  35.  
  36. INTRODUCTION
  37.  
  38. Complex Number Calculator (CNC) evaluates expressions containing real or
  39. complex numbers. Examples of valid expressions are:
  40.  
  41.    1.23e10/.45e-27 ............. numbers can be entered in exponential format
  42.    1 + sin(pi/3) ............... same as 1 + sin(180/3) if "degrees" are set
  43.    exp( 2 - (1/2) * exp(3) ) ... functions can, of course, be nested
  44.    .5 * ln( (1+z)/(1-z) ) ...... you will be prompted for z
  45.    (i+1)/(i-1) ................. "i" is the unit imaginary constant
  46.    (z+1)/(z-1) ................. enter any real or complex no. at the prompt
  47.    (1+i)^(2+i) ................. exponents can be complex
  48.    int( 1 / (1+t^2), 4,0,1) .... numerically integrate f(t) = 1 / ( 1+t^2 )
  49.                                  from 0 to 1 using an approx order of 4
  50.    int(cos(t)+j*sin(t),4,0,pi).. numerically integrate cos(t) + i * sin(t)
  51.    M_m(2.0) .................... convert 2 miles to meters
  52.    kW_hp(4.5) .................. convert 4.5 kilo-Watts to horse power
  53.  
  54. See the end of this document for a full list of functions, constants, and
  55. conversions available in CNC. Be aware that CNC is case sensitive.
  56.  
  57. CNC "remembers" previously entered expressions (up to 20), they can be
  58. accessed by using the up and down arrow keys. Expressions can be one full line
  59. in length. When the line is full, CNC will not allow any addition characters
  60. to be inserted until some are deleted. All calculations are performed in
  61. double precision with about 15 significant digits of precision. The number of
  62. displayed digits (default is 6) can be changed using the "dd" command.
  63. When responding to prompts in CNC, the default response is given in square
  64. brackets. Simply hit "Enter" (CR) to respond with the default.
  65.  
  66. At the top of the screen is a message line which lists some information on
  67. valid editing keys and other commands. At the bottom of the screen is the
  68. status line.
  69.  
  70. OPERATORS, FUNCTIONS AND PRECEDENCE
  71.  
  72. The valid operators are + - * / ^.  The operator ^ (exponentiation) has the
  73. highest precedence, followed by the operators * and / which have equal
  74. precedence, followed by + and - which have equal precedence. Operators with
  75. equal precedence are evaluated left to right. Functions (and conversions) have
  76. higher precedence than operators. Therefore sin(pi/6)^2 is evaluated as
  77. (sin(pi/6) )^2 since sin(pi/6) is evaluated before the exponentiation is
  78. performed. Consider the following two expressions:
  79.  
  80.                    sin(5) ^ sqrt(2)   and
  81.                    sin(5) ^ 2^.5
  82.  
  83. The first yields:  (-.958924) ^ 1.41421      ( = -0.250921 - i * 0.90839 )
  84. The second gives:  ( (-.958924) ^ 2 ) ^ .5   ( = .958924                 )
  85.  
  86. In the first expression sqrt (which IS a function) and sin are evaluated
  87. first, in the second expression sin is evaluated, followed by the operators ^
  88. and ^, which are evaluated left to right. Enough said. As when using any
  89. calculator, when in doubt, use parenthesis. One final note: do not use
  90. operators side by side with no intervening numbers or parenthesis such as 
  91. 2*-2, you will be surprised at what you get. Instead use 2*(-2)
  92.  
  93. PRECISION, ROUND OFF ERROR, MIN AND MAX NUMBERS
  94.  
  95. All calculations are done in double precision and have about 15 digits of
  96. accuracy. Problems that can occur from this finite accuracy are best
  97. illustrated by the following example session:
  98.  
  99.             >sin(z)^2 + cos(z)^2 ...... (user enters expres at > prompt)
  100.             z=?>1 ..................... (user enters expres at z=?> prompt)
  101.             1 ......................... (result)
  102.             z=?>10
  103.             1
  104.             z=?>100
  105.             1
  106.             z=?>i ..................... (of course you may use complex
  107.             1                            numbers as well)
  108.             z=?>10*i
  109.             1
  110.             z=?>100*i ................. (WHAT HAPPENED HERE!)
  111.             6.90175e+71
  112.  
  113. This last result is not a bug in CNC! It results because of the finite
  114. precision of this (and any) calculator. The functions sin(z)^2 and cos(z)^2
  115. with purely imaginary arguments are -sinh(y)^2 and cosh(y)^2, respectively.
  116. Now the answer is obvious, for large y we are subtracting two very large
  117. numbers. The answer, of course, becomes very inaccurate.
  118.  
  119. Floating point numbers can range from 1e-308 to 1e308.
  120.  
  121. FUNCTIONS  
  122.  
  123. sqrt()  square root function
  124. exp()   inverse natural log function
  125. real()  real part of a complex number
  126. imag()  imaginary part of a complex number
  127. mag()   magnitude of a complex number
  128. ang()   angle of a complex number
  129. ln()    natural log
  130. log()   log base 10
  131.  
  132. sin(), cos(), tan()        trigonometric functions
  133. asin(), acos(), atan()     inverse trigonometric functions
  134. sinh(), cosh(), tanh()     hyperbolic functions
  135. asinh(), acosh(), atanh()  inverse hyperbolic functions
  136.  
  137. INTEGRATION FUNCTION
  138.  
  139. int( f(t),N,l,u )  numerical integration of a function of a single real
  140.                    variable (t) using Gaussian Quadrature
  141.  - f(t) can evaluate to a complex number
  142.  - N is the order of the approximation ( 2,4,8,10,12,16,32 )
  143.  - l,u lower and upper integration limits (can be a function of T)
  144.  
  145. The integration method used is Gaussian Quadrature. The numerical procedure
  146. does not put integration points at the integration limits. Therefore the
  147. integration limit points can be singular. Of course, one must be concerned
  148. about convergence. Some singularities are integrable, some are not. Consider
  149. the following two sessions. In both the function is singular at t=0, but the
  150. first function is integrable and the second is not.
  151.  
  152.             >int(ln(t),8,0,1) ......... The ln function is integrable
  153.             -0.991239                   from 0 to 1
  154.             >int(ln(t),16,0,1)
  155.             -0.997679
  156.             >int(ln(t),32,0,1)
  157.             -0.999402
  158.  
  159.             >int(1/t,8,0,1) ............The 1/t function in not integrable
  160.             5.43571                     from 0 to 1
  161.             >int(1/t,16,0,1)
  162.             6.76146
  163.             >int(1/t,32,0,1)
  164.             8.11699
  165.  
  166. We notice that the first integral converges but that the second does not.
  167.  
  168. INTEGRATION IN THE COMPLEX PLANE
  169.  
  170. Integrating a function of a complex variable in the complex plane is possible
  171. with some work. The function must be parameterized as a function of a real
  172. variable as follows: f(z) = f(x+i*y) = f(x(t) + i*y(t)), where t is real.
  173. We then note that dz = ( x'(t) + i*y'(t) ) dt, where ' denote differentiation
  174. with respect to t. Therefore we have
  175.  
  176.              f(z) dz = f( x(t) + i*y(t) ) * ( x'(t) + i*y'(t) ) dt.
  177.  
  178. Example: We want to integrate 1/z along the unit circle centered at the 
  179. origin. The complex variable z can be described by z = cos(t) + i * sin(t).
  180. Therefore we have
  181.  
  182.         1/z dz = ( 1 / (cos(t) + i * sin(t) ) * ( -sin(t) + i*cos(t) ) dt.
  183.  
  184. The following is from an actual session:
  185.  
  186. >int( ( 1 / (cos(t) + i * sin(t) ) ) * ( -sin(t) + i*cos(t) ),4,0,2*pi)
  187. 3.73223e-18 + i * 6.28319
  188.  
  189. With the exception of some small round-off error, we obtain approximately
  190. 2*pi*i as expected.
  191.  
  192. BUILT IN CONSTANTS
  193.  
  194. mathematical constants:   pi (3.14159...)   gamma (.5772...)
  195.  
  196. physical constants:
  197.  
  198. c0   speed of light in vacuum (m/s)    N   Avagadro's constant (1/mole)
  199. h    Planck's constant  (J-s)          R   Universal gas constant (J/K-mole)
  200. qe   electron charge (C)               k   Boltzmann's constant (J/K)
  201. eps  permittivity constant (F/m)       Me  electron mass (kg)
  202. mu   permeability constant (H/m)       Mn  neutron mass  (kg)
  203. G    Grav constant (N-m^2/kg^2)        Mp  proton mass   (kg)
  204. g    standard gravity (m/s^2)
  205.  
  206. CONVERSION FUNCTIONS (must use real arguments)
  207.  
  208. M_m(),   m_M()     miles to meters, meters to miles
  209. M_yd(),  yd_M()    miles to yards, yards to miles
  210. M_ft(),  ft_M()    miles to feet,  ....
  211. m_in(),  in_ft()   meters to inches, ....
  212. cm_in(), in_cm()   cm to inches, ....
  213. F_C(), C_F()       degrees Fahrenheit to degrees Celsius, ....
  214. K_C(), C_K()       degrees Kelvin to degrees Celsius, ....
  215. K_F(), F_K()       degrees Kelvin to degrees Fahrenheit, ....
  216. lb_kg(), kg_lb()   pounds to kilograms, ....    (under standard gravity)
  217. lb_N(),  N_lb()    pounds to Newtons, ....
  218. Btu_J(), J_Btu()   Btu's to Joules, ....
  219. kWh_J(), J_kWh()   kilo-Watt hours to Joules, ....
  220. kW_hp(), hp_kW()   kilo-Watt hours to horse-power, ....
  221.  
  222. FILES
  223.  
  224. You can write data to a file only from the z=?> (or T=?>) prompt. Enter a
  225. function of z, at the z=?> prompt press f <CR>, you will be prompted for a
  226. file name and whether you want to write the domain and range or just the
  227. range. If you request the domain and range to be written, the real part of z
  228. will be written to the first column, the imaginary part of z to the second
  229. column, the real part of f(z) to the third column and finally the imaginary
  230. part of f(z) to the fourth column. If you request the range (only) to be
  231. written, the real and imaginary parts of f(z) will be written to the first and
  232. second columns, respectively. The file will be close when you press "q" from
  233. the z=?> (or T=?>) prompt. You can plot your data with any standard plotting
  234. package. A shareware plotting package is available from this author if you are
  235. in need (see beginning of this document).