08-02-12.mw

> with(CurveFitting);
 

[BSpline, BSplineCurve, Interactive, LeastSquares, PolynomialInterpolation, RationalInterpolation, Spline, ThieleInterpolation]
[BSpline, BSplineCurve, Interactive, LeastSquares, PolynomialInterpolation, RationalInterpolation, Spline, ThieleInterpolation]
(1)
 

> with(plots):
 

> seq( [x, x/2], x=0..4);
 

[0, 0], [1, `/`(1, 2)], [2, 1], [3, `/`(3, 2)], [4, 2] (2)
 

> stuff:=[ seq( [x, x/2], x=0..4), [5,3], seq( [x, x/2], x=6..10)] ;
 

[[0, 0], [1, `/`(1, 2)], [2, 1], [3, `/`(3, 2)], [4, 2], [5, 3], [6, 3], [7, `/`(7, 2)], [8, 4], [9, `/`(9, 2)], [10, 5]] (3)
 

> plot(stuff, x=0..10, style=point,symbolsize=18, scaling=constrained);
 

Plot_2d
 

> polly:=PolynomialInterpolation(stuff, x);
 

`+`(`-`(`*`(`/`(1, 28800), `*`(`^`(x, 10)))), `*`(`/`(1, 576), `*`(`^`(x, 9))), `-`(`*`(`/`(107, 2880), `*`(`^`(x, 8)))), `*`(`/`(4, 9), `*`(`^`(x, 7))), `-`(`*`(`/`(93773, 28800), `*`(`^`(x, 6)))), `...
`+`(`-`(`*`(`/`(1, 28800), `*`(`^`(x, 10)))), `*`(`/`(1, 576), `*`(`^`(x, 9))), `-`(`*`(`/`(107, 2880), `*`(`^`(x, 8)))), `*`(`/`(4, 9), `*`(`^`(x, 7))), `-`(`*`(`/`(93773, 28800), `*`(`^`(x, 6)))), `...
(4)
 

> display(
 plot(stuff, x=0..10, style=point,symbolsize=18, scaling=constrained),
 plot(polly, x=0..10, color=blue));
 

Plot_2d
 

> ?piecewise
 

> cracker:=piecewise( 4<x and x<5, x-2,  5 <= x and x < 6, 3, x/2);
 

`:=`(cracker, PIECEWISE(`?`, `?`, `?`)) (5)
 

> display(
 plot(stuff, x=0..10, style=point,symbolsize=18, scaling=constrained),
 plot(polly, x=0..10, color=yellow),
 plot(cracker, x=0..10, color=black));
 

Plot_2d
 

> pirate:=Spline(stuff, x, degree=1);
 

`:=`(pirate, PIECEWISE(`?`, `?`, `?`, `?`, `?`, `?`, `?`, `?`, `?`, `?`)) (6)
 

> plot([cracker, pirate],x=0..10);
 

Plot_2d
 

> swashbuckler:=Spline(stuff, x);
 

`:=`(swashbuckler, PIECEWISE(`?`, `?`, `?`, `?`, `?`, `?`, `?`, `?`, `?`, `?`)) (7)
 

> plot([cracker,swashbuckler],x=0..10,color=[red,blue]);
 

Plot_2d
 

> display( [seq(
         plot(Spline( stuff, x, degree=i), x=-1..11),
        i=1..5)]);
 

Plot_2d
 

> plot( [seq(Spline( stuff, x, degree=i), i=1..10)], x=-1..11,thickness=2);
 

Plot_2d
 

>
 

>