1 | |
---|
2 | function pass = guide2tests |
---|
3 | |
---|
4 | % LNT 25 May 2008 |
---|
5 | % Various tests from chapter 2 of the Chebfun Guide. |
---|
6 | |
---|
7 | splitting on |
---|
8 | |
---|
9 | f = chebfun('log(1+tan(x))',[0 pi/4]); |
---|
10 | I = sum(f); Iexact = pi*log(2)/8; |
---|
11 | err1 = I-Iexact; pass1 = err1<chebfunpref('eps')*10; |
---|
12 | |
---|
13 | f = chebfun('sin(sin(x))',[0 1]); |
---|
14 | I = sum(f); Iexact = 0.4306061031206906049; |
---|
15 | err2 = I-Iexact; pass2 = err2<chebfunpref('eps')*10; |
---|
16 | |
---|
17 | t = chebfun('t',[0,1]); |
---|
18 | f = 2*exp(-t.^2)/sqrt(pi); |
---|
19 | I = sum(f); Iexact = erf(1); |
---|
20 | err3 = I-Iexact; pass3 = err3<chebfunpref('eps')*10; |
---|
21 | |
---|
22 | f = chebfun(@(x) abs(besselj(0,x)),[0 20]); |
---|
23 | I = sum(f); Iexact = 4.4450316030016; |
---|
24 | err4 = I-Iexact; pass4 = err4<chebfunpref('eps')*1e3; |
---|
25 | |
---|
26 | x = chebfun('x'); |
---|
27 | f = sech(3*sin(10*x)); |
---|
28 | g = sin(9*x); h = min(f,g); |
---|
29 | I = sum(h); Iexact = -0.38155644885025; |
---|
30 | err5 = I-Iexact; pass5 = err5<chebfunpref('eps')*10; |
---|
31 | |
---|
32 | % splitting off |
---|
33 | % x = chebfun('x',[0 1]); |
---|
34 | % f = sech(10*(x-0.2)).^2 + sech(100*(x-0.4)).^4 + sech(1000*(x-0.6)).^6; |
---|
35 | % I = sum(f); Iexact = 0.210802735500549; |
---|
36 | % err6 = I-Iexact; pass6 = err6<chebfunpref('eps')*10; |
---|
37 | pass6 = 1; %commented out to save time |
---|
38 | |
---|
39 | % splitting on |
---|
40 | % f = sech(10*(x-0.2)).^2 + sech(100*(x-0.4)).^4 + sech(1000*(x-0.6)).^6; |
---|
41 | % I = sum(f); |
---|
42 | % err7 = I-Iexact; pass7 = err7<1e2*chebfunpref('eps'); |
---|
43 | pass7 = 1; %commented out to save time |
---|
44 | |
---|
45 | pass = pass1 && pass2 && pass3 && pass4 && pass5 && pass6 && pass7; |
---|