Arguments to functions must be enclosed by parentheses. For instance
cos(pi)
evaluates to 1
.
Arguments to trigonometric functions must be in radians. Use set values to convert between degrees and radian, if desired. Here is an example of varying an angle in degrees and calculating the function in radians:
guess alphad 0
set alpha alphad * pi / 180
function 1 tan(alpha)
Some of these function have singular values. Be very careful
when using singular functions in a fit. There is no problem using
these functions in your fitting model so long as the singular point is
not included in your fit. The residual at this point will be so much
larger than any other in the fit, that the minimization will be
ill-posed. If the singular point is excluded either by judicious
choice of input grid or by excluding data from the fit by using the
x1 - x10
keywords, then the fit should be well behaved.
Functions with singular or undefined values for certain values of the
argument are error checked before evaluating to avoid run-time errors.
For example, ln(-1)
will return 0, atan(0)
will
return 10ˆ40, and so on. The program will therefore not crash if a
function is poorly used in a fitting model. The quality of the fit,
however, should be quite poor.
Int and nint might be troublesome functions in the fit, since changes
in the argument can produce absolutely no change in the evaluation of
the function. They are included for completeness -- use them with
caution. Note that int(3.7) = 3
and nint(3.7) = 4
.
Also, int(2)
might return 1 if your computer
represents the floating point value of 2 as, for instance, 1.99999837,
which is a valid representation.
The commas in the argument lists to the special functions of multiple arguments are necessary. In my experience, a reasonably good first guess for the peak positions of the Gaussian and Lorentzian functions is necessary for a well-posed fitting problem.
The temperatures in the Einstein function are in Kelvin and the reduced mass is in atomic units. Here is a good way to specify the reduced mass:
set r_cu 63.546
set r_ba 137.33
set rmass 1 / ( 1/r_cu + 1/r_ba )
At present, pi
is the only recognized special constant.
This is a function of ten arguments (!) that returns the position of a diffraction peak in two-theta and in degrees. The arguments are the x-ray wavelength, the Miller indices, the cell axis lengths, and the cell angles. The wavelength and axis lengths must be in consistent units. That is, all four must be in angstroms or in nanometers or whatever. The function will behave identically for different units, so long as they are consistent. The cell angles are in degrees. Fractions of degrees should be specified as decimals rather than minutes and seconds of arc. All ten arguments must be specified. The value for the angle that is returned is the angle of the two-theta circle.
This function only is used for peak position, which is dependent only
on the geometry of the unit cell of a crystal. It is derived from
Bragg's law and uses the formulas for interplanar spacing and cell
volume in a triclinic cell. This should be well described in any
introductory crystallography text book.