Generating your own data
Instead of plotting experimental data, physicists often like to
``doodle'' with mathematical expressions. Sometimes it's an attempt to
visualize a solution to some differential equation, to see if it makes
sense; or it's a first step in finding the nulls of a
complicated polynomial; possibly it's a quick way to look
up a family of standard mathematical functions. Programs like
maple or mathematica do these things extremely well, but in many
cases physica has sufficient capabilities, and is much faster.
As an example, execute the following commands:
x=[0:3*Pi:0.1]
y=x**2*exp(-x)
graph x,y
and you can see right away that the function y(x)=x2e-x
has a maximum value of about 0.55 near x=2. The vector x was
generated from 0 to three Pi in steps of 0.1, then we calculated y(x)
using the standard Fortran syntax, and plotted y vs.
x in the usual way. We can look for the zeroes of the
first derivative, in this way:
set lintyp 9
graph\noaxes x,deriv(x,y,`interp')
replot
where we stipulated that the numerical derivative be calculated using
the method of interpolating splines. To see
what other possibilities exist, use help facility to look up
the description of the special function deriv().
Both the function and its derivative show up on the same plot:
Figure 2. A physicist's `doodle'. We plot here
the function y(x)=x2e-x
and its first derivative (the dotted line).
Encapsulated PostScript (.eps) file.
For the derivative, we set the line type (set lintyp) to
something other than the default value of 0, the solid line type (use
display lines to see what line types are available).
Numerical integration, differentiation, spline interpolation, a large
library of special functions (would you like to know what the
fourth-order Laguerre polynomial looks like? - try y=laguerre(4,x)) - these are all things that physica does
with ease. It is pointless to try to provide you with a
comprehensive list of its capabilities, this is what the manuals are
for. Remember, you don't have to know all of physica commands, just
get the feel for where things are in the manual, to be able to look
them up quickly when needed. For example, the special functions known
to physica are described in Chapter 7 of the Reference Manual.
Up: Table of contents
Next: Changing the default settings
Previous: Hardcopy
|