|
11 | 11 | f(3) = sin(x)/x; |
12 | 12 | f(4) = cos(x); |
13 | 13 |
|
14 | | -% g(1) = 0.00181258334235528*x^6 + 0.0080200206419458*x^5 + 0.0419670793931914*x^4 + 0.166391821690428*x^3 + 0.500099940056635*x^2 + 0.999987610323461*x + 1.00000138583625; |
15 | | -% g(2) = - 0.0312013789893733*x^6 + 0.101964634786825*x^5 - 0.187255939165997*x^4 + 0.30301542826567*x^3 - 0.492957605179448*x^2 + 0.999422879211686*x + 0.0000811859400770467; |
16 | | -% g(3) = 0.00000269375975765659*x^8 - 0.000198358664086584*x^6 + 0.00833331406945632*x^4 - 0.166666664261236*x^2 + 0.999999999951925; |
17 | | -% g(4) = 0.0000241212010831705*x^8 - 0.00138829603431855*x^6 + 0.0416664553753419*x^4 - 0.499999973621718*x^2 + 0.999999999472876; |
18 | | -% |
19 | | -% err = [0.000002, 0.0001, 0.0000000001, 0.000000001] ; |
20 | | - |
| 14 | +% Expand Taylor series around hand-picked point. |
21 | 15 | [g(1), err(1)] = ChebyshevPolyfit(f(1), 6, 0, 1, 0.3762); |
22 | 16 | [g(2), err(2)] = ChebyshevPolyfit(f(2), 6, 0, 1, 0.1113); |
23 | 17 | [g(3), err(3)] = ChebyshevPolyfit(f(3), 8, -1, 1, 0); |
24 | 18 | [g(4), err(4)] = ChebyshevPolyfit(f(4), 8, -1, 1, 0); |
25 | 19 |
|
| 20 | +% Expand Taylor series around the central point. |
26 | 21 | % [g(1), err(1)] = ChebyshevPolyfit(f(1), 6, 0, 1, 0); |
27 | 22 | % [g(2), err(2)] = ChebyshevPolyfit(f(2), 6, 0, 1, 0); |
28 | 23 | % [g(3), err(3)] = ChebyshevPolyfit(f(3), 8, -1, 1, 0); |
29 | 24 | % [g(4), err(4)] = ChebyshevPolyfit(f(4), 8, -1, 1, 0); |
30 | 25 |
|
31 | | -% [g(1), err(1)] = ChebyshevPolyfitIntegral(f(1), 6, 0, 1, 10); |
32 | | -% [g(2), err(2)] = ChebyshevPolyfitIntegral(f(2), 6, 0, 1, 10); |
33 | | -% [g(3), err(3)] = ChebyshevPolyfitIntegral(f(3), 8, -1, 1, 10); |
34 | | -% [g(4), err(4)] = ChebyshevPolyfitIntegral(f(4), 8, -1, 1, 10); |
| 26 | +% Calculate using integrals. |
| 27 | +% [g(1), err(1)] = ChebyshevPolyfitIntegral(f(1), 6, 0, 1, 15); |
| 28 | +% [g(2), err(2)] = ChebyshevPolyfitIntegral(f(2), 6, 0, 1, 15); |
| 29 | +% [g(3), err(3)] = ChebyshevPolyfitIntegral(f(3), 8, -1, 1, 15); |
| 30 | +% [g(4), err(4)] = ChebyshevPolyfitIntegral(f(4), 8, -1, 1, 15); |
35 | 31 |
|
36 | | -digits(15); |
| 32 | +digits(25); |
37 | 33 | g = vpa(g); |
38 | 34 | err = double(err); |
39 | 35 | disp(g); |
|
0 commit comments