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