Constructing Chebfun2 from slightly non-smooth chebfun seems not working

21 views
Skip to first unread message

Mike

unread,
May 19, 2020, 5:19:43 AM5/19/20
to chebfun-users

Hello friends!

I have a very simple question (I think!) but surprisingly it does not work. I would like to make a chebfun2
function which is made of a chebfun function where the later is not smooth. Consider the following:

>> f=chebfun({0,@(x)sin(x)},[-2 0 2],'vectorize');
>> g=chebfun(@(y)y,[0 3],'vectorize');
>> h=chebfun2(@(x,y)f(x)*g(y),[-2 2 0 3],'vectorize');

I did try both splitting on and off options. I wait a lot and at the end neighter I get error message nor I get any solution.

Thanks for your response!

Very best,
Babak



Nick Trefethen

unread,
May 19, 2020, 5:26:19 AM5/19/20
to chebfun-users
Chebfun2 is made for smooth functions, so this won't work.  However, you can get a reasonable approximation by forcing it to take a grid of a fixed size.  For example, here I make the grid of size 100 x 100:
```
>> f=chebfun({0,@(x)sin(x)},[-2 0 2]);
>> g=chebfun(@(y)y,[0 3]);
>> h=chebfun2(@(x,y)f(x).*g(y),[-2 2 0 3],[100,100]);
>> surf(h), camlight

plt.png

```
The plot is below.
Reply all
Reply to author
Forward
0 new messages