
[Sponsors] 
May 12, 2020, 00:05 
Least approximation of derivative

#1 
Senior Member

Greetings,
Recently, I've read some papers in which they are using leastsquare to approximate the 2bdorder derivatives of a given 1D data. I couldn't figure out how to do this, and I couldn't find any helpful references online. Can anyone give me some hint, or recommend some references? Appreciate it! Edit: To be more specific, my purpose is to evaluate the following 2ndorder derivative where is just the integer wavenumber, and is a given function in spectral space. Last edited by TurbJet; May 12, 2020 at 22:04. 

May 12, 2020, 00:52 

#2  
Senior Member
Troy Snyder
Join Date: Jul 2009
Location: Akron, OH
Posts: 219
Rep Power: 18 
Quote:


May 12, 2020, 04:32 

#3 
Senior Member

The general idea is that you write a 1st order taylor series approximation of a variable phi in the neighborhood n of the point c where you need the gradient (it is used for gradients in general) and assume that:
phi_n = phi_c + dphi/dx_i * (x_nx_c)_i Write this for all the available neighbors of a given point c and you get a system of equations that, in most cases, needs to be solved by a least squares method because you have more neighbors than gradient components. However, the exact least squares solution of the equations is available and you don't typically solve it by a numerical procedure. There is abundant literature on this. I suggest the book by Blazek as textbook reference because it is the one that covers it best (he and Haselbacher actually developed one of the available closed solutions to the problem). EDIT: a different version of the exact solution (basically, you have the one based on solving the normal equations and the one based on QR factorization) can also be found in several of the early works of Prof. Z. J. Wang but, unfortunately, each one of them has a slight little error, and you need to look at all of them together to catch it. Let me also highlight that the work of Blazek and Haselbacher is more general and has, indeed, been extended to higher than first order approximations (used for kexact rexonstructions) as well as to filters for unstructured grids. Doru Caraeni also put forward some developments/derivations for the easy application for 3rd order codes Finally, Nishikawa and coworkers have also made several studies recently Last edited by sbaffini; May 12, 2020 at 08:23. 

May 12, 2020, 13:20 

#4 
Senior Member

Join Date: Jul 2012
Location: Germany
Posts: 184
Rep Power: 13 
Or you simply use this slide:
edit: By the way it is called Least Squares! 

May 12, 2020, 21:37 

#5 
Senior Member

Maybe, but I am not sure. The paper I read is using this leastsquares approximation to approximate the 2ndorder derivative of the energy flux of HIT in spectral space. The reason they're using this is because the underlying grid is nonuniform.


May 12, 2020, 21:42 

#6 
Senior Member

Is this applicable to 1D case? I am just looking for an approach to differentiate a function on a nonuniform grid. The paper I referred to use this leastsquares approximation to find out the 2ndderivative of a given dataset.


May 12, 2020, 21:49 

#7  
Senior Member

Quote:


May 13, 2020, 02:19 

#8  
Senior Member

Join Date: Jul 2012
Location: Germany
Posts: 184
Rep Power: 13 
Quote:
Quote:
and therefore . This is more easy to discretisize. Regards Last edited by Eifoehn4; May 13, 2020 at 04:43. 

May 13, 2020, 06:10 

#9 
Senior Member

Quote:
for a function of the form , representative of the energy at large large scales (i.e., no dissipative range). When you look at this in log k the peak is much more spread (besides the fact that the delta log(k) are much smaller than the delta k). However, without knowing the original use case for least squares here, Ferziger & Peric has straighforward formulas for both 1st and 2nd derivatives in 1D for non uniform grids, without need to resort to anything fancy. 

May 13, 2020, 07:02 

#10 
Senior Member

Join Date: Jul 2012
Location: Germany
Posts: 184
Rep Power: 13 
Quote:


May 13, 2020, 15:29 

#11 
Senior Member


May 13, 2020, 15:37 

#12 
Senior Member

Quote:


May 13, 2020, 16:18 

#13 
Senior Member

Well, the function I used is just an example of how the energy spectra behave at low wave numbers (I used k^4, but k^2 would have been another possibility), where they tipically have a peak.
Now, what approach is more suited obviously depends from what the final goal is, but I would point out the following: 1) The formula with log k is just a second derivative, while the formula with k has two derivatives (first and second) multiplied by k and k^2 respectively. More work and typically more error. 2) The steps in k are much larger than those in log k, so this is necessarily linked to higher error 3) Now that I think more about it, this might simply be a restatement of 2 but, if you plot the function above as function of k and of log k, the latter is much more smoother around the peak, which means that any given formula would give less error. When I wrote the message this morning, I actually tried both formulas and they indeed differ at low wavenumbers for the function I mentioned. I deleted the script I used, but I suggest you to make a similar test to better understand them both. 

May 13, 2020, 18:08 

#14  
Senior Member

Quote:


Tags 
derivative, leastsquares, numerical analysis, numerical method 
Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Error when calculating the second derivative using the derivative function d2dy2  mona.li  Tecplot  0  July 8, 2018 14:11 
Time derivative of pressure in low mach number approximation  hnemati  Main CFD Forum  1  June 16, 2016 07:05 
Tangential derivative on curved boundary  Simbelmynė  Main CFD Forum  40  October 14, 2014 06:57 
discontinuous second derivative  new_at_this  Main CFD Forum  9  April 28, 2012 16:55 
Different one sided derivative approximation?  zonexo  Main CFD Forum  2  January 11, 2006 04:40 