source: MML/trunk/machine/SOLEIL/common/toolbox/chebfun_v2_0501/chebfun/chebtests/invtest.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 872 bytes
Line 
1function pass = invtest
2
3% Nick Hale  07/06/2009
4tol = chebfunpref('eps');
5
6x = chebfun('x');
7f = sin(x);
8g = chebfun(@(x) asin(x), [sin(-1),sin(1)]);
9finv = inv(f);
10pass1 = norm(g - finv,inf) < 100*tol;
11
12% %  commented for speed
13pass2 = true;
14% pass2 = norm(f - inv(finv),inf) < 100*tol;
15
16% %  commented for speed
17pass3 = true;
18% x = chebfun('x',[0,1]);
19% f = sqrt(x);
20% g = x.^2;
21% finv = inv(f,'splitting',true);
22% pass3 = norm(g - finv,inf) < 100*tol;
23
24x = chebfun('x');
25f = chebfun(@(x) sausagemap(x));
26finv = inv(f);
27pass4 = norm(f(finv)-x,inf) + norm(finv(f)-x,inf) < 200*tol;
28
29pass = pass1 && pass2 && pass3 && pass4;
30
31function [g,gprime] = sausagemap(s,d)
32if nargin<2, d = 9; end % this can be adjusted
33c = zeros(1,d+1);
34c(d:-2:1) = [1 cumprod(1:2:d-2)./cumprod(2:2:d-1)]./(1:2:d);
35c = c/sum(c); g = polyval(c,s);
36cp = c(1:d).*(d:-1:1); gprime = polyval(cp,s);
37
38
Note: See TracBrowser for help on using the repository browser.