home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast2.iso
/
calculat
/
sm30a.zip
/
SYMBMATH.H18
< prev
next >
Wrap
Text File
|
1993-11-07
|
6KB
|
136 lines
3.4. Libraries and Packages
A library is a file of an external function, which filename is its
function name within 8 letters plus extension .(x). e.g. the library named
sin.(x) is a file of the sin(x) function definition.
You can protect a library (e.g. sin.(x)) for write-protect by
the DOS command:
attrib +r sin.(x)
or for hidden-protect by the DOS command:
attrib +h sin.(x)
You can remove the write-protect of a library by the DOS command:
attrib -r sin.(x)
or remove the hidden-protect by the DOS command:
attrib -h sin.(x)
The library (*.(x) file) is similar to the MS-DOS .bat file. You
need not to load or read the library by any command. SymbMath automatically
load the library when it is needed. For example, when you use the sin(x)
function first time, the library sin.(x) will be autoloaded. The library
must be in the default directory, otherwise the library is not loaded and
the function is not working. Only the assignments in the library can be
loaded, and others in the library will be omitted, but all of these
assignments will be not evaluated when they are loaded. You can clear the
library sin.(x) from memory by clear(sin(x)).
You can have libraries (external functions) as many as your disk
space available. You should use the "one function per file" convenience.
Note that all names of the variables in libraries and packages
are public (global) except for those declared by local() and name
conflicts must be avoided.
A package is the SymbMath program file which filename has not
extension .(x). It is recommanded that its filename has the extension .sm.
A package is similiar to a libarary, but the package must be read
by a command
readfile("filename")
The filename can be any MS-DOS filename. It is recommended that
the filename is same function name used in your program, plus the
extension .sm. e.g. inte.sm is the filename of the integral package as
the name of integral function is inte().
After reading the package, you can call the commands in the
package from your program.
The readfile() command must be in a single line anywhere.
Many packages can be read at a time.
Alternately, a part of the package file rather than the whole
package file can be copied into the Input window by pressing <F7>
(external copy) in order to save memory space.
You can convert a package of f.sm into a library by renaming f.sm
to f.(x) for auto loading, or a library f.(x) to a package by renaming
f.(x) to f.sm for not auto loading.
There are many libraries and packages. The following are some
of them.
Table 3.4.1 Libraries and Packages
------------------------------------------------------------------------
File Name Package Function
plot.(x) plotting functions.
d.(x) derivatives.
inte.(x) integrals.
sin.(x) sin(x) function.
cos.(x) cos(x) function.
fac.(x) n!.
sign.(x) sign(x) function.
abs.(x) abs(x) function.
arg.(x) arg(x) function.
sum.(x) sum function.
NInte.(x) numeric integration.
NSolve.(x) numeric solver of equation.
DSolve.(x) differential equation solver.
gamma.(x) gamma function.
ei.(x) exponential integral function.
series.(x) Taylor series.
partSum.(x) partial sum.
infSum.(x) infinite sum.
sinh.(x) sinh(x) function.
cosh.(x) cosh(x) function.
average.(x) average([x]) function.
listSum.(x) sum of list of data.
react.(x) chemical reactions database.
phoneNo.(x) phone No. database.
.......................................................................
init.sm initial package when running the program in
the Input window. It contains switches on the
default status.
chemical.sm the atomic weight of chemical elements.
tExpand.sm expansion of trig functions.
expandLn.sm expand ln(x*y).
ExpandGa.sm expand gamma(n,x).
ExpandEi.sm expand ei(n,x).
units.sm an units conversion.
listPlot.sm plotting a list of data.
plotData.sm intefacing software PlotData.
-----------------------------------------------------------------------
You can get help for all libraries by the library Index command
in the Help menu. You first open the library index window by this command,
then open a library by selecting its library name in the library index
window.
3.4.1 Initial Package
When a program is run in the Input window, SymbMath first
automatically reads (or runs) the initial package "init.sm".
The commands in the "init.sm" package seems to be the SymbMath system
commands. You can read other packages (e.g. f.sm) in the initial
package "init.sm", so the commands in the package "f.sm" seems
to be in SymbMath system. You do this by adding the readfile("f.sm")
into the init.sm file:
readfile("f.sm")
3.4.2 ExpandLn Package
The lnexpand.sm package does the logarithmic expansion.
e.g. ln(a*b) is expanded into ln(a)+ln(b).
3.4.3 Chemical Calculation Package
SymbMath recognizes 100 symbols of chemical elements and
converts them into their atomic weights after the chemical package of
"Chemical.sm" is read.
Example 3.4.3.1.
Calculate the weight percentage of the element C in the molecule CH4.
IN: readfile("chemical.sm")
IN: numeric:=on
IN: C/(C+H*4)*100*%
OUT: 74.868 %
Example 3.4.3.2.
Calculate the molar concentration of CuO when 3 gram of CuO is in 0.5
litre of a solution.
IN: readfile("chemical.sm")
IN: numeric:=on
IN: g:=1/(Cu+O)*mol
IN: 3*g/(0.5*l)
OUT: 0.07543 mol/l