История появления системы MATLAB
Современная компьютерная математика предлагает целый набор интегрированных программных систем и пакетов программ для автоматизации математических расчетов: Eureka, Gauss, TK Solver!, Derive, Mathcad, Mathematica, Maple V и др. Возникает вопрос: «А какое место занимает среди них система MATLAB?»
MATLAB — одна из старейших, тщательно проработанных и проверенных временем систем автоматизации математических расчетов, построенная на расширенном представлении и применении матричных операций. Это нашло отражение в названии системы — MATrix LABoratory — матричная лаборатория. Однако синтаксис языка программирования системы продуман настолько тщательно, что эта ориентация почти не ощущается теми пользователями, которых не интересуют непосредственно матричные вычисления.
Матрицы широко применяются в сложных математических расчетах, например при решении задач линейной алгебры и математического моделирования статических и динамических систем и объектов. Они являются основой автоматического составления и решения уравнений состояния динамических объектов и систем. Примером может служить расширение MATLAB — Simulink. Это существенно повышает интерес к системе MATLAB, вобравшей в себя лучшие достижения в области быстрого решения матричных задач.
. Однако в настоящее время MATLAB далеко вышла за пределы специализированной матричной системы и стала одной из наиболее мощных универсальных интегрированных СКМ. Слово «интегрированная» указывает на то, что в этой системе объединены удобная оболочка, редактор выражений и текстовых комментариев, вычислитель и графический программный процессор. В новой версии используются такие мощные типы данных, как многомерные массивы, массивы ячеек, массивы структур, массивы Java и разреженные матрицы, что открывает возможности применения системы при создании и отладке новых алгоритмов матричных и основанных на них параллельных вычислений и крупных баз данных.
В целом MATLAB — это уникальная коллекция реализаций современных численных методов компьютерной математики, созданных за последние три десятка лет. Она вобрала в себя и опыт, правила и методы математических вычислений, накопленные за тысячи лет развития математики. Это сочетается с мощными средствами графической визуализации и даже анимационной графики. Систему с прилагаемой к ней обширной документацией вполне можно рассматривать как фундаментальный многотомный электронный справочник по математическому обеспечению ЭВМ — от массовых персональных компьютеров до супер-ЭВМ.
Увы, пока представленный полностью лишь на английском и частично на японском языках!
Система MATLAB была разработана Молером (С. В. Moler) и с конца 70-х гг. широко использовалась на больших ЭВМ. В начале 80-х гг. Джон Литл (John Little) из фирмы MathWorks, Inc. разработал версии системы PC MATLAB для компьютеров класса IBM PC, VAX и Macintosh. В дальнейшем были созданы версии для рабочих станций Sun, компьютеров с операционной системой UNIX и многих других типов больших и малых ЭВМ. Сейчас свыше десятка популярных компьютерных платформ могут работать с системой MATLAB. К расширению системы были привлечены крупнейшие научные школы мира в области математики, программирования и естествознания. И вот теперь появилась новейшая версия этой системы — MATLAB 6. Одной из основных задач системы было предоставление пользователям мощного языка программирования, ориентированного на математические расчеты и способного превзойти возможности традиционных языков программирования, которые многие годы использовались для реализации численных методов. При этом особое внимание уделялось как повышению скорости вычислений, так и- адаптации системы к решению самых разнообразных задач пользователей.
Возможности MATLAB весьма обширны, а по скорости выполнения задач система нередко превосходит своих конкурентов. Она применима для расчетов практически в любой области науки и техники. Например, очень широко используется при математическом моделировании механических устройств и систем, в частности в динамике, гидродинамике, аэродинамике, акустике, энергетике и т. д. Этому способствует не только расширенный набор матричных и иных операций и функций, но и наличие пакета расширения (toolbox) Simulink, специально предназначенного для решения задач блочного моделирования динамических систем и устройств, а также десятков других пакетов расширений.
В обширном и постоянно пополняемом комплексе команд, функций и прикладных программ (пакетов расширения, пакетов инструментов, (toolbox)) [Пакет инструментов, пакет расширения, прикладная программа — почти синонимы при переводе термина toolbox, но пакет инструментов собственно MATLAB 6 рассматривается как один из toolbox всей системы, включающей MATLAB 6, Simulink и другие пакеты. Редакция старалась максимально сохранить авторский стиль, но следует помнить, что и под прикладной программой, и иод пакетом расширения автор имеет в виду toolbox в терминах MATLAB. — Примеч. ред.
] системы MATLAB содержатся специальные средства для электротехнических и радиотехнических расчетов (операции с комплексными числами, матрицами, векторами и полиномами, обработка данных, анализ сигналов и цифровая фильтрация), обработки изображений, реализации нейронных сетей, а также средства, относящиеся к другим новым направлениям науки и техники. Они иллюстрируются множеством практически полезных примеров. К разработкам расширений для системы MATLAB привлечены многие научные школы мира и руководящие ими крупные ученые и педагоги университетов.
Важными достоинствами системы являются ее открытость и расширяемость. Большинство команд и функций системы реализованы в виде текстовых m-файлов (с расширением .m) и файлов на языке Си, причем все файлы доступны для модификации. Пользователю дана возможность создавать не только отдельные файлы, но и библиотеки файлов для реализации специфических задач.
Поразительная легкость модификации системы и возможность ее адаптации к решению специфических задач науки и техники привели к созданию десятков пакетов прикладных программ (toolbox), намного расширивших сферы применения системы. Некоторые из них, например Notebook (интеграция с текстовым процессором Word и подготовка «живых» электронных книг), Symbolic Math и Extended Symbolic Math (символьные вычисления с применением ядра системы Maple V R5) и Simulink (моделирование динамических систем и устройств, заданных в виде системы блоков), настолько органично интегрировались с системой MATLAB, что стали ее составными частями. Аннотационное описание этих и ряда других пакетов дано в уроке 23. Более подробно, хотя в версиях для выпуска 11.
The Origins of MATLAB
With 2004 marking the 20th anniversary of The MathWorks, it’s a good time to look back at the origins of MATLAB. MATLAB is now a full-featured technical computing environment, but it started as a simple “Matrix Laboratory.” Three men, J. H. Wilkinson, George Forsythe, and John Todd, played important roles in the origins of MATLAB. Our account begins more than 50 years ago. Wilkinson was a British mathematician who spent his entire career at the National Physical Laboratory (NPL) in Teddington, outside London. Working on a simplified version of a sophisticated design by Alan Turing, Wilkinson and colleagues at NPL built the Pilot Automatic Computing Engine (ACE), one of Britain’s first stored-program digital computers. The Pilot ACE ran its first program in May 1950. Wilkinson did matrix computations on the machine and went on to become the world’s leading authority on numerical linear algebra. At about the same time, mathematicians at the Institute for Numerical Analysis (INA), a branch of the National Bureau of Standards, located at UCLA, were working with the Standards Western Automatic Computer (SWAC), one of the USA’s first computers. Researchers at INA included George Forsythe, John Todd, and Olga Taussky-Todd. When the INA dissolved in 1957, Forsythe joined the faculty at Stanford and the Todds joined the faculty at Caltech.
I went to Caltech as a freshman in 1957 and two years later took John Todd’s Math 105, Numerical Analysis. We did some of our homework with mechanical calculators, but we also used the Burroughs 205 Datatron, one of only a few dozen computers in southern California at the time.
One of the projects that I did under Todd’s direction in 1960 involved Hilbert matrices. These are famous, ill-conditioned test matrices with elements \[h_ = \frac\texti,j = 1,\dots, n\] I wrote my programs in absolute numeric machine language and punched them on paper tape. If I’d had MATLAB at the time, my project would have involved computing
H = single(hilb(6))
H =
1.0000000 0.5000000 0.3333333 0.2500000 0.2000000 0.1666667
0.5000000 0.3333333 0.2500000 0.2000000 0.1666667 0.1428571
0.3333333 0.2500000 0.2000000 0.1666667 0.1428571 0.1250000
0.2500000 0.2000000 0.1666667 0.1428571 0.1250000 0.1111111
0.2000000 0.1666667 0.1428571 0.1250000 0.1111111 0.1000000
0.1666667 0.1428571 0.1250000 0.1111111 0.1000000 0.0909091
I would then compute the inverse of H.
inv(H)
ans =
35.80 -624.43 3322.96 -7464.7 7455.6 -2731.09
-624.41 14546.09 -87179.65 209060.31 -217634.53 82038.44
3322.81 -87180.05 557732.38 -1393901.88 1493100.13 -574728.88
-7464.46 209065.14 -1393927.13 3584568 -3920712 1533448.13
7455.48 -217644.66 1493161.5 -3920799.75 4357413 -1725818
-2731.10 82044.3 -574766 1533516.5 -1725855.38 690537.44
The exact inverse of the Hilbert matrix has integer elements. A function in MATLAB computes it with a recursive algorithm.
invhilb(6)
ans =
36.00 -630.00 3360.00 -7560.00 7560.00 -2772.00
-630.00 14700.00 -88200.00 211680.00 -220500.00 83160.00
3360.00 -88200.00 564480.00 -1411200.00 1512000.00 -582120.00
-7560.00 211680.00 -1411200.00 3628800.00 -3969000.00 1552320.00
7560.00 -220500.00 1512000.00 -3969000.00 4410000.00 -1746360.00
-2772.00 83160.00 -582120.00 1552320.00 -1746360.00 698544.00
I would compare these last two matrices and say the difference was the result of roundoff error introduced by the inversion process. I was wrong. I would learn a few years later from Wilkinson that the roundoff error introduced in computing H in the first place has more effect on the final answer than the error introduced by the inversion process.
In 1961, it was time for graduate school. Todd recommended that I go to Stanford and work with his friend George Forsythe. At the time, Forsythe was a professor in the math department, but he was starting the process that would create Stanford’s computer science department, one of the world’s first, in 1965. In 1962, after Forsythe’s numerical analysis course and a visit to Stanford by Wilkinson, I wrote a Fortran program to solve systems of simultaneous linear equations. Decks of punched cards for the program were distributed fairly widely at the time, including via SHARE, the IBM User’s Group.
Alston Householder from Oak Ridge National Laboratory and the University of Tennessee began a series of research conferences on numerical algebra in the late 1950s. These are now held every three or four years and are called the Householder Conferences. As a graduate student, I went to the third conference in the series in 1964 and obtained a photo of the organizing committee. Much later, that photo was used in the first documentation of the image function in MATLAB.
My 1965 Ph.D. thesis under Forsythe’s direction was entitled “Finite Difference Methods for the Eigenvalues of Laplace’s Operator.” The primary example, on which both Forsythe and Wilkinson had worked earlier, was the L-shaped membrane, now the MathWorks logo.
Forsythe and I published a textbook about matrix computation in 1967 that was later listed by the Association for Computing Machinery as an important early text in computer science because it contained working software: programs in Algol, Fortran, and PL/I for solving systems of simultaneous linear equations. Over several years in the late 1960s, Wilkinson and a number of colleagues published papers in Numerische Mathematik that included algorithms in Algol for various aspects of matrix computation. These algorithms were eventually collected in a 1971 book edited by Wilkinson and Reinsch.
Every summer for 15 years, Wilkinson lectured in a short course at the University of Michigan and then visited Argonne National Laboratory for a week or two. Researchers at Argonne translated the Algol code for matrix eigenvalue computation from the Wilkinson and Reinsch handbook into Fortran to produce EISPACK. This was followed by LINPACK, a package of Fortran programs for solving linear equations.
When we were developing EISPACK and LINPACK, I was a math professor at the University of New Mexico, teaching numerical analysis and matrix theory. I wanted my students to be able to use our new packages without writing Fortran programs, so I studied a book by Niklaus Wirth to learn about parsing computer languages.
In the late 1970s, following Wirth’s methodology, I used Fortran and portions of LINPACK and EISPACK to develop the first version of MATLAB. The only data type was “matrix.” The HELP command listed all of the available functions, with their names abbreviated.
ABS ANS ATAN BASE CHAR CHOL CHOP CLEA COND CONJ COS
DET DIAG DIAR DISP EDIT EIG ELSE END EPS EXEC EXIT
EXP EYE FILE FLOP FLPS FOR FUN HESS HILB IF IMAG
INV KRON LINE LOAD LOG LONG LU MACR MAG I NORM ONES
ORTH PINV PLOT POLY PRIN PROD QR RAND RANK RCON RAT
REAL RETU RREF ROOT ROUN SAVE SCHU SHOR SEMI SIN SIZE
SQRT STOP SUM SVD TRIL TRIU USER WHAT WHIL WHO WHY There were only 80 functions. There were no M-files or toolboxes. If you wanted to add a function, you had to modify the Fortran source code and recompile the entire program. Here is a sample program. If you change long to format long , it works with today’s MATLAB.
n = 10 J = 1:n; J = J(ones(n,1),:); I = J'; E = ones(n,n); A = E./(I-J+E/2); long S = svd(A)
S =
3.141592653589682
3.141592653566661
3.141592651393170
3.141592527498737
3.141587781570560
3.141459305862261
3.138952480600909
3.104107683136387
2.786915482404130
1.300969070029704 The first graphics were very primitive.
pi = 4*atan(1); x = 0:pi/40:2*pi; y = x.*sin(3*x); plot(x,y)
This first Fortran MATLAB was portable and could be compiled to run on many of the computers that were available in the late 1970s and early 1980s. We installed it on the interactive time-sharing systems that were hosted by mainframe computers at universities and national laboratories. The first “personal computer” that I used was the Tektronix 4081, which Argonne acquired in 1978. The machine was the size of a desk and consisted of a Tektronix graphics display attached to an Interdata 7/32, the first 32-bit minicomputer. There was only 64K, that’s 64 kilobytes of memory. But there was a Fortran compiler, and so, by using memory overlay, we were able to run MATLAB.

I visited Stanford in 1979 and taught CS237, the graduate numerical analysis course. I had the students use MATLAB for some of the homework. Half of the students in the class were from math and computer science, and they were not impressed by my new program. It was based on Fortran, it was not a particularly powerful programming language, and it did not represent current research work in numerical analysis. The other half of the students were from engineering, and they liked MATLAB. They were studying subjects that I didn’t know anything about, such as control analysis and signal processing, and the emphasis on matrices in MATLAB proved to be very useful to them. A few of the Stanford engineering students from my class joined two consulting companies in Palo Alto. These companies extended MATLAB to have more capability in control analysis and signal processing and, in the early 1980s, offered the resulting software as commercial products. Jack Little, a Stanford- and MIT-trained control engineer, was the principal developer of one of the first commercial products based on Fortran MATLAB. When IBM announced their first PC in August, 1981, Jack quickly anticipated the possibility of using MATLAB and the PC for technical computing. He and colleague Steve Bangert reprogrammed MATLAB in C and added M-files, toolboxes, and more powerful graphics. The three of us founded The MathWorks in California in 1984.
A Brief History of MATLAB
The first MATLAB ® was not a programming language; it was a simple interactive matrix calculator. There were no programs, no toolboxes, no graphics. And no ODEs or FFTs. In this Cleve’s Corner, I’ll describe some milestones in the evolution of MATLAB from those simple beginnings.
Mathematical Origins
The mathematical basis for the first version of MATLAB was a series of research papers by J. H. Wilkinson and 18 of his colleagues, published between 1965 and 1970 and later collected in Handbook for Automatic Computation, Volume II, Linear Algebra, edited by Wilkinson and C. Reinsch. These papers present algorithms, implemented in Algol 60, for solving matrix linear equation and eigenvalue problems.
EISPACK and LINPACK
In 1970, a group of researchers at Argonne National Laboratory proposed to the U.S. National Science Foundation (NSF) to “explore the methodology, costs, and resources required to produce, test, and disseminate high-quality mathematical software and to test, certify, disseminate, and support packages of mathematical software in certain problem areas.” The group developed EISPACK (Matrix Eigensystem Package) by translating the Algol procedures for eigenvalue problems in the handbook into Fortran and working extensively on testing and portability. The first version of EISPACK was released in 1971 and the second in 1976. In 1975, four of us—Jack Dongarra, Pete Stewart, Jim Bunch, and myself—proposed to the NSF another research project that would investigate methods for the development of mathematical software. A byproduct would be the software itself, dubbed LINPACK, for Linear Equation Package. This project was also centered at Argonne. LINPACK originated in Fortran; it did not involve translation from Algol. The package contained 44 subroutines in each of four numeric precisions. In a sense, the LINPACK and EISPACK projects were failures. We had proposed research projects to the NSF to “explore the methodology, costs, and resources required to produce, test, and disseminate high-quality mathematical software.” We never wrote a report or paper addressing those objectives. We only produced software.
Historic MATLAB
In the 1970s and early 1980s, I was teaching Linear Algebra and Numerical Analysis at the University of New Mexico and wanted my students to have easy access to LINPACK and EISPACK without writing Fortran programs. By “easy access,” I meant not going through the remote batch processing and the repeated edit-compile-link-load-execute process that was ordinarily required on the campus central mainframe computer. So, I studied Niklaus Wirth’s book Algorithms + Data Structures = Programs and learned how to parse programming languages. I wrote the first MATLAB—an acronym for Matrix Laboratory—in Fortran, with matrix as the only data type. The project was a kind of hobby, a new aspect of programming for me to learn and something for my students to use. There was never any formal outside support, and certainly no business plan. This first MATLAB was just an interactive matrix calculator. This snapshot of the start-up screen shows all the reserved words and functions. There are only 71. To add another function, you had to get the source code from me, write a Fortran subroutine, add your function name to the parse table, and recompile MATLAB.
