# Solving PDE's with chebychev FFT

• I
• fahraynk
In summary, the conversation discusses two different methods for solving a PDE using Fast Fourier Transform. One lecturer solves the PDE by transforming it into an ODE and using an ODE solver, while the other uses FFT and iFFT in both x-space and theta-space. The difference between the two methods lies in the use of the chain rule and the presence of the term sqrt(1-x^2) in the book's method. The reason for this difference is unclear, but it could be due to the initial conditions of the PDE.
fahraynk
I have seen one lecturer solve a PDE with just using Fast Fourier Transform (##FFT##) of a function ##v## on a chebychev grid. ##v_t=\mu v_x##

This lecturer uses ##FFT## on ##V##, then solves the ODE using an ODE solver in Matlab, then inverse ##FFT## to get the real solution :
$$FFT(v_t)=\hat{v_t}=FFT(\mu v_x)\\ =>\frac{\partial{\hat{v}}}{\partial{t}}=iK\mu \hat{v}$$
##K## is a vector of wave numbers, ##FFT## is fast Fourier transform of a function, ##ifft## is the inverse fast Fourier transform, and ##i## is the imaginary number.

the lecturer solves for ##\hat{v}## with an ODE solver, then inverse Fourier transform to get solution ##v##.

BUT, in the book Spectral Methods for Matlab, the author first transforms the function with ##FFT##, then he calculates the derivative in Fourier space, then the author claims he must transform this back into ##x## space to get the derivative. So, $$\mu \hat{v}_x=\mu iK\hat{v}\\ v_x=-\frac{ifft(\mu iK\hat{v})}{\sqrt{1-x^2}}$$

the ##\sqrt{1-x^2}## comes from chain rule derivative, where the author states when he takes the ##FFT## of the function, it puts the function into ##\theta## space, so to get the x derivative the author has to use chain rule for some reason.

I can't figure out why the methods are different. The only idea I have is maybe the first lecturer's function V is approximately zero at the boundaries, while the Spectral Methods for Matlab author's function is not zero at the boundaries. Could this be the only difference?

I understand what the lecturer does , and that is standard theory of transforming PDEs to ODEs using Fourier transform.

However I can't quite understand what the book does, and how exactly it uses the chain rule. Can you post screenshots of the respective book pages?

Delta² said:
I understand what the lecturer does , and that is standard theory of transforming PDEs to ODEs using Fourier transform.

However I can't quite understand what the book does, and how exactly it uses the chain rule. Can you post screenshots of the respective book pages?

This function outputs the derivative of a grid function v based on the above method :

#### Attachments

24.3 KB · Views: 908
9.5 KB · Views: 893
34.2 KB · Views: 849
26.2 KB · Views: 531
15.1 KB · Views: 780
5.2 KB · Views: 550
I have trouble understanding what the book does (especially the part with the algebraic and trigonometric interpolant of the given data), but I think at the end it calculates the derivative of a known function (given data). It doesn't solve a PDE.

Delta² said:
I have trouble understanding what the book does (especially the part with the algebraic and trigonometric interpolant of the given data), but I think at the end it calculates the derivative of a known function (given data). It doesn't solve a PDE.

Yeah, I know, but it is used to solve a pde, ##u_{tt}=u_{xx}##. Author uses leap from in time and chebfft (the program above) twice to approximate the x derivative.

#### Attachments

32 KB · Views: 837
Well the book in calculating the derivative for some reason it chooses to work in ##\theta## space (I guess for better accuracy), that is it first does the transform ##x=\cos\theta## and then it calculates ##v'(\theta)## with the aid of FFT, and then it uses the chain rule to calculate for ##v'(x)=v'(\theta)\frac{d\theta}{dx}=v'(\theta)\frac{1}{\sqrt{1-x^2}}##(1).

It doesn't solve a PDE which would involve ##\theta## and ##x## as independent variables.

I guess you interpret equation (1) as some sort of PDE, no it isn't a PDE.

Delta² said:
Well the book in calculating the derivative for some reason it chooses to work in ##\theta## space (I guess for better accuracy), that is it first does the transform ##x=\cos\theta## and then it calculates ##v'(\theta)## with the aid of FFT, and then it uses the chain rule to calculate for ##v'(x)=v'(\theta)\frac{d\theta}{dx}=v'(\theta)\frac{1}{\sqrt{1-x^2}}##(1).

It doesn't solve a PDE which would involve ##\theta## and ##x## as independent variables.

I guess you interpret equation (1) as some sort of PDE, no it isn't a PDE.

The program in my last post, program 19, is solving $$\frac{\partial^2 u}{\partial t^2} = \frac{\partial^2 u}{\partial x^2}$$ That is the PDE I am talking about. The author is solving it with leapfrog in ##t## and fft on chebyshev points in ##x##, but the only difference seems to be the ##\sqrt{1-x^2}## term. I don't understand why one author needs this extra term and the other doesn't. Why one author considers it ##\theta## space and the other does not.

The only answer I can think of is maybe the initial condition is zero at the boundaries in one case and not zero in the other case.

fahraynk said:
The program in my last post, program 19, is solving $$\frac{\partial^2 u}{\partial t^2} = \frac{\partial^2 u}{\partial x^2}$$ That is the PDE I am talking about. The author is solving it with leapfrog in ##t## and fft on chebyshev points in ##x##, but the only difference seems to be the ##\sqrt{1-x^2}## term. I don't understand why one author needs this extra term and the other doesn't. Why one author considers it ##\theta## space and the other does not.

The only answer I can think of is maybe the initial condition is zero at the boundaries in one case and not zero in the other case.
I am not sure either why the book works with the FFT and iFFT in ##\theta## space (it might had to do with the boundary conditions or for better accuracy in the calculation of the derivative), but that's where the extra term ##\sqrt{1-x^2}## comes from.

The lecturer works in all cases with FFT and iFFT in x-space. The book, inside chebfft(v(x)) works with FFT and iFFT in ##\theta## space not in x-space. so it calculates ##v_{\theta}=iFFT(\mu iK\hat{v})## and then it uses the chain rule ##v_x=v_{\theta}\cdot\frac{d\theta}{dx}##. When ##x=\cos\theta## or equivalently ##\theta=\arccos x## then ##\frac{d\theta}{dx}=\frac{-1}{\sqrt{1-x^2}}##.

Delta² said:
I am not sure either why the book works with the FFT and iFFT in ##\theta## space (it might had to do with the boundary conditions or for better accuracy in the calculation of the derivative), but that's where the extra term ##\sqrt{1-x^2}## comes from.

The lecturer works in all cases with FFT and iFFT in x-space. The book, inside chebfft(v(x)) works with FFT and iFFT in ##\theta## space not in x-space. so it calculates ##v_{\theta}=iFFT(\mu iK\hat{v})## and then it uses the chain rule ##v_x=v_{\theta}\cdot\frac{d\theta}{dx}##. When ##x=\cos\theta## or equivalently ##\theta=\arccos x## then ##\frac{d\theta}{dx}=\frac{-1}{\sqrt{1-x^2}}##.

So, if ##iFFT## is in ##\theta##-space, and the author transforms the answer back into ##x##-space, than doesn't that mean the author has to initially transform the data from ##x##-space to ##\theta##-space? But the author starts out with a function defined on a chebyshev grid, and just uses chebfft on it. I don't see where the author originally transforms it from ##x##-space to ##\theta##-space, so I don't understand why he is transforming it back.

fahraynk said:
So, if ##iFFT## is in ##\theta##-space, and the author transforms the answer back into ##x##-space, than doesn't that mean the author has to initially transform the data from ##x##-space to ##\theta##-space?

I think it does the transform of data from the x-space to θ - space in the lines from 2 to 4 inside the function chebfft(v), at least that's what I see in the image you uploaded and contains the code for chebfft(v). Inside it defines a new V that contains the transformed data and then it does FFT to V (not to v) , and proceeds with iFFT on the result it gets.

fahraynk
Delta² said:
I think it does the transform of data from the x-space to θ - space in the lines from 2 to 4 inside the function chebfft(v), at least that's what I see in the image you uploaded and contains the code for chebfft(v). Inside it defines a new V that contains the transformed data and then it does FFT to V (not to v) , and proceeds with iFFT on the result it gets.
Thanks again,

$$v=v(:)\\ V=[v;flipud(v(2:N))];$$

I thought those 2 lines just makes the grid function periodic, although I admit I don't fully understand why he did this!

If I take those lines out and just set : $$w=iFFT(i*K*FFT(v))$$, do you think it would be the same solution? I wonder why this "transform" makes the equation more accurate when he is already using chebychev grid points, what good does it do making it periodic with some weird flipping function (flipud)...

Delta2
It is a mystery to me too why it choses to work in θ -space .

If you take out those lines and proceed as you say, I don't think you ll get exactly the same solution but approximately the same solution maybe. You will also have to remove the line that applies the chain rule (line 8 or 9), otherwise you ll get totally different solutions.

## 1. What is a PDE?

A PDE, or partial differential equation, is a mathematical equation that involves multiple variables and their partial derivatives. It is used to model and describe physical phenomena in fields such as physics, engineering, and economics.

## 2. How does the chebychev FFT method solve PDEs?

The chebychev FFT method is a numerical method that uses fast Fourier transforms and chebychev polynomials to solve PDEs. It converts the PDE into a system of algebraic equations, which can then be solved using the FFT algorithm.

## 3. What are the advantages of using chebychev FFT for solving PDEs?

Chebychev FFT offers several advantages over other numerical methods for solving PDEs. It is highly accurate, efficient, and can handle complex boundary conditions. It also has a low memory requirement and is parallelizable, making it suitable for large-scale computations.

## 4. Are there any limitations to using chebychev FFT for solving PDEs?

Like any other numerical method, chebychev FFT has its limitations. It is most effective for solving PDEs with smooth solutions and may not perform well for problems with discontinuities or singularities. Additionally, the algorithm may become unstable for certain types of PDEs.

## 5. What are some applications of solving PDEs with chebychev FFT?

Chebychev FFT has a wide range of applications in various fields, including fluid dynamics, heat transfer, and quantum mechanics. It is commonly used to solve problems involving wave propagation, diffusion, and convection. It is also useful for solving boundary value problems and optimization problems.

• Calculus and Beyond Homework Help
Replies
5
Views
376
• Electrical Engineering
Replies
8
Views
1K
• Differential Equations
Replies
1
Views
2K
• General Math
Replies
1
Views
1K
• Calculus and Beyond Homework Help
Replies
3
Views
2K
• Differential Equations
Replies
8
Views
3K
• Calculus and Beyond Homework Help
Replies
2
Views
2K
• Differential Equations
Replies
2
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
• Mechanics
Replies
3
Views
2K