Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
GNU Octave Beginner's Guide

You're reading from   GNU Octave Beginner's Guide Become a proficient Octave user by learning this high-level scientific numerical tool from the ground up

Arrow left icon
Product type Paperback
Published in Jun 2011
Publisher Packt
ISBN-13 9781849513326
Length 280 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jesper Schmidt Hansen Jesper Schmidt Hansen
Author Profile Icon Jesper Schmidt Hansen
Jesper Schmidt Hansen
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

GNU Octave
Credits
About the Author
About the Reviewers
1. www.PacktPub.com
2. Preface
1. Introducing GNU Octave FREE CHAPTER 2. Interacting with Octave: Variables and Operators 3. Working with Octave: Functions and Plotting 4. Rationalizing: Octave Scripts 5. Extensions: Write Your Own Octave Functions 6. Making Your Own Package: A Poisson Equation Solver 7. More Examples: Data Analysis 8. Need for Speed: Optimization and Dynamically Linked Functions Pop quiz - Answers

So what is GNU Octave?


In brief, GNU Octave is a multi-functional tool for sophisticated numerical analysis. GNU Octave provides you with:

  1. 1. A large set of build-in functionalities to solve many different problems.

  2. 2. A complete programming language that enables you to extend GNU Octave.

  3. 3. Plotting facilities.

This book will cover these features.

GNU Octave uses an interpreter to compile and execute a sequence of instructions given by the user at run-time. This is also how, for example, PHP and Python work. This is in contrast to pre-compiled programming languages such as C where the program is first compiled and then executed manually. Just like Python, you can give GNU Octave instructions in a prompt-like environment. We shall see many examples of this later. The following image shows a screenshot of GNU Octave in action—do not worry about what the plots are, for the time being.

GNU Octave is named after the chemist Octave Levenspiel and has nothing to do with music and harmonic waves. The project was started by James B. Rawlings and John G. Ekerdt, but it has mainly been developed by John W. Eaton, who has put a lot of effort into the project. GNU Octave is an official GNU project (hence, the GNU prefix), and the source code is released under the GNU General Public License (GPL).

In simple terms, this means that you are allowed to use the software for any purpose, copy, and distribute it, and make any changes you want to it. You may then release this new software under GPL. If you use GNU Octave's own programming language to extend the functionality, you are free to choose another license. I recommend you to have a look at the license agreement that comes with GNU Octave at http://www.gnu.org/software/octave/license.html.

In the remainder of the book, GNU Octave will simply be referred to as Octave for convenience. However, if you wish to sound like an Octave guru, use the "GNU" prefix!

Applications

As mentioned previously, Octave can be used to solve many different scientific problems. For example, a Copenhagen-based commercial software and consulting company specializes in optimization problems, especially for packing containers on large cargo ships. This can be formulated in terms of linear programming which involves solving large linear equation systems and to this end, the company uses Octave. Pittsburgh supercomputing center also used Octave to study social security number vulnerability. Here Octave ran on a massive parallel computer named Pople with 768 cores and 1.5 TB memory and enabled researches to carry out sophisticated analysis of different strategies before trying out new ones.

In the research community, Octave is used for data analysis, image processing, econometrics, advanced statistical analysis, and much more. We shall see quite a few examples of this throughout the book.

Limitations of Octave

Octave is mainly designed to perform numerical computations and is not meant to be a general purpose programming language such as C or C++. As it is always the case, you should choose your programming language depending on the problem you wish to solve. Nevertheless, Octave has a lot of functionality that can help you with, for example, reading from and writing to files, and you can even use a package named sockets for accessing a network directly.

The fact that Octave uses an interpreter means that Octave first has to convert the instructions into machine readable code before executing it. This has its advantages as well as drawbacks. The main advantage is that the instructions are easy to implement and change, without having to go through the edit, compile, and run phase and gives the programmer or user a very high degree of control. The major drawback is that the program executes relatively slowly compared to pre-compiled programs written in languages such as C or Fortran. Octave is therefore perhaps not the first choice if you want to do extremely large scale parallelized computations, such as state-of-art weather forecasting.

However, as you will experience later in the book, Octave will enable you solve very advanced and computationally demanding problems with only a few instructions or commands and with satisfactory speed. The last chapter of this book teaches you some optimization techniques and how you can use C++ together with Octave to speed things up considerably in some situations.

Octave is not designed to do analytical (or symbolic) mathematics. For example, it is not the best choice if you wish to find the derivative of a function, say f (x) = x2. Here software packages such as Maxima and Sage can be very helpful. It should be mentioned that there exists a package (a package is also referred to as a toolbox) for Octave which can do some basic analytical mathematics.

Octave and MATLAB

It is in place to mention MATLAB. Often Octave is referred to as a MATLAB-clone (MATLAB is a product from MathWorksTM). In my opinion, this is wrong! Rather, Octave seeks to be compatible with MATLAB. However, be aware, in some cases you cannot simply execute your Octave programs with MATLAB and vice-versa. Throughout the book, it will be pointed out where compatibility problems can occur, but we shall stick with Octave and make no special effort to be compatible with MATLAB.

The Octave community

The newest version of Octave can be found on the web page http://www.octave.org. Here you will also find the official manual, a Wiki page with tricks and tips, latest news, a bit of history, and other exciting stuff. From this web page, you can join Octave's mailing lists (the help-list is especially relevant), which only require a valid email address. The user community is very active and helpful, and even the developers will answer "simple" user questions. You can also learn quite a lot from browsing through the older thread archives.

There also exists an Usenet discussion group http://groups.google.com/group/comp.soft-sys.octave/topics?lnk. Unfortunately, this group seems quite inactive, so it could take a while for help to arrive.

There exist a very large number of additional packages that do not come with the standard Octave distribution. Many of these can be downloaded from the Octave-Forge http://octave.sourceforge.net. Here you will find specially designed packages for imaging processing, econometrics, information theory, analytical mathematics, and so on. After reading this book and solving the problems at the end of each chapter, you will be able to write your own Octave package. You can then share your work with others, and the entire Octave community can benefit from your efforts. Someone might even extend and improve what you started!

You have been reading a chapter from
GNU Octave Beginner's Guide
Published in: Jun 2011
Publisher: Packt
ISBN-13: 9781849513326
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime