Loren on the Art of MATLAB

June 21st, 2011

Update on the Chebfun Project

A while ago, I wrote about the Chebfun Project. At the time, version 3 had recently come out. I recently visited Nick Trefethen and Nick Hale, part of the Chebfun team, and they showed me the latest and greatest version 4.

As I said in my earlier post, the package is designed to have syntax very much like regular vector notation in MATLAB, though the entities represent functions.

Here's a description from the Chebfun website:

Chebfun is a collection of algorithms and a software system in object-oriented MATLAB which extends familiar powerful methods of numerical computation involving numbers to continuous or piecewise-continuous functions. It also implements continuous analogues of linear algebra notions like the QR decomposition and the SVD, and solves ordinary differential equations. The mathematical basis of the system combines tools of Chebyshev expansions, fast Fourier transform, barycentric interpolation, recursive zerofinding, and automatic differentiation.

Contents

Nonlinear Operators

One recent addition includes being able to use nonlinear operators more naturally. So, to solve a nonlinear system, guess what?! You get to use the MATLAB operator \! See Chapter 7 of the Chebfun Guide for a nice example.

Graphical User Interface

Nick and Nick ran the GUI for Chebfun (and have since). You can use it to formulate your problems. In addition, you can use it to access the demos and examples. Find a problem similar to on your want to solve, select it in the GUI where it will populate all the required fields, and you are ready to run the code or tinker.

Rich Set of Examples

This page lists an overview of the categories of examples solved using Chebfun. Here is a full list of examples>. You can get the code, or the example in PDF or HTML form.

I'll mention just a few of my favorites to show you the breadth of possible problems that Chebfun can solve.

  • Orr-Somerfield eigenvalues (hydrodynamic stability)
  • Carrier equation (ode: boundary value problem)
  • Double well Schrodinger eigenstates (quantum mechanics)
  • Coupled system of reaction-diffusion equations

And that's just the tip of the iceberg.

What Basis Functions Do You Use When Required?

Many people use splines as basis functions for approximations, solving differential equations, and so on. Some people use wavelets for similar purposes. The package discussed here relies on Chebyshev functions. I hope from the examples you can see the broad applicability of the Chebfun project. What do you use? And why? Let me know here.


Get the MATLAB code

Published with MATLAB® 7.12

4 Responses to “Update on the Chebfun Project”

  1. Oyster Engiineer replied on :

    I downloaded the package & as is my habit, I ran Code Metrics on it. The Maximum Cyclomatic Complexity Index in the package is 147, although only one file is that high. But a few are in the 80s & 90s with many dozen above the recommended maximum of 10.

    The one file at 147 has several sub-functions concatenated together, so I looked a bit deeper & it appears that the 1st, main function in the file is what drives the complexity index high.

    I’m sure that the smart folks behind a project like this can deal with higher complexity than me. But I don’t see how any mortal could ensure that code this complex does not have undetected errors.

  2. Mark Shore replied on :

    I found this an interesting toolbox, but somewhat over my head mathematically.

    Watch the relative path position, since the Chebfun package has a number of functions with the same name as native MATLAB function and can lead to inadvertent function overloads.

  3. Ben Petschel replied on :

    It’s quite amazing what can be done with Chebfun. I’m looking forward to when the 2D version comes out.

  4. Mike replied on :

    Really impressive project, and a great demonstration of the value to using OOP in MATLAB. Thanks for sharing!


MathWorks
Loren Shure works on design of the MATLAB language at MathWorks. She writes here about once a week on MATLAB programming and related topics.

These postings are the author's and don't necessarily represent the opinions of The MathWorks.