. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Introduction to the Chebfun System
Titus Pinta
Presentation at the ICTP Institute Seminar, January 30, 2019.
1 / 23
Contents I
1 Introduction
2 Approximating Functions 3 Chebyshev Series
4 Chebyfun and Approximations 5 Clenshaw-Curtis Algorithm 6 Chebfun and Integration 7 Chebfun and Primitives 8 Differentiation
9 Chebops
10 Chebfun and ODEs
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Definitions
Givenxandy, two vectors fromRnwith xi̸=xj,i̸=j, there exists an unique polynomialp of degree at mostn−1with the property
p(xi) =yi
This unique polynomial is called the Lagrange Interpolation polynomial. If the vectorxgiven by
xi=cos(i
nπ)
, xi∈[−1,1]
the nodes of interpolation are called Chebyshev-Gauss-Lobatto nodes. These points are the extremum points of the Chebyshev polynomials, defined as
{Tn+1(x) = 2xTn(x)−Tn−1(x), T0(x) = 1, T1(x) =x.
3 / 23
Definitions
Givenxandy, two vectors fromRnwith xi̸=xj,i̸=j, there exists an unique polynomialp of degree at mostn−1with the property
p(xi) =yi
This unique polynomial is called the Lagrange Interpolation polynomial.
If the vector xgiven by xi=cos(i
nπ)
, xi∈[−1,1]
the nodes of interpolation are called Chebyshev-Gauss-Lobatto nodes. These points are the extremum points of the Chebyshev polynomials, defined as
{Tn+1(x) = 2xTn(x)−Tn−1(x), T0(x) = 1, T1(x) =x.
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Definitions
Givenxandy, two vectors fromRnwith xi̸=xj,i̸=j, there exists an unique polynomialp of degree at mostn−1with the property
p(xi) =yi
This unique polynomial is called the Lagrange Interpolation polynomial. If the vectorxgiven by
xi=cos(i
nπ)
, xi∈[−1,1]
the nodes of interpolation are called Chebyshev-Gauss-Lobatto nodes.
These points are the extremum points of the Chebyshev polynomials, defined as
{Tn+1(x) = 2xTn(x)−Tn−1(x), T0(x) = 1, T1(x) =x.
3 / 23
Definitions
Givenxandy, two vectors fromRnwith xi̸=xj,i̸=j, there exists an unique polynomialp of degree at mostn−1with the property
p(xi) =yi
This unique polynomial is called the Lagrange Interpolation polynomial. If the vectorxgiven by
xi=cos(i
nπ)
, xi∈[−1,1]
the nodes of interpolation are called Chebyshev-Gauss-Lobatto nodes. These points are the extremum points of the Chebyshev polynomials, defined as
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Approximating Functions
Given a functionf: [−1,1]→R, we can evaluatefatn Chebyshev-Gauss-Lobatto points and construct the Lagrange polynomial that interpolates the given points.
pn(xi) =f(xi), ∀xi =cos(i
nπ) .
Using the barycentric form of the Lagrange polynomial, we can derive a fast algorithm for evaluating the resulting polynomial
Pn(x) =
f(−1)
2(x+1) +f(1)(2(x−−1)1)n
n−1
∑
k=1
f(xk)(−1)k x−xk
1
2(x+1) +2(x(−−1)1)n +
n−1
∑
k=1
(−1)k x−xk
4 / 23
Approximating Functions
Given a functionf: [−1,1]→R, we can evaluatefatn Chebyshev-Gauss-Lobatto points and construct the Lagrange polynomial that interpolates the given points.
pn(xi) =f(xi), ∀xi =cos(i
nπ) .
Using the barycentric form of the Lagrange polynomial, we can derive a fast algorithm for evaluating the resulting polynomial
Pn(x) =
f(−1)
2(x+1) +f(1)(2(x−−1)1)n
n−1
∑
k=1
f(xk)(−1)k x−xk
n−1
∑(−1)k
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Approximating Functions
Given a functionf: [−1,1]→R, we can evaluatefatn Chebyshev-Gauss-Lobatto points and construct the Lagrange polynomial that interpolates the given points.
pn(xi) =f(xi), ∀xi =cos(i
nπ) .
Using the barycentric form of the Lagrange polynomial, we can derive a fast algorithm for evaluating the resulting polynomial
Pn(x) =
f(−1)
2(x+1) +f(1)(2(x−−1)1)n
n−1
∑
k=1
f(xk)(−1)k x−xk
1
2(x+1) +2(x(−−1)1)n +
n−1
∑
k=1
(−1)k x−xk
4 / 23
Chebyshev Series
We can approximate a functionf defined on the interval[−1,1]
with a series of Chebyshev polynomials f(x)≈
∑n i=0
aiTi(x).
We can define the functionF(θ) =f(cos(θ))whereθ∈[0, π]and using the fact that
Tn(x) =cos(narccos(x)), we can approximate
F(θ)≈
∑n
i=1
aicos(nθ).
This suggests using a FFT to compute the coefficients of the Chebyshev expansion.
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebyshev Series
We can approximate a functionf defined on the interval[−1,1]
with a series of Chebyshev polynomials f(x)≈
∑n i=0
aiTi(x).
We can define the functionF(θ) =f(cos(θ))whereθ∈[0, π]and using the fact that
Tn(x) =cos(narccos(x)), we can approximate
F(θ)≈
∑n i=1
aicos(nθ).
This suggests using a FFT to compute the coefficients of the Chebyshev expansion.
5 / 23
Chebyshev Series
We can approximate a functionf defined on the interval[−1,1]
with a series of Chebyshev polynomials f(x)≈
∑n i=0
aiTi(x).
We can define the functionF(θ) =f(cos(θ))whereθ∈[0, π]and using the fact that
Tn(x) =cos(narccos(x)), we can approximate
F(θ)≈
∑n
a cos(nθ).
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun and Approximations
Chebfun is a Matlab package with the primary goal to make computing with functions as similar as possible with computing with vectors, in other words it aims to ”Feel symbolic, but work numeric”.
It expands a given functionf as a Chebyshev series, using a FFT based algorithm, and then performs its calculations on vectors of coefficients.
1 chebfun (@( x ) s i n ( x ) ) ;
6 / 23
Chebfun and Approximations
Chebfun is a Matlab package with the primary goal to make computing with functions as similar as possible with computing with vectors, in other words it aims to ”Feel symbolic, but work numeric”.
It expands a given functionf as a Chebyshev series, using a FFT based algorithm, and then performs its calculations on vectors of coefficients.
1 chebfun (@( x ) s i n ( x ) ) ;
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun System
Chebfuns are polynomial approximations of functions. They can be constructed from a string representing the expression of a function or from an anonymous function.
Normally, chebfuns are represented on[−1,1], but the range can be specified in the constructor and the Chebyshev polynomials employed will be rescaled.
The usual mathematical operators are overloaded in Chebfun, in order to allow operations with chebfuns, combining existing chebfuns to create a new chebfun.
1 x = chebfun (' x ')
2 x . ^2 + 1
3 exp ( x ) . ∗ s i n ( x )
7 / 23
Chebfun System
Chebfuns are polynomial approximations of functions. They can be constructed from a string representing the expression of a function or from an anonymous function. Normally, chebfuns are
represented on[−1,1], but the range can be specified in the constructor and the Chebyshev polynomials employed will be rescaled.
The usual mathematical operators are overloaded in Chebfun, in order to allow operations with chebfuns, combining existing chebfuns to create a new chebfun.
1 x = chebfun (' x ')
2 x . ^2 + 1
3 exp ( x ) . ∗ s i n ( x )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun System
Chebfuns are polynomial approximations of functions. They can be constructed from a string representing the expression of a function or from an anonymous function. Normally, chebfuns are
represented on[−1,1], but the range can be specified in the constructor and the Chebyshev polynomials employed will be rescaled.
The usual mathematical operators are overloaded in Chebfun, in order to allow operations with chebfuns, combining existing chebfuns to create a new chebfun.
1 x = chebfun (' x ')
2 x . ^2 + 1
3 exp ( x ) . ∗ s i n ( x )
7 / 23
Chebfun System
Chebfuns are polynomial approximations of functions. They can be constructed from a string representing the expression of a function or from an anonymous function. Normally, chebfuns are
represented on[−1,1], but the range can be specified in the constructor and the Chebyshev polynomials employed will be rescaled.
The usual mathematical operators are overloaded in Chebfun, in order to allow operations with chebfuns, combining existing chebfuns to create a new chebfun.
1 x = chebfun (' x ')
2 x . ^2 + 1
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebyshev-Gauss-Lobatto Nodes vs.
Equispaced Nodes
Using Chebyshev-Gauss-Lobatto nodes gives a great advantage over equispaced nodes. On an uniform grid the interpolant may oscillate at the ends of the interval, no matter how smooth the function is. To put it another way, in equispaced nodespn(x) may diverge even iffis analytic.
A classic example of this phenomenon is Runge’s function f(x) = 1
1 + 25x2,
for which the interpolation polynomial on an uniform grid on [−1,1]diverges.
8 / 23
Chebyshev-Gauss-Lobatto Nodes vs.
Equispaced Nodes
Using Chebyshev-Gauss-Lobatto nodes gives a great advantage over equispaced nodes. On an uniform grid the interpolant may oscillate at the ends of the interval, no matter how smooth the function is. To put it another way, in equispaced nodespn(x) may diverge even iffis analytic.
A classic example of this phenomenon is Runge’s function f(x) = 1
1 + 25x2,
for which the interpolation polynomial on an uniform grid on
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebyshev-Gauss-Lobatto Nodes vs.
Equispaced Nodes
In contrast the Chebfun System has no problem approximating Runge’s function up to machine precision using189terms of a Chebyshev expansion.
1 f = chebfun (@( x ) (1/(1 + 25 ∗ x^2) ) ) ;
2 l e n g t h ( f )
3 p l o t ( f )
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
9 / 23
Chebyshev-Gauss-Lobatto Nodes vs.
Equispaced Nodes
In contrast the Chebfun System has no problem approximating Runge’s function up to machine precision using189terms of a Chebyshev expansion.
1 f = chebfun (@( x ) (1/(1 + 25 ∗ x^2) ) ) ;
2 l e n g t h ( f )
3 p l o t ( f )
0.6 0.7 0.8 0.9 1
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Edge Detection
It is proven that for a Lipschitz continuous functionfthe Chebyshev series of the function
∑∞ k=0
akTk(x), ak=
∫ 1
−1
f(x)Tk(x)
√1−x2 dx, converges.
Unfortunately, in practice, not all functions are smooth enough. Real functions may satisfy some smoothness conditions only piece-wise. This kind of situation was taken into consideration, as part of the design of the Chebfun System, and it can represent functions as piece-wise polynomials.
10 / 23
Edge Detection
It is proven that for a Lipschitz continuous functionfthe Chebyshev series of the function
∑∞ k=0
akTk(x), ak=
∫ 1
−1
f(x)Tk(x)
√1−x2 dx,
converges.
Unfortunately, in practice, not all functions are smooth enough.
Real functions may satisfy some smoothness conditions only piece-wise. This kind of situation was taken into consideration, as part of the design of the Chebfun System, and it can represent
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Edge Detection
The break points of a picewise continuous function are detected via the algorithm presented in [PPT10], when the option ’splitting’
is on in a chebfun constructor.
When a chebfun is constructed from a combination of other chebfuns, using commands likeabsor maxbreakpoints are also introduced automatically.
1 f = chebfun (@( x ) abs ( s i n (3 ∗ p i ∗ x ) ) , ' s p l i t t i n g ', ' on ')
2 p l o t ( f )
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
-0.2 0 0.2 0.4 0.6 0.8 1
11 / 23
Edge Detection
The break points of a picewise continuous function are detected via the algorithm presented in [PPT10], when the option ’splitting’
is on in a chebfun constructor. When a chebfun is constructed from a combination of other chebfuns, using commands likeabsor maxbreakpoints are also introduced automatically.
1 f = chebfun (@( x ) abs ( s i n (3 ∗ p i ∗ x ) ) , ' s p l i t t i n g ', ' on ')
2 p l o t ( f )
0.6 0.8 1
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Clenshaw-Curtis Algorithm
By approximating the functionf with a Chebyshev expansion, we can construct a cosine approximation for a functionF, given by F(θ) =f(cosθ).
f(cosθ) =F(θ) = a0 2 +
∑∞ k=1
akcos(kθ).
We can make a change of variable in order to use the cosine series
∫ 1
−1
f(x)dx=
∫ π
0
f(cos(θ))sinθdθ.
12 / 23
Clenshaw-Curtis Algorithm
By approximating the functionf with a Chebyshev expansion, we can construct a cosine approximation for a functionF, given by F(θ) =f(cosθ).
f(cosθ) =F(θ) = a0 2 +
∑∞ k=1
akcos(kθ).
We can make a change of variable in order to use the cosine series
∫ 1
−1
f(x)dx=
∫ π
0
f(cos(θ))sinθdθ.
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Clenshaw-Curtis Algorithm
To compute the definite integral offwe can integrate the cosine series term by term
∫ π
0
f(cosθ)sinθdθ=a0+
∑∞ k=1
2a2k 1−(2k)2, wherea2k are Fourier coefficients defined by
a2k = 2π
∫ π
0
f(cosθ)sinkθdθ
13 / 23
Clenshaw-Curtis Algorithm
In our descrete setting we can computea2k using an algorithm based on the Discrete Cosine Transform
a2k≈ 2n (
f(1)
2 + (−1)k f(−21) +
n−1
∑
k=1
f( cosiπn)
coskiπn )
Because we are interested in a discrete representation of a function we can take advantage of the aliasing property of Chebyshev polynomials and arrive at the formula
∫ 1
−1
f(x)dx=a0+ (n−1
∑
k=1 2a2k
1−(2k)2
)
+ 1−a2n(n)2
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Clenshaw-Curtis Algorithm
In our descrete setting we can computea2k using an algorithm based on the Discrete Cosine Transform
a2k≈ 2n (
f(1)
2 + (−1)k f(−21) +
n−1
∑
k=1
f( cosiπn)
coskiπn )
Because we are interested in a discrete representation of a function we can take advantage of the aliasing property of Chebyshev polynomials and arrive at the formula
∫ 1
−1
f(x)dx=a0+ (n−1
∑
k=1 2a2k
1−(2k)2
)
+1−a2n(n)2
14 / 23
Chebfun and Integration
An algorithm similar to the one described above is implemented in the Chebfun System.
Using the FFT and the DCT the coefficientsa2k are computed. The commandsumwhich originally returned the sum of the elements of a vector, was overloaded, and now takes also a chebfun as an argument and returns its integral on the domain of definition.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 sum( f )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun and Integration
An algorithm similar to the one described above is implemented in the Chebfun System.
Using the FFT and the DCT the coefficientsa2k are computed.
The commandsumwhich originally returned the sum of the elements of a vector, was overloaded, and now takes also a chebfun as an argument and returns its integral on the domain of definition.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 sum( f )
15 / 23
Chebfun and Integration
An algorithm similar to the one described above is implemented in the Chebfun System.
Using the FFT and the DCT the coefficientsa2k are computed.
The commandsumwhich originally returned the sum of the elements of a vector, was overloaded, and now takes also a chebfun as an argument and returns its integral on the domain of definition.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 sum( f )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun and Integration
An algorithm similar to the one described above is implemented in the Chebfun System.
Using the FFT and the DCT the coefficientsa2k are computed.
The commandsumwhich originally returned the sum of the elements of a vector, was overloaded, and now takes also a chebfun as an argument and returns its integral on the domain of definition.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 sum( f )
15 / 23
Chebfun and Primitives
Chebfun can also handle indefinite integrals, evaluated as
∫ x
−1
f(t)dt.
Iffis a chebfun, than its indefinite integral will be another chebfun,F, with F′ =f andF(−1) = 0. When we work with definite integrals we should never forget the arbitrary constant of integration.
The commandcumsumnormally had a vector as its input and would return another vector which on each positionkhad the sum of the firstk elements of the original vector. In Chebfun it was overloaded to give the indefinite integral.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun and Primitives
Chebfun can also handle indefinite integrals, evaluated as
∫ x
−1
f(t)dt.
Iffis a chebfun, than its indefinite integral will be another chebfun,F, with F′ =f andF(−1) = 0. When we work with definite integrals we should never forget the arbitrary constant of integration.
The commandcumsumnormally had a vector as its input and would return another vector which on each positionkhad the sum of the firstk elements of the original vector. In Chebfun it was overloaded to give the indefinite integral.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
16 / 23
Chebfun and Primitives
Chebfun can also handle indefinite integrals, evaluated as
∫ x
−1
f(t)dt.
Iffis a chebfun, than its indefinite integral will be another chebfun,F, with F′ =f andF(−1) = 0. When we work with definite integrals we should never forget the arbitrary constant of integration.
The commandcumsumnormally had a vector as its input and would return another vector which on each positionkhad the sum of the firstk elements of the original vector. In Chebfun it was overloaded to give the indefinite integral.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun and Primitives
Chebfun can also handle indefinite integrals, evaluated as
∫ x
−1
f(t)dt.
Iffis a chebfun, than its indefinite integral will be another chebfun,F, with F′ =f andF(−1) = 0. When we work with definite integrals we should never forget the arbitrary constant of integration.
The commandcumsumnormally had a vector as its input and would return another vector which on each positionkhad the sum of the firstk elements of the original vector. In Chebfun it was overloaded to give the indefinite integral.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
16 / 23
Differentiation
The idea of a matrix acting on a vector is extended naturally to Chebfun, with the place of matrix occupied by linear operators, called chebops.
One of the most important class of linear operators is the class of differential operators. Expanding the functionfas a series of Chebyshev polynomials we can differentiate term by term arriving at a spectral method of differentiation.
Chebfun overloads the standard Matlab commanddiff, which normally takes in a vector and returns a vector of finite differences. diffcan now take as argument a chebfun and it will return its derivative.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Differentiation
The idea of a matrix acting on a vector is extended naturally to Chebfun, with the place of matrix occupied by linear operators, called chebops.
One of the most important class of linear operators is the class of differential operators. Expanding the functionfas a series of Chebyshev polynomials we can differentiate term by term arriving at a spectral method of differentiation.
Chebfun overloads the standard Matlab commanddiff, which normally takes in a vector and returns a vector of finite differences. diffcan now take as argument a chebfun and it will return its derivative.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
17 / 23
Differentiation
The idea of a matrix acting on a vector is extended naturally to Chebfun, with the place of matrix occupied by linear operators, called chebops.
One of the most important class of linear operators is the class of differential operators. Expanding the functionfas a series of Chebyshev polynomials we can differentiate term by term arriving at a spectral method of differentiation.
Chebfun overloads the standard Matlab commanddiff, which normally takes in a vector and returns a vector of finite differences.
diffcan now take as argument a chebfun and it will return its derivative.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Differentiation
The idea of a matrix acting on a vector is extended naturally to Chebfun, with the place of matrix occupied by linear operators, called chebops.
One of the most important class of linear operators is the class of differential operators. Expanding the functionfas a series of Chebyshev polynomials we can differentiate term by term arriving at a spectral method of differentiation.
Chebfun overloads the standard Matlab commanddiff, which normally takes in a vector and returns a vector of finite differences.
diffcan now take as argument a chebfun and it will return its derivative.
1 f = chebfun (@( x ) s i n ( x ) , [ 0 , p i ] ) ;
2 cumsum( f )
17 / 23
Chebops
We can define a chebop using the constructor.
1 D = chebop (@(u) d i f f (u) )
Chebfun sees chebops as direct analogues to matrices. They act as linear operators on chebfuns, condition by sharing the same
domain. Similar to the constructor for chebfuns we can change the domain of definition for a chebop.
1 I = chebop (@(u)cumsum(u) , [ 0 , 1 ] )
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebops
We can define a chebop using the constructor.
1 D = chebop (@(u) d i f f (u) )
Chebfun sees chebops as direct analogues to matrices. They act as linear operators on chebfuns, condition by sharing the same
domain. Similar to the constructor for chebfuns we can change the domain of definition for a chebop.
1 I = chebop (@(u)cumsum(u) , [ 0 , 1 ] )
18 / 23
Chebfun and ODEs
Chebops can be combined to create differential and integral equations of the form
Lu=f(u).
Because both the operator and the function on which it operates are represented discreetly, solving a linear operator equation reduces to solving a system of linear equations. Chebfun can employ different techniques to solve equation ranging from direct methods like LU factorization to iterative methods like Krylov Subspace Methods and Conjugate Gradient.
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Chebfun and ODEs
Chebops can be combined to create differential and integral equations of the form
Lu=f(u).
Because both the operator and the function on which it operates are represented discreetly, solving a linear operator equation reduces to solving a system of linear equations. Chebfun can employ different techniques to solve equation ranging from direct methods like LU factorization to iterative methods like Krylov Subspace Methods and Conjugate Gradient.
19 / 23
Solving IVPs
To uniquely determine the solution of an Initial Value Problem we need to supply the value of the function, and eventually its derivatives, at a pointx0.
In Chebfun the initial condition is stored as a field called lbc (left boundary condition) in the class chebop. The operator\, that in Matlab solves a system of linear equations, was overloaded to solve a linear operator equation.
Since 2014 Chebfun has changed its approach to solve IVPs using the differentiation of Chebyshev polynomials, and now uses the classic methods from Matlab like ode45. All this functions were overloaded to accept chebfuns as arguments.
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Solving IVPs
To uniquely determine the solution of an Initial Value Problem we need to supply the value of the function, and eventually its derivatives, at a pointx0.
In Chebfun the initial condition is stored as a field called lbc (left boundary condition) in the class chebop. The operator\, that in Matlab solves a system of linear equations, was overloaded to solve a linear operator equation.
Since 2014 Chebfun has changed its approach to solve IVPs using the differentiation of Chebyshev polynomials, and now uses the classic methods from Matlab like ode45. All this functions were overloaded to accept chebfuns as arguments.
20 / 23
Solving IVPs
To uniquely determine the solution of an Initial Value Problem we need to supply the value of the function, and eventually its derivatives, at a pointx0.
In Chebfun the initial condition is stored as a field called lbc (left boundary condition) in the class chebop. The operator\, that in Matlab solves a system of linear equations, was overloaded to solve a linear operator equation.
Since 2014 Chebfun has changed its approach to solve IVPs using the differentiation of Chebyshev polynomials, and now uses the classic methods from Matlab like ode45. All this functions were overloaded to accept chebfuns as arguments.
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Solving IVPs
The damped harmonic oscillator:
1 D = chebop (@(u) d i f f (u , 2)+0. 4 ∗ d i f f (u)+s i n (u) , [ 0 , 1 0 ] ) ;
2 D.lbc = [ 1 , 0 ] ;
3 s o l = D\ chebfun (' 0 ', [ 0 , 1 0 ] ) ;
We get the following solution:
0 1 2 3 4 5 6 7 8 9 10
-1 -0.5 0 0.5 1
21 / 23
Solving BVPs
Chebfun can also handle Boundary Value Problems. The algorithm is also based on constructing a differential matrix and solving a system of linear equations.
1 D = chebop (@(u) d i f f (u , 2)+0. 4 ∗ d i f f (u)+s i n (u) , [ 0 , 1 0 ] ) ;
2 D.lbc = 1 ;
3 D.rbc = 0 . 3 ;
4 s o l = D\ chebfun (' 0 ', [ 0 , 1 0 ] ) ;
0 1 2 3 4 5 6 7 8 9 10
0 1000 2000 3000 4000 5000 6000 7000
. . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . .
. .
. . . . .
Solving BVPs
Chebfun can also handle Boundary Value Problems. The algorithm is also based on constructing a differential matrix and solving a system of linear equations.
1 D = chebop (@(u) d i f f (u , 2)+0. 4 ∗ d i f f (u)+s i n (u) , [ 0 , 1 0 ] ) ;
2 D.lbc = 1 ;
3 D.rbc = 0 . 3 ;
4 s o l = D\ chebfun (' 0 ', [ 0 , 1 0 ] ) ;
0 1 2 3 4 5 6 7 8 9 10
0 1000 2000 3000 4000 5000 6000 7000
22 / 23
References
L. N. Trefethen,Chebfun Guide. 2009.url:
https://www.mathworks.com/matlabcentral/mlc- downloads/downloads/submissions/23972/
versions/22/previews/chebfun/guide/html/
guide1.html.
R. Pachon, R. B. Platte, and L. N. Trefethen,
Piecewise-smooth chebfuns. IMA Journal of Numerical Analysis 30 (4 2010).
L. N. Trefethen,Approximation Theory and Approximation Practice. SIAM, 2013.