CHEBFUN helps to make the MATLAB codes easier, and allows you to work with solutions as though
Question:
CHEBFUN helps to make the MATLAB codes easier, and allows you to work with solutions as though they were analytic functions. You will find it very useful once you start using these. I will walk you through several examples in this book. This example is a starting point.
What are CHEBFUNs? The answer is that they are a type of polynomial fitting to a data or function using Chebyshev polynomials. Once fitted, these functions have the feel of a mathematical function rather than a discrete set of data points.
How does one access these? For getting started you need to copy and paste the following in your MATLAB command window:
unzip ('http://www.chebfun.org/download/chebfun_v4.2.2889.zip')
cd chebfun_v4.2.2889, addpath(fullfile(cd,'chebfun')), savepath
This will install the chebfun directory and also add the required path to the file. Once this has been installed you will have access to a number of new functions, which makes the MATLAB coding easier. The code will look much more compact with this functionality added to your MATLAB. Some sample codes provided in problems in this book use these compact functions. Let us do some function manipulations first and see how compact the codes become. The code lines to be entered in MATLAB are indicated below. You should type these and test them out with your own functions.
\(x=\) chebfun ( ' \(x\) ', \([0,1]\) ) defines \(x\) as a CHEBFUN in the interval 0 to 1 , and, using \(x\) as a variable, any function of \(x\) can be created. For example \[y=\exp (x)\]
creates an exponential function.
The statement plot(y) generates a plot of this function.
The statement \(\operatorname{sum}(y)\) gives directly the integral of the function in the given domain.
Infinite or semi-infinite domains can be easily handled. Thus, for example, the statement \(\mathrm{X}=\) chebfun ('X', [0. ,inf] ) and \(\mathrm{t}=\exp \left(-\mathrm{X} \cdot{ }^{\wedge 2}\right)\)
creates a CHEBFUN \(t=\exp \left(-x^{2}\right)\) defined from 0 to \(\infty\). Note the X. (dot) operator to show a function multiplication.
The sum ( \(t\) ) gives the result 0.8862 , which is the integral of the function. This matches exactly the analytic value of \(\sqrt{\pi} / 2\).
A first-order differential equation where the separation of variables can be used is readily solved using the sum command.
For more details on the CHEBFUN and the mathematics involved in the construction of such a representation, the papers by Battles and Trefethen (2004) and Trefethen (2007) should be consulted.
Step by Step Answer:
Advanced Transport Phenomena Analysis Modeling And Computations
ISBN: 9780521762618
1st Edition
Authors: P. A. Ramachandran