File Exchange Pick of the Week

Our best user submissions

Numerical methods on piecewise-continuous functions

Jiro's pick this week is Chebfun v2 by the Chebfun Team.

Contents

Thorough Documentation

I was initially drawn to this entry because of the comprehensive documentation that was included with it. You can directly view it from the File Exchange page:

Their user's guide is extremely detailed and helpful. I had very little prior knowledge of the concepts covered by this tool, but after reading through it, I've come to appreciate the usefulness and the power of the tool. They created the guide using MATLAB's publishing functionality, which is an extremely effective way of providing documentation and examples for the end-users, because of the ability to intermix code, figures, explanatory text, and equations. Find more information about publish from this page on our Academic website.

Chebfun Function

Now, let's take a look at the tool.

Borrowing the words from their documentation, a chebfun is a function of one variable defined within a particular interval. It allows you to perform symbolic-like operations with the performance of numerics. The underlying implementation of chebfun is based on the mathematical fact that smooth functions can be represented very efficiently by expansions in Chebyshev polynomials, similar to how Fourier series work with smooth periodic functions. By decomposing a function into these polynomial interpolants, many mathematical operations can be carried out efficiently.

Let's define a chebfun for within the interval [0 2].

f = chebfun(@(x) sin(x)+cos(3.3*x)-0.5*x.^2, [0 2])
f = 
   chebfun column (1 smooth piece)
          interval          length   values at Chebyshev points
(        0,        2)        21            1          1          1 ...      -0.14
 

You can see that this function is represented by 21 points, i.e. a polynomial of degree 20. Let's plot it, along with the intermediate points (Chebyshev points)

plot(f, '.-')

This chebfun representation can be evaluated at arbitrary points:

f([0.2, 0.5, 0.9, 1.5, 1.85])
ans =
    0.9687    0.2753   -0.6070    0.1079    0.2342

To calculate the integral from 0 to 2,

sum(f)
ans =
    0.1772

The roots can be found by

r = roots(f)
hold on
plot(r, f(r), 'ro', 'MarkerFaceColor', 'r');
r =
    0.5953
    1.4429
    1.9557

By now, you probably have noticed that chebfun is implemented using object-oriented programming, with a number of overloaded methods, such as plot, sum, and roots.

I can say for sure that I'm not doing justice to this entry with this short blog post. I've just scratched the surface with what could be done with this tool. I highly encourage you to take a look through the documentation and give it a try. On the download page, it says that they have Version 4 available for download off of their university website. I'm hoping that they will also update the version on the File Exchange.

Comments

Let us know what you think here or leave a comment for the Chebfun Team.




Published with MATLAB® 7.13

|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。