2d unequally spaced

48 views
Skip to first unread message

Jason Nicholson

unread,
Jun 21, 2024, 9:33:05 AM6/21/24
to chebfun-users
Dear All,

I am modeling some unequally spaced data, trying to recover an accurate 2d function. I am working on thermodynamic fluid property modeling where having several accurate derivatives is useful. 

While I do want a 2d function, I think I should start with asking the question, how do I find a 1d function of unequally spaced data that doesn't have the runge phenomenon?

Here is an example x:
x = [-10 -5 0 40 80 120 150]; % unequally spaced

What do you recommend?

Nick Trefethen

unread,
Jun 24, 2024, 10:12:18 AM6/24/24
to chebfun-users
Mr. Nicholson - sometimes rational approximations can do better than polynomials (not always), and you can compute them with `aaa.m`.  Below are a little code and the figure it generates, illustrating how this can sometimes work.  See "Numerical analytic continuation", including the section on 2D problems, at https://people.maths.ox.ac.uk/trefethen/papers.html.  Also the paper "AAA interpolation of equispaced data" (for the data don't have to be equispaced).

```
MS = 'markersize'; LW = 'linewidth';
grid = [-10:5:0 40:40:120 150];
f = chebfun('exp(-x/40)',[-10 150]);
subplot(311), plot(f,LW,1.4), hold on
data = f(grid); plot(grid,data,'.k',MS,10), hold off, grid on
title('data')

subplot(312), p = chebfun.interp1(grid,data);
plot(p,LW,1.4), hold on
plot(grid,data,'.k',MS,10), hold off, grid on
err = norm(f-p,inf);
title(['polynomial interpolant: error = ', num2str(err)])

subplot(313), r = aaa(data,grid);
pAAA = chebfun(r,[-10 150]); plot(pAAA,LW,1.4), hold on
plot(grid,data,'.k',MS,10), hold off, grid on
err = norm(f-pAAA,inf);
title(['AAA rational approximant: error = ', num2str(err)])
```
fig.jpg

Jason Nicholson

unread,
Jul 3, 2024, 10:49:20 AM7/3/24
to chebfun-users
Dr. Trefethen,

Thank you for the reply. I appreciate it. I will look into this closely and report back.

Dr. Trefethen, I am a big admirer of your work. I think I began following chebfun and your work on polynomials around 2019. This led to going through the materials available from your website on function approximation, various lectures, and various papers and creating a YouTube playlist of your various lectures, Nick Trefethen. In short, I appreciate your work. I have also followed some of your colleagues as well. In short, thank you!

Sincerely,
an engineer,
Jason Nicholson
Reply all
Reply to author
Forward
0 new messages