Skip to content

Commit 9b87a59

Browse files
committed
Clean up code
1 parent 3e2f29b commit 9b87a59

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

ChebyshevDemo.m

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,25 @@
1111
f(3) = sin(x)/x;
1212
f(4) = cos(x);
1313

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.
2115
[g(1), err(1)] = ChebyshevPolyfit(f(1), 6, 0, 1, 0.3762);
2216
[g(2), err(2)] = ChebyshevPolyfit(f(2), 6, 0, 1, 0.1113);
2317
[g(3), err(3)] = ChebyshevPolyfit(f(3), 8, -1, 1, 0);
2418
[g(4), err(4)] = ChebyshevPolyfit(f(4), 8, -1, 1, 0);
2519

20+
% Expand Taylor series around the central point.
2621
% [g(1), err(1)] = ChebyshevPolyfit(f(1), 6, 0, 1, 0);
2722
% [g(2), err(2)] = ChebyshevPolyfit(f(2), 6, 0, 1, 0);
2823
% [g(3), err(3)] = ChebyshevPolyfit(f(3), 8, -1, 1, 0);
2924
% [g(4), err(4)] = ChebyshevPolyfit(f(4), 8, -1, 1, 0);
3025

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);
3531

36-
digits(15);
32+
digits(25);
3733
g = vpa(g);
3834
err = double(err);
3935
disp(g);

0 commit comments

Comments
 (0)