MathUser
Fall 1995
About MathUser
MathUser is published by Wolfram Research to provide news and
information
about Mathematica to registered Mathematica users.
MathUser is also
available
free of charge to other people interested in Mathematica. To be
added to
the
list of subscribers or to submit a change of address, send your postal
address
information to mathuser@wri.com, or call +1-217-398-5151. (In Europe, fax
+44-(0)1993-883800.) Note that MathUser is sent to your
registration
address,
the same address where all other Mathematica information and
mailings are
sent.
Electronic copies of this and earlier issues of MathUser are
available on
MathSource. This issue of MathUser is MathSource item
0207-863.
The MathSource item numbers of prior issues are:
Spring/Summer 1992 0202-655
Fall/Winter 1992
0204-477
Spring/Summer 1993 0205-759
Fall 1993 0205-827
Winter 1994 0206-907
Spring 1994 0205-771
Fall 1994 0207-278
Spring 1995 0207-593
Now you can get MathUser by email automatically when the current
issue is
available; send the text "subscribe mathuser" (without quotes) in a
message to
mathlist@wri.com.
Your comments and suggestions are important to us. Send letters to the
editor
at the address below. We are always interested in hearing ideas for topics
to
be covered in MathUser.
How to Contact Us
Wolfram Research, Inc.
100 Trade Center Drive, Champaign, IL 61820-7237, USA
phone: +1-217-398-0700; fax: +1-217-398-0747
customer service and orders: +1-217-398-5151
technical support: +1-217-398-6500
Wolfram Research Europe Ltd.
10 Blenheim Office Park, Lower Road, Long Hanborough,
Oxfordshire OX8 8LN, UNITED KINGDOM
phone: +44-(0)1993-883400
fax: +44-(0)1993-883800
Wolfram Research Asia Ltd.
Izumi Building 8F
3-2-15 Misaki-cho
Chiyoda-ku, Tokyo 101, JAPAN
phone: +81-(0)3-5276-0506
fax: +81-(0)3-5276-0509
World Wide Web
Wolfram Research: http://www.wri.com/
Internet email addresses
general and sales information: info@wri.com
European information: info-europe@wri.com
Asian information: info-asia@wri.com
customer service and orders: orders@wri.com
user registration and password requests: register@wri.com
technical questions and support: support@wri.com
European technical questions and support: support-europe@wri.com
bug reports: support@wri.com
suggestions: suggestions@wri.com
training: training@wri.com
grant programs: grants@wri.com
Web suggestions: webmaster@wri.com
this newsletter: mathuser@wri.com
MathSource
World Wide Web: http://www.wri.com/MathSource.html
FTP: mathsource.wri.com
Gopher: mathsource.wri.com
mail server: mathsource@wri.com
dialup: +1-217-398-1898
system administrator: ms-admin@wri.com
On the cover
"Transitions", Mathematica graphic by Igor Bakshee. One of a series
of
images
to be included in the Graphica book.
1995 Wolfram Research, Inc. MathUser (ISSN 1062-7030) is published
several
times a year by Wolfram Research, Inc., 100 Trade Center Drive, Champaign,
IL
61820-7237, USA; email: mathuser@wri.com.
Mathematica, MathLink, and MathSource are registered
trademarks, and
MathUser
is a trademark of Wolfram Research, Inc. Mathematica is not
associated
with
Mathematica Policy Research, Inc. or MathTech, Inc. All other product
names
mentioned are trademarks of their producers.
Mathematica for Microsoft Word
Now in testing, this new product will be available soon for the Macintosh
and
Microsoft Windows
Microsoft Word, the world's most powerful and popular word processor, will
soon be available as an interface to Mathematica. If you are
already using
Word to create technical documents and want to incorporate live
mathematical
calculations, this will be an ideal combination.
You work directly in Word, entering calculations and receiving results
(including graphics) in a notebook-style interface like the familiar
Mathematica front end. In addition, you can use all of Word's
features for
advanced document processing and page layout. These features include
spelling
and grammar checking (which automatically ignore Mathematica input
and
output), equation and figure numbering, indexing and cross-referencing,
multicolumn layout, text flow around graphics and frames, and a drawing
environment for customizing graphics.
The Mathematica input cells are "live" and can be edited and
reevaluated.
Corresponding output cells will be updated in place, even if they have
been
moved to distant locations in the document. You can also automatically
hide or
delete all the inputs, outputs, or prompts. This means that you could have
the
output distributed throughout your document, perhaps in movable, resizable
frames, with all of the input collected at the end. Hide the input, and
you
have a publication-ready manuscript; show it, and you have a live
mathematical
document.
Those who want an alternative to the traditional Mathematica
notebook
interface can take advantage of Word's easy-to-use macro language,
WordBasic,
to create interface elements like custom dialog boxes, toolbars of common
functions, on-screen forms with buttons and pop-up menus, and so forth.
The
interface itself is written in WordBasic, and access to the full source
code
allows you to modify or enhance it.
Mathematica for Microsoft Word will be announced on our Web site as
soon
as
it is available. Check the site for the latest news and ordering
information.
First Asian Technology Conference in Mathematics
December 18-21, 1995
National Institute of Education, Singapore
Among the plenary talks will be one by Jerry Uhl (University of Illinois),
co-author of Calculus&Mathematica: "Visual Interactive Learning
through
Electronic Courseware". There will be several other talks by
Mathematica
developers and Mathematica users from Japan, Hong Kong, and other
Asian
countries. Wolfram Research, Inc. will also hold training and lab sessions
at
the conference.
For more information, contact Ho Kheong Fong at +65-(0)460-5310, send a
fax
to +65-(0)469-8952, or email fonghk@nievax.nie.ac.sg. Or contact David
Washburn at Wolfram Research, 217-398-0700, or email washburn@wri.com.
1995 Mathematica Developer Conference
The Inside Track for Advanced Mathematica Users
October 5-8, 1995
University of Illinois, Illini Union
Urbana-Champaign, Illinois
The 1995 Mathematica Developer Conference will give advanced users
an
opportunity to meet Wolfram Research staff and other Mathematica
experts
to
share and exchange experiences and ideas. The conference will feature
workshops, forums, luncheons, a computer lab, and a series of informative,
practical sessions. Many of the sessions are dedicated to helping users
create
Mathematica packages, MathLink applications,
Mathematica books, and
interactive texts. Attendees will be introduced to new features of
Mathematica
currently in development, and will be encouraged to integrate these
features
into their work.
For further information or to register, call Donna Lents-Johnson at
217-398-0700, send
email to devconf@wri.com, or visit our Web site at
http://www.wri.com/devconf.
New Version of Mathematica Now in Testing
With over a million people around the world depending on
Mathematica for
fast,
reliable results, Wolfram Research takes product testing very seriously.
Every
new version of Mathematica is
subjected to an exhaustive battery of automated and human testing. The
goal
of this long and
creatively demanding testing process is to make sure that the software is
of
the highest quality.
The next major new version of Mathematica, which has been under
development
for the past three years, is now completing its final alpha test. Although
alpha testing is primarily internal, a small group of external
Mathematica
developers have participated in three of the alpha tests. As we had hoped,
many testers' reports describe bugs and problems that will be fixed before
the
next stage of testing. Their constructive criticism is also helping to
shape
the design of the product. We received encouraging comments concerning
both
the front end and the kernel: "Beautiful... congratulations.";
"Breakthrough!"; "The front end is just marvelous!"; "A fine
accomplishment.
Thanks!"
Mathematica Plus subscribers will receive the upcoming version
automatically
as soon as it is released. For more information about this program,
contact
Wolfram Research.
World Wide Web
Mathematica Courseware Directory Available on the Web
Visit the Wolfram Research Web site (http://www.wri.com/) to discover how
educators around the world are using Mathematica in the classroom.
The new
on-line directory contains courseware descriptions from educators at
colleges,
universities, and high schools who have integrated Mathematica into
their
teaching programs. From algebra and calculus to physics and graduate-level
courses, the programs in the directory provide useful examples that cover
a
wide range of disciplines.
You can also find information on the Web site about Wolfram Research's
flexible academic purchase programs, Mathematica for Students,
Mathematica
for
High Schools, and other resources and products designed specifically
for
educators and students.
Interactive Mathematica Demo Premieres on the Web
(http://www.wri.com/demo/)
A revolutionary interactive demo has been added to the Wolfram Research
site.
It allows Web users without a copy of Mathematica to sample
Mathematica's
capabilities.
When you click to start the demo from your Web browser, a
Mathematica
kernel
is launched on a computer at Wolfram Research in Champaign, Illinois. Your
input is sent to the kernel for processing and the output is returned to
your
screen.
New Mathematica Notebook to HTML Conversion Program Available
Free
math2html is now available free on MathSource as item 0207-829.
Now you can easily put your Mathematica notebooks on the World Wide
Web.
The
math2html program, written by H. Edward Donley from Indiana University of
Pennsylvania, is a PERL program that converts Mathematica notebooks
to
HTML
format for viewing on the Web.
math2html creates an evaluated or an unevaluated version of your
Mathematica
notebook in the form of an HTML document. Closed cell groups are placed in
their own HTML documents and are linked to their parent documents. You can
specify which series of adjacent graphics are combined into MPEG movies
and
which are converted to individual GIF images (math2html does not convert
sounds or bitmap images). Input cells can be converted into HTML forms
that
can be sent to a Mathematica kernel.
New Versions of Mathematica
NEXTSTEP for SPARC
Mathematica 2.2 will be available soon under NEXTSTEP for SPARC.
This new
version is functionally identical to Mathematica for NEXTSTEP
Motorola,
Intel,
and HP PA-RISC computers, and is compatible with all other notebook front
end
versions.
LINUX
Mathematica 2.2 is now available under LINUX. This new version
includes a
text-based interface and support for interprocess communication and remote
computing via MathLink.
Windows 95
An update for Mathematica 2.2.3 for Microsoft Windows 95 users who
did not
install TCP/IP is now available on MathSource, item 0207-841. This
update
replaces Mathematica's local protocol.
Acquire New Mathematica Skills in a Training Course near You
Sign up soon for one-day courses in Boston, New York, and Washington, DC
September 25-29 and November 6-10, 1995
Mathematica training courses are going on an east coast U.S. tour,
and if
you
live nearby, you won't want to miss it! The courses cover practical skills
that you can take back to work and use the very next day. It's the fastest
way
to learn how to apply Mathematica efficiently and to increase your
productivity on the job.
Space is limited, so register early! For specific course dates or to
register, call 1-800-441-6284, ext. 244 (U.S. and Canada only), or email
training@wri.com for an electronic registration form. For more
information,
you can also check the training section on our Web site:
http://www.wri.com/services/training/traintour/
Introduction to Mathematica ($400)
Ben Friedman, Robert Dickau, Todd Ramsburg
Wolfram Research staff
This basic training course gives new users a thorough introduction to
using
the system's
numeric, symbolic, graphical, and programming features. In this
problem-solving, hands-on session, you will learn just what you need to
know
to start applying Mathematica to technical problems you encounter
on a
daily
basis.
Programming with Mathematica ($400)
Richard Gaylord
Professor, Department of Materials Science, University of Illinois at
Urbana-Champaign
Co-author, Introduction to Programming with Mathematica and
Computer
Simulations with Mathematica
Learn to use the Mathematica programming language by discovering
how
pattern
matching works and how expressions are evaluated. Learn tips and
techniques
for writing Mathematica programs that are much shorter than in C or
Fortran.
Data Analysis with Mathematica ($500)
William Shaw
Principal Consultant, Oxford System Solutions
Co-author, Applied Mathematica: Getting Started, Getting It
Done
Professionals in engineering, physics, biology, finance, and other applied
sciences can benefit by learning to use Mathematica effectively for
data
analysis. This course covers methods for importing data, data modeling,
how to
use 2D and 3D visualization tools, regression, how to incorporate
functions
from the new Time Series Pack, and more.
Financial Modeling with Mathematica ($500)
William Shaw
Principal Consultant, Oxford System Solutions
Co-author, Applied Mathematica: Getting Started, Getting It
Done
Discover how to harness Mathematica as a tool for complex
analytical
modeling, rapid development, verification for testing code, and
visualization.
Sections include data import mechanisms and regression tools, derivatives,
portfolio covariance analysis and optimization, and enhancements for the
Mathematica Finance and Time Series Packs, MathLink for
Excel, and
MathLive.
This course is ideal for quantitative analysts and other financial
engineering
professionals.
Additional Mathematica Training
Mathematica Training Courses by Principia Consulting
Anaheim, CA, September 19-21.
For more information, contact Dave Wagner at 303-786-8371.
Mathematica Training Courses by Allan Hayes
Introduction to Mathematica, Intermediate Graphics and
Visualization,
Intermediate Programming. De Montfort University, Leicester, UK, September
13-15.
For more information, contact Jackie Mackay at +44-(0)171-490-1609, or
email
jackie@ledge.co.uk.
Mathematica Training Courses by CorporateU
Computation and Data Analysis, September 19-October 10; Mathematica
Programming,
October 17-November 11.
For more information, contact CorporateU, Philadelphia, PA, at
215-988-2150.
Mathematica Training Seminar by Additive
Friedrichsdorf, Germany, September 29.
For more information, contact Beate Reif at +49-(0)6172-77015.
Principles of Mathematica by Uni Software Plus
Hands-on introductory course.
Hagenburg, Austria, September 28Ð30.
For more information, contact Herbert Exner at +43-(0)723-63-338, or
fax
+43-(0)723-63-33830, or email usp@unisoft.co.at.
How to Become a Mathematica Master
A one-day systematic introductory course for beginners and intermediates.
For exact seminar dates (October/November) and locations in Germany,
contact
QT Software at
+49-(0)89-33297-0, or email 100614.350@compuserve.com.
Mathematica on Wall Street: Derivatives Analysis Workshops
New York, NY, October 2; Chicago, IL, November 13; London, UK, December
20.
For more information, contact Variable Symbols, Inc. at 510-652-8462.
Mathematica for Students Is Just What Students Need for School
This
Fall
Now Includes Free World Wide Web Browser--A Limited-Time Special Offer*
As more and more colleges incorporate Mathematica into the
curriculum,
more
and more students want a copy of their own to take home. At a specially
reduced price, Mathematica for Students fits the bill
perfectly--it's a
full-function version of Mathematica, at a price that's just right
for the
student budget. And for a limited time only, Mathematica for
Students
comes
with a free copy of the renowned World Wide Web browser, Enhanced Mosaic
2.0.
As students use Mathematica to delve deeper into mathematics than
they
ever
could before, concepts become clearer and easy-to-create graphics bring
ideas
to life. The connection to real-world applications makes math more
exciting to
learn, and knowing how to use Mathematica is a valuable skill that
students
can put to use immediately for homework in all kinds of engineering and
science courses.
Students who use Mathematica in school find they have a head start
when it
comes to looking for a job after graduation. Since Mathematica is
what the
professionals use, including it on your resume can certainly give you an
advantage!
*Special offer in U.S. and Canada only.
1995-1996 High School Grants Awarded
Recipients Develop Mathematica-based Courseware to Share with
Educators
Worldwide
As was the case with the response to last fall's announcement of a new
Visiting Scholar Grant Program, response to our new High School Grant
Program
was far greater than we had imagined! High school teachers around the
world
are bringing Mathematica into their classrooms in record numbers,
and
sending
their students off to college very well prepared.
Grant recipients attended a three-day workshop at Wolfram Research
headquarters in Champaign this summer. A Mathematica basic training
course,
presentations by experienced Mathematica courseware developers, and
discussion
time with fellow grant recipients and Wolfram Research staff gave
recipients
inspiration and practical information as they continue to develop their
own
courseware projects.
As part of the award, grant recipients also received copies of
Mathematica
for the computers in their school labs, so they can actually put the
courseware they develop to the test with their students this fall. Plans
so
far include creating lessons in the form of Mathematica notebooks
to teach
topics in algebra, trigonometry, geometry, calculus, physics, statistics,
and
computer science. The resulting courseware will be published on a sample
courseware CD-ROM, and will be available free of charge to high school
educators.
"Mathematica is an invaluable tool for the next generation of
scientists,
engineers, and business leaders. I look forward to exposing my students to
this top quality software product."
Gordon Locke-Scobie
High School Grant Recipient
1995-1996 High School Grant Recipients
Daniel Boice
Southwest Research
Institute
San Antonio, Texas
James Button
Antilles School
Charlotte Amalie, Virgin Islands
Carol Castellon
University Laboratory High School
Urbana, Illinois
Sergey Feofanov
Filer High School
Filer, Idaho
Sally Illman
Roosevelt High School
Seattle, Washington
Michael Grasse
Elk Grove High School
Elk Grove Village, Illinois
Richard Kick
Hinsdale Central High School
Hinsdale, Illinois
Gordon Locke-Scobie
Vienna International School
Austria
Thomas Ramsey
Mentor High School
Mentor, Ohio
Reinhard Simonovits
University of Graz
Graz, Austria
Christopher Thiel
St. Francis High School
La Canada, California
John Tinnin
Kaycee Junior/Senior High School
Kaycee, Wyoming
- Rock Island High School
Rock Island, Illinois
For information on how to apply for a 1996-1997 grant, email
grants@wri.com.
High School Teachers Get Mathematica for Less
Major Discounts Make It Affordable for High School Classrooms
Mathematica for High Schools contains a full-function version of
Mathematica,
a user interface guide, and Mathematica: The Student Book, a
comprehensive
manual filled with practical math and science examples that teachers and
students can use in class. Substantial educational discounts make this
special
high school version of Mathematica available to high school
teachers for
up to
80% off the price of the professional version!
Using Mathematica makes it possible for teachers to present
students with
more real-world examples and to incorporate two- and three-dimensional
graphics that are too time-consuming or complex to draw on the blackboard.
In
Mathematica's interactive environment, students discover how to
explore
math
on their own, and often find that they suddenly understand concepts that
were
otherwise too difficult to grasp. Equipped with an alternative approach to
presenting information, teachers can enhance their students' understanding
of
all kinds of topics in math and science classes.
Those who have the opportunity to use Mathematica in school tell us
they
are
pleased they did. As one Illinois high school student who was in the
Calculus&Mathematica Distance Education Program explained, "Most of
all,
Mathematica is great because it applies EVERYTHING to real
situations. I
feel
that traditional math courses I have taken have fallen short in this area.
This course is showing me how math is everywhere in the real world. I
can't
wait to get out there and put it to the test."
5-Packs and 10-Packs Are Perfect for School Labs
If you teach with Mathematica in a school computer lab, consider a
Mathematica
for High Schools 5-pack or 10-pack for significant savings off the
already-low
price of Mathematica for High Schools. (District-wide site
licenses are
also
available.)
Mathematica for High Schools is available for Macintosh and
Microsoft
Windows.
"I find that students are more willing to 'play' with the mathematics
using
Mathematica than they would if they had to grind each example out
on their
own. Many students become more independent problem-solvers as a result of
working with Mathematica."
Mike Chupa, math instructor
Tower Hill School, Delaware
"Now I know more about calculus than just definitions. I could take
calculus
and apply it to a situation really well."
Matthew Stanley, student
Camp Point Central High School, Illinois
"When it's presented to you on the computer, sometimes it's like you're
seeing
in a different way and it clicks. That was the way it was for me. Our
teacher
would explain something to us. Then I would come over and look at it in a
different way, and then I understood."
Maria Monge, student
Fairfield Community High School, Illinois
Visiting Scholars' Progress Will Benefit Others
Grant recipients work on projects at Wolfram Research headquarters
Mathematica-based application packages, courseware, and texts are
the
focus of
projects that earned a select group of researchers and educators
invitations
to collaborate with Wolfram Research staff at the company's headquarters.
Among the grant recipients who visited us this summer two took advantage
of
the expertise of nearby staff to make headway on some exciting educational
projects.
Phillip Kent from Imperial College (London) spent time developing
strategies
for World Wide Web-based Mathematica educational materials. He
organized a
meeting that brought together Wolfram Research staff and the director of
the
U.S. Department of Energy's Undergraduate Computational Engineering and
Sciences project, Thomas Marchioro. The discussion focused on courses that
use
Mathematica to teach problem-solving skills and on the development
of
public-domain software for publishing Mathematica materials in an
interactive
form on the Web. This spurred the establishment of an active email group
as a
forum for continuing discussion on these topics. You can access more
information on the Web at URL
http://uep.ameslab.gov/dev/tlm/uces_wri.html.
Grant Keady from the Department of Mathematics at the University of
Western
Australia worked on developing a series of instructional
Mathematica
notebooks
to accompany the well-known text, Advanced Engineering Mathematics,
by
Zill
and Cullen. You can access these notebooks on the Web site at URL
http://www.pws.com/diffeq.html. He also used the time to pursue his
interests
in links between numerical computing and computer algebra, particularly
using
MathLink.
For information on the Mathematica Visiting Scholar Grant Program,
email
grants@wri.com.
Mathematica at the top!
For the past two years, Stan Wagon, author of several Mathematica
books,
has
organized a highly successful workshop in Colorado called
"Mathematica in
the
Mountains". This year, Stan's workshop attracted more than 30 high school
and
college teachers. Participants scaled new heights in the use of
Mathematica
while on a hike to the summit of Torreys Peak (14,267 ft.) in the middle
of a
hailstorm.
The World of Mathematica Graphics on Display
Be among the first to receive this new series of art books.
Since the introduction of Mathematica seven years ago, the system's
powerful
graphics capabilities have earned it widespread recognition as an
essential
tool for effectively communicating complex scientific and mathematical
ideas.
Quickly adopted by researchers and scientists, Mathematica is
commonly
used
to create the graphics now seen in standard textbooks and appearing in
technical journals around the world.
Even beyond the scientific community, however, many have tapped its
powerful
capabilities to create stunning images that have captured the attention of
technical and nontechnical people alike. Soon the talents of a few people
who
have become experts in creating elaborate and impressive images using
Mathematica will be showcased in the Graphica books, a new
series
of
hardcover, large-format, full-color art books.
This is not the first time images created using Mathematica have
ventured
outside purely scientific applications. Mathematica graphics have
found
their
way into Hollywood special effects, architecture, sculpture, and
industrial
and graphic design. Images by the physicist and artist whose works are
featured in Graphica 2, for example, have been reproduced on
clothing
fabrics,
wallpaper, and automobile upholstery, and not surprisingly, as fine art
prints.
Now this spectacular series can be made a part of your own library
collection
at home or work. The images in these books may even inspire you to realize
the
aesthetic potential in your own Mathematica-based creations.
As a Mathematica user, you are invited to register for a special
Graphica
charter offer. For more information, send email to info@graphica.com.
Many of these and other images are available for licensing. For more
information, email licensing@graphica.com.
Reading and Writing External Files
Sometimes users have to work with data stored not in a notebook but in
some
external file. Mathematica has many facilities for dealing with
external
files. Text or binary data can be read in, manipulated in some way, and
then
written back out.
*Viewing the Contents of a File
Before reading a file into Mathematica, you can look at the
contents with
the
!! command.
!!polyfile
1 + 2*x + x^2
*Reading and Writing Expressions
The Get command is the basic command for reading a file into
Mathematica.
The
commands in the file are read in as if you had typed them into your
session
directly.
Get["polyfile"]
1 + 2 x + x2
This is the equivalent short form.
<<polyfile
1 + 2 x + x2
We can use the corresponding Put command (or the short form
>>) to write
an
expression out to a file.
Factor[x^2 + 2 x + 1] >>: factorfile
!!factorfile
(1 + x)^2
*Reading in Data
Mathematica input/output commands are often used to read data that
are in
tabular form. The ReadList command reads in each row as a sublist
of a
larger
list.
!!matrixfile
1 2 3
4 5 6
mymatrix = ReadList["matrixfile",
{Number, Number, Number}]
{{1, 2, 3}, {4, 5, 6}}
The arrangement of the data in the external file is irrelevant to the way
in
which it is read. We can read in the numbers as pairs.
pairmatrix = ReadList["matrixfile", {Number, Number}]
{{1, 2}, {3, 4}, {5, 6}}
We can also read in the numbers as a flat list.
mylist = ReadList["matrixfile", Number]
{1, 2, 3, 4, 5, 6}
If you don't know ahead of time how many columns of data you have, you can
add
the RecordLists option. If this option is set to True, then each
line of
data
is read into a separate sublist.
mymatrix = ReadList["matrixfile", Number,
RecordLists -> True]
{{1, 2, 3}, {4, 5, 6}}
Another way to read this data is to open a stream to the file and read one
line at a time. The OpenRead command creates an
InputStream object.
mystream = OpenRead["matrixfile"]
InputStream[matrixfile, 11]
The Read command reads data from the stream, one line at a time.
line1 = Read[mystream,
{Number, Number, Number}]
{1, 2, 3}
line2 = Read[mystream,
{Number, Number, Number}]
{4, 5, 6}
When we have finished reading data from the stream, we use the
Close
command.
Close[mystream]
matrixfile
Putting the lines into a list gives the same matrix as the one we got
using
ReadList.
mymatrix = {line1, line2}
{{1, 2, 3}, {4, 5, 6}}
*Reading More Complicated Files
In the previous simple example, it was more efficient to use
ReadList than
to
open a stream and use Read. However, streams let you read
complicated
files
that ReadList cannot handle. We need to know the structure of the
file
before
being able to read it properly.
!!polymatrixfile
Here is a polynomial:
1 + 2x + x^2
Here is a matrix:
1 2 3
4 5 6
As before, we open a stream to this file.
mystream = OpenRead["polymatrixfile"]
InputStream[polymatrixfile, 7]
We use the Read command to read off the first piece of text as a
string.
mystring1 = Read[mystream, String]
Here is a polynomial:
We use Read again, specifying that an expression (the polynomial)
is to be
read.
mypoly = Read[mystream, Expression]
1 + 2 x + x2
Reading an expression does not advance us to the next line, so we need to
read
the newline character to throw it away.
Read[mystream, Character];
Now we can read the second piece of text as a string.
mystring2 = Read[mystream, String]
Here is a matrix:
Since we know that a table of data is next, we can use ReadList
on the
stream.
mymatrix = ReadList[mystream,
Number, RecordLists -> True]
{{1, 2, 3}, {4, 5, 6}}
Finally, we close the file.
Close[mystream]
polymatrixfile
*Reading Comma-Separated Data
Mathematica does not have a built-in command for reading
comma-separated
data.
!!commafile
1,2,3
4,5,6
There are several ways to read this data in as a matrix. You need to know
the
number of columns to use the following combination of commands.
Partition[Map[First, ReadList[
"commafile", {Number, Character}]],
3]
{{1, 2, 3}, {4, 5, 6}}
The next case supposes you don't know the number of columns; for large
files,
it is a little slower than the previous example.
Map[ToExpression, ReadList[
"commafile", Word,
RecordLists -> True,
WordSeparators -> {",", " "}], {2}]
{{1, 2, 3}, {4, 5, 6}}
Using a pure function gives a slight improvement in speed.
Map[ToExpression[
StringJoin["{", #, "}"]]&,
ReadList["commafile", String]]
{{1, 2, 3}, {4, 5, 6}}
*Writing Data to a File
Suppose we want to write out the following matrix.
mymatrix2 =
{{10, 20, 30}, {40, 50, 60}};
There is no built-in command analogous to ReadList for writing a
list or
matrix of data to a file. However, we can use the following sequence of
commands. The OpenWrite command creates an OutputStream that
allows us to
write data to a file.
mystream = OpenWrite["matrixfile2"]
OutputStream[matrixfile2, 4]
The following converts the matrix into one string; the numbers are
separated
by spaces and the rows are separated by a newline character.
matrixstring = ToString[
TableForm[mymatrix2,
TableSpacing -> {0,1}] ]
10 20 30
40 50 60
FullForm[%]
"10 20 30\n40 50 60"
Now we write the string to mystream, pointing to the file matrixfile2.
WriteString[mystream, matrixstring]
We tidy up by closing the stream.
Close[mystream]
matrixfile2
We check that the data are in the file.
!!matrixfile2
10 20 30
40 50 60
While this routine is short, only spaces are allowed to separate the
columns
of data. The more flexible function WriteMatrix requires two
arguments: a
filename and a matrix. The optional third argument specifies the column
separator, with the tab character as the default.
WriteMatrix[file_String, matrix_List,
separator_String:"\t"] :=
With[{myfile = OpenWrite[file]},
Scan[(
WriteString[myfile, First[#]];
Scan[
WriteString[myfile, separator,
#]&, Rest[#]];
WriteString[myfile, "\n"]
)&,
matrix];
Close[myfile]
]
This uses the default separator.
WriteMatrix["tabfile", mymatrix2]
tabfile
!!tabfile
10 20 30
40 50 60
Here we use commas to separate the columns.
WriteMatrix["commafile",
mymatrix2, ","]
commafile
!!commafile
10,20,30
40,50,60
Rieman Zeta Poster
A special edition of the six-foot-long poster on the Riemann zeta function
(originally produced in 1990) has been re-created to honor the work of
Jerry
Keiper (1953-1995). Keiper was the leader of the numerics research and
development group at Wolfram Research and author of many numerical
algorithms
in Mathematica. Posters are available at cost from Wolfram Research
($15
U.S.,
$20 outside the U.S.; includes shipping and handling).
Mathematica Publishing Support
The Mathematica Developer Support program contributes to
Mathematica book
development by giving authors access to the technical publishing expertise
of
the Wolfram Research staff. We encourage authors to contact us for advice
on
book production and electronic publishing issues, as well as for critical
readings of manuscripts and information about how upcoming changes in
Mathematica will affect their projects. If you are writing a book,
the
Developer Support program can help you do things right, from technical and
production issues to connections with potential publishers.
At Wolfram Research we put great value on the many books and articles that
show people how to use Mathematica to learn, discover, and to get
things
done,
as well as those authors who use Mathematica to get their results.
More
than
100 books about Mathematica are now in print (see
http://www.wri.com/mathematica/books/index.html, and MathSource
item
0203-825); and some 2000 articles using Mathematica have appeared
in
scientific journals (see MathSource item 0205-018 for selective
bibliography).
As Mathematica expands in every field where mathematics is applied,
Wolfram
Research works with publishers to identify subject areas for needed new
Mathematica books, and locates authors to write them. And to ensure
that
published material is widely distributed in the Mathematica
community and
beyond, Wolfram Research regularly promotes Mathematica books
through
trade
shows and mailings. If you have a Mathematica book or article, we
would
very
much like to receive a copy of it (send to Librarian, Wolfram Research,
Inc.;
in return we will send you a free Mathematica T-shirt).
Some contact points for Mathematica authors:
Developer Support program devsupport@wri.com
Permissions Editor permissions@wri.com
WRILaTeX (documentation kit) wrilatex@wri.com
Notebook-to-TeX converter nb2tex@wri.com
Or call 217-398-0700
Mathematica's Popularity in Japan Explodes
Corporate and research organizations, universities, and high schools alike
discover its advantages
From high school students first learning algebra to experienced
researchers at
scientific institutions and universities, Mathematica is becoming
firmly
established as the technical computing system of choice. Considered an
indispensable productivity tool at major
corporations and research centers, Mathematica is being
increasingly
applied
in finance, optics, and all areas of engineering, with users at
organizations
such as Matsushita Electric Company,
Mitsubishi Electric, NTT, Nikon, Olympus, and the National Lab for High
Energy Physics.
Waseda University regularly uses Mathematica in science classes for
over
1900
first-year students, and recently hosted a training session for 800
students,
organized by Mathematica reseller Japan Information Processing
Service
(JIPS).
Customized academic purchase programs have made Mathematica
affordable for
all
types of universities. Among the over 80 universities that participate in
academic site programs are: the University of Tokyo, Tohoku University,
Waseda
University, Science University of Tokyo, Kobe University, Aizu University,
and
Chuo University.
Mathematica User Group in Japan Hosts Annual Meeting
Over 400 expected to attend
Mathematica User Conference
December 2, 1995
Tokyo Denki University-Hatoyama campus
Featuring keynote speakers from Wolfram Research's research and
development
team, user presentations, and an on-site computer lab.
For more information or to register, contact:
Scientist-sha
Yamazaki Building, 3-2 Kanda Surugadai
Chiyoda-ku, Tokyo 101, JAPAN
phone: 81-(0)3-3253-8992; fax: 81-(0)3-3255-6847;
email: info-asia@wri.com
The Mathematica Book Now Available in French
ISBN 2-87908-035-5
To get a copy of Mathematica: Le systeme informatique pour les
mathematiques,
the French translation of the definitive text on Mathematica by
Stephen
Wolfram, visit your local bookstore or contact the publisher:
Addison-Wesley France
41, Rue de Turbigo, 75003 Paris, France
phone: +33-(0)1-4887-9797; fax: +33-(0)1-4887-9799
Also available in German and Japanese. For more information contact:
Addison-Wesley Deutschland GmbH
+49-(0)228-98-5150
(Mathematica: Ein System fŸr Mathematik auf dem Computer; ISBN
3-89319-371-5)
Addison-Wesley Japan Ltd.
+81-(0)3-3291-4581
(Mathematica: A System for Doing Mathematics by Computer, in
Japanese;
ISBN
4- 7952-9614-6)
Fuzzy Logic
What is it, and why do engineers and researchers use it in their
work?
by Marian S. Stachowicz and Lance Beall, authors of the recently released
Mathematica Fuzzy Logic Pack
Mathematics based on classical set theory is only able to describe
situations
where a sharp boundary distinguishes elements having a certain property
from
those that do not. In terms of logic, a proposition is either true or
false,
with nothing in between.
More commonly in the real world, however, we have to deal with "unsharp"
phenomena--imprecise situations in which it is difficult to find a
boundary
between truth and falsehood.
Fuzzy logic extends conventional Boolean logic to handle the concept of
partial truth, so that truth values can be between "completely true" and
"completely false". Fuzzy logic can be used to describe complex systems
involving human linguistic descriptions, where Aristotelian two-valued
logic
is ineffective. With fuzzy set theory it is possible to relate linguistic
information to a computer, allowing us to communicate with computers more
naturally.
*Applications of Fuzzy Logic
Fuzzy logic is being applied increasingly over a wide range of fields.
This
technology is particularly popular in Japan, where over 1000 patents have
been
filed in the last few years. These fuzzy logic-based products have grossed
billions of dollars in sales around the world.
One of the first applications of fuzzy logic was to control a cement kiln
in
Denmark. Michio Sugeno displayed the power of fuzzy logic control by using
it
to fly a model helicopter. Some classic examples of problems that can be
solved with fuzzy control include truck-backing, balancing an inverted
pendulum, and controlling a hanging crane. Recently, fuzzy logic has been
used
to control everything from consumer electronics to the Sendai subway.
*Advantages of Fuzzy Logic
Fuzzy systems offer a number of benefits over traditional systems; it is
often
possible to develop solutions for complex, ill-defined problems quickly.
This
is especially true if there is a good deal of expert knowledge about a
process
or if the problem is easy to describe linguistically. Neither exact system
parameters nor complicated equations describing physical processes are
needed
to find a solution to a problem. Furthermore, once the system is designed
and
working, the linguistic variables and rules make maintenance easier.
Another advantage of fuzzy systems is that they tend to be more robust
than
traditional systems; they are naturally much more tolerant of fluctuating
or
changing system parameters or operating conditions. This could be an
important
advantage if you are looking for a solution for a noisy process or a
process
that changes over time. Using a smaller number of general rules that
describe
all situations, fuzzy systems can achieve a performance better than
traditional systems.
*The Future
Fuzzy systems are able to deal with vague and ambiguous information that
is
common in natural language. Since we live in an imprecise and uncertain
world,
it is pretty certain that fuzzy logic will be an important engineering
tool in
the next century.
*Fuzzy logic is being applied in an ever-broadening range of areas,
including:
linear and nonlinear process control (robotics, automation,
tracking)
consumer electronics (digital high-definition televisions, VCRs,
microwave
ovens, cameras)
pattern recognition (image processing, machine vision)
decision making (sensor fusion, risk analysis)
financial systems
information systems (database management, information retrieval)
data analysis
meteorology
Now Available
Fuzzy Logic Pack
Engineers and system designers can apply this pack's practical,
customizable
set of tools immediately to create, modify, and visualize all kinds of
fuzzy
logic-based systems. It's also ideal for a solid introduction on how to
use
fuzzy logic to quickly model nonlinear systems and systems with incomplete
or
ambiguous input data.
Signal Processing Pack
This set of Mathematica-based tools for working with signals and
systems
focuses on symbolic transforms, classical filter design, and signal
analysis
by transforms and graphical presentation.
These packs are available for all platforms that run Mathematica
2.2 or
later. (Versions that support the notebook front end are required in order
to
use on-line documentation.)
Free!
For a complete listing of all Mathematica-related
products--application-specific packages, courseware, books, journals, gift
items, and more--check our Web site or contact Wolfram Research today for
your
own Mathematica Products Catalog.
Q&A
Q: How do I plot two curves on the same plot, one as a solid line
and one as
a
dashed line? What about different colors?
A: You can graph several functions simultaneously by putting the
functions
into
the first argument of Plot as a list.
Plot[{Sin[8 x] E^(-x), E^(-x)}, {x,0,5}, PlotRange -> All];
The PlotStyle option is used to change the way the individual
curves are
displayed. PlotStyle is set to a list of sublists; each sublist
specifies
the
style for the corresponding curve. In the following plot, the first curve
is
not changed because the first sublist is empty, {}. The second curve is
drawn
as a thick, dashed, red line.
Plot[{Sin[8 x] E^(-x), E^(-x)}, {x,0,5}, PlotRange -> All,
PlotStyle -> {{},
{Thickness[.009],Dashing[{0.02}],
Hue[0.67]}}];
Q: How can I export a graphic from Mathematica for Windows
to
another
program?
A: The Mathematica 2.2.2 (or later) front end provides two
facilities for
exporting graphics to other applications. The easiest method is to use the
Windows Clipboard. To do this, select the graphic with the mouse pointer,
and
choose Copy under the Edit menu. Switch to the other Windows application,
position the cursor where you want to insert the graphic, and choose Paste
under the Edit menu. If the other Windows application supports graphics,
your
Mathematica graphic should show up in that application. Unlike
earlier
versions, the graphics pasted from Mathematica 2.2.2 (or later) can
be
rescaled without losing any resolution or introducing "jaggies".
The second way to export a graphic is to save it as a file. Once again,
select the graphic using the mouse pointer. This time, choose Export under
the
File menu. A dialog box will appear. Under "File Type:" there are several
kinds of files that can be saved. For a regular graphic, choose TIFF
(*.TIF),
Encapsulated PostScript (*.EPS), or Windows Metafile (*.WMF). Choose the
appropriate format, name the file with the proper extension (*.TIF, *.EPS,
or
*.WMF), and click OK. In order to import these files into another Windows
program, consult the documentation for that program.
Q: How do I add labels and change line styles in
ContourPlot?
A: To display labels in ContourPlot, use the option
FrameLabel. Axes is set
to
False by default, so axes labels are not rendered. The default for Frame
is
True, so all frame labels will be displayed.
ContourStyle modifies the appearance of the contour lines in the
plot. All
that you need is a list of graphics directives that affect lines.
ContourPlot[ Re[Tan[x + y I]],
{x,1,2}, {y,0,1},
FrameLabel -> {"Bottom",
"Left", "Top", "Right"},
ContourStyle ->
{Dashing[{0.02,0.02}],
RGBColor[1,0,0]}];
Q: How does the option LightSources affect a Graphics3D object?
A:Let's look at the usage message first.
?LightSources
LightSources is an option to Graphics3D and related
functions that specifies the properties of point light
sources for simulated illumination. The basic form is
LightSources -> {{direction1, color1}, {direction2,
color2}, ... }. The direction is specified as {x, y,
z}. The color can be specified by GrayLevel, Hue or
RGBColor.
FullOptions gives the default values.
FullOptions[Graphics3D[{}],
LightSources]
{{{1., 0., 1.}, RGBColor[1., 0, 0]},
{{1., 1., 1.}, RGBColor[0, 1., 0]},
{{0., 1., 1.}, RGBColor[0, 0, 1.]}}
Each light source has a location and color. The coordinate systems for the
locations of the light sources and Graphics3D objects are different. The
origin is at the center of the screen or print image, the x axis is
horizontal, the y axis is vertical, and the z axis is perpendicular to the
display.
If you are sitting squarely in front of your screen, the defaults for
LightSources shine a red light from your right shoulder, a green light
from
above your right shoulder at about head height, and a blue light from your
forehead.
The next graphic shows the effect of LightSources alone and in
combination.
We need to load the Graphics`Shapes` package to draw a torus.
Needs["Graphics`Shapes`"]
t = Torus[];
Show[GraphicsArray[{
{
Graphics3D[t, LightSources ->
{{{1., 0., 1}, RGBColor[1,0,0]}}],
Graphics3D[t, LightSources ->
{{{1., 1., 1}, RGBColor[0,1,0]}}]
},
{
Graphics3D[t, LightSources ->
{{{0., 1., 1}, RGBColor[0,0,1]}}],
Graphics3D[t]
}
}]];
Because the default light source locations are fairly close together, the
colors are blended. In the next GraphicsArray, we put the sources on the
LightSources axes and we use Hue instead of RGBColor.
Show[GraphicsArray[{
{
Graphics3D[t, LightSources ->
{{{1., 0., 0.}, Hue[.8]}}],
Graphics3D[t, LightSources ->
{{{0., 1., 0.}, Hue[.6]}}]
},
{
Graphics3D[t, LightSources ->
{{{0., 0., 1.}, Hue[.4]}}],
Graphics3D[t]
}
}]];
Q: What are some techniques for speeding up Mathematica
calculations?
A: Operating with Lists
If a calculation involves accessing all of the elements in a list, there
are
several techniques that will speed up evaluation. We will add 1 to each of
the
10,000 elements of mylist in four different ways.
mylist = Table[
Random[Integer,{1,10}],{10000}];
To compare the speed of evaluation, we use the Timing command.
Timing[expr]
returns a list of two elements: the time it took to evaluate expr and the
result of that evaluation. The following examples were done on a Macintosh
IIcx.
The first way is to use the For and AppendTo commands. The For command
does
not return a result, so the second element is Null.
Timing[
newlist1 = {};
For[i = 1, i <= Length[mylist],
i++,
AppendTo[newlist1,
mylist[[i]] + 1]]
]
{3087.73 Second, Null}
It is faster to use the Table command to construct a new list.
This time
the
long result is suppressed with a semicolon.
Timing[
newlist2 = Table[mylist[[i]] + 1,
{i, 1, Length[mylist]}];
]
{47.8833 Second, Null}
To make the calculation a little faster, you use the Map command
to avoid
accessing each element individually.
Timing[
f[x_] = x + 1;
newlist3 = Map[f, mylist];
]
{41.55 Second, Null}
Here is a more dramatic speedup. The Plus command has the
attribute
Listable:
when a single number is added to a list, it will be added to every element
of
that list.
Timing[
newlist4 = mylist + 1;
]
{19.9833 Second, Null}
A simple check shows that all of the new lists are identical.
newlist1 == newlist2 ==
newlist3 == newlist4
True
Compiling for Speed
The Compile function can be used to speed up commands. Here is a
function
of t.
f[t_] = Abs[1 +
E^(-I ((7 Pi)/12 + Pi Cos[t])) +
E^(-I ((7 Pi)/6 + 2 Pi Cos[t]))];
PolarPlot for this function takes a very long time. This function
is
defined
to accept any expression (real, integer, or symbolic) for t. We can use
the
Compile command to define an associated function that will work
only for
real
numbers. Compile has the HoldAll attribute, so we need to add the
Evaluate
command.
fCompiled = Compile[{{t,_Real}},
Evaluate[f[t]]];
Now PolarPlot plots the graph in 18 seconds.
Needs["Graphics`Graphics`"]
Timing[
PolarPlot[fCompiled[t],
{t,-Pi,Pi}, PlotRange -> All]
]
{18.1167 Second, -Graphics-}
Not all calculations can be speeded up by using Compile. However,
for
those
that can, the savings in time can be tremendous. For more information on
Compile, see page 312 of The Mathematica Book.
Second Edition of MathSource Compact Disc Now Available
The second edition of the entire MathSource collection on CD-ROM
was
released
in April. This major revision includes the following new features:
20% more items
There are nearly 700 distinct items on the CD-ROM (over 5000 files),
including Mathematica tools and packages, documentation, electronic
books,
and
journal supplements.
table of contents with abstracts
This notebook listing of all the items reflects how the CD is
organized.
Mathematica's extensive search capabilities make it easy to
identify the
items
and files you want and to see where to find them on the CD.
immediate access to files
It isn't necessary to copy any archive files onto your hard
disk. Tarred-and-compressed, Binhexed, and PKZipped archives are
de-archived
for the appropriate platform, making all the files on MathSource
accessible
directly from the CD.
The MathSource CD is ideal for those who don't have network access
to
MathSource. Even if you do have network access, having your own CD
can
mean
substantial savings in commercial on-line service fees or long-distance
modem
charges. And if you often search through and download files from
MathSource,
you'll save time and hard disk space by having the complete collection
right
on your desk.
The MathSource CD is available for Macintosh, MS DOS/Windows, and
Unix/VMS.
Call Wolfram Research or your nearest software dealer to order today!
Macintosh-format CD can be used on any Macintosh and any other computer
that
can read HFS file systems. MS DOS/Windows CD uses ISO-9660 level 1 format,
and
is best used on computers limited to 8.3 filenames. Unix/VMS CD can be
used on
any platform that recognizes ISO-9660 with Rock Ridge extensions.
|