• Nu S-Au Găsit Rezultate

Introduction to the Chebfun System

N/A
N/A
Protected

Academic year: 2022

Share "Introduction to the Chebfun System"

Copied!
54
0
0

Text complet

(1)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

Introduction to the Chebfun System

Titus Pinta

Presentation at the ICTP Institute Seminar, January 30, 2019.

1 / 23

(2)

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

(3)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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)−Tn1(x), T0(x) = 1, T1(x) =x.

3 / 23

(4)

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)−Tn1(x), T0(x) = 1, T1(x) =x.

(5)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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)−Tn1(x), T0(x) = 1, T1(x) =x.

3 / 23

(6)

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

(7)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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(x1)1)n

n1

k=1

f(xk)(1)k x−xk

1

2(x+1) +2(x(1)1)n +

n1

k=1

(1)k x−xk

4 / 23

(8)

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(x1)1)n

n1

k=1

f(xk)(1)k x−xk

n1

∑(1)k

(9)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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(x1)1)n

n1

k=1

f(xk)(1)k x−xk

1

2(x+1) +2(x(1)1)n +

n1

k=1

(1)k x−xk

4 / 23

(10)

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.

(11)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(12)

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θ).

(13)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(14)

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 ) ) ;

(15)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(16)

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 )

(17)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(18)

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

(19)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(20)

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

(21)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(22)

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

(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 functions as piece-wise polynomials.

10 / 23

(24)

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

(25)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(26)

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

(27)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(28)

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θ.

(29)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(30)

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) +

n1

k=1

f( cosn)

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+ (n1

k=1 2a2k

1(2k)2

)

+ 1a2n(n)2

(31)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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) +

n1

k=1

f( cosn)

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+ (n1

k=1 2a2k

1(2k)2

)

+1a2n(n)2

14 / 23

(32)

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 )

(33)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(34)

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 )

(35)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(36)

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 )

(37)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(38)

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 )

(39)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(40)

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 )

(41)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(42)

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 )

(43)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(44)

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 ] )

(45)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(46)

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.

(47)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(48)

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.

(49)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(50)

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.

(51)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(52)

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

(53)

. . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . .

. .

. . . . .

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

(54)

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.

Referințe

DOCUMENTE SIMILARE

1 Department of Physical Medicine and Rehabilitation, National Taiwan University Hospital, Bei Hu Branch and National Taiwan University College of Medicine, Taipei, Taiwan,

Transverse (a) and longitudinal (b) transvaginal ultrasound exhibit an isoechoic solid mass measuring 4 cm in size, with mul- tiple intralesional echogenic foci (arrows) and

The book opens with an introduction that provides a brief historical orientation to the background and methods of philosophical investigation and then discusses how the study

Left: The predictions of the model for 1,2,3 and 4 parameters, along with the real data (open circles) generated from a 4 parameter model with noise.. Right: the AIC values for

An AR system adds virtual computer generated objects, audio and other sense enhancements to a real-world environment which is interactive in real time.. Aim: To enhance a

projection visual displays, but it is possible to use speakers with head-based visual displays It is also possible to combine the two types of aural display systems: bass sounds

Plausibility illusion is the feeling that the world is real and that is responding to us Embodiment illusion is the feeling that we have a body in the virtual

The Dope Sheet View is used to visualize motion tracking data, it is implemented as separate view of the Movie Clip editor just like the Graph View. It displays channels for