Richer or Broker

> restart;


We want to look at the differences in prices of a stock from day to day.

> FwdDiff := proc(Y) local k; [seq(Y[k]-Y[k-1], k=2..nops(Y))] end:#Define the FwdDiff function.

> DiffTable := proc(X,Y) local k, fd, sd;
fd := FwdDiff(Y);
sd := FwdDiff(fd);
linalg[transpose](convert([X,Y,[op(fd), "-"],[op(sd),"-","-"]],array));
end:# Define the DiffTable function

> a := [58.33, 59.04, 61.10, 62.27, 61.62, 59.26,
58.31, 57.92, 57.86, 58.00, 59.11, 62.33,
67.84, 68.55, 69.96, 71.37, 71.96, 72.15];

[Maple Math]

> pts := [seq([k-1, a[k]],k=1..nops(a))]:
plot(pts,style=point);

[Maple Plot]

> DiffTable([seq(k-1,k=1..nops(a))],a);

[Maple Math]

> P1 := plot(pts,style=point):
fd := FwdDiff(a);
pts := [seq([k-1,fd[k]],k=1..nops(fd))]:
P2 := plot(pts, style=point, symbol=box, color=blue):
plots[display](P1,P2);

[Maple Math]

[Maple Plot]

> sd := FwdDiff(fd);
pts := [seq([k-1,sd[k]],k=1..nops(sd))]:
P3 := plot(pts, style=point, symbol=circle, color=green):
plots[display](P2,P3);

[Maple Math]

[Maple Plot]

> pts := [seq([k-1, a[k]],k=1..nops(a))]:
plot(pts,style=point, view=[4..11,57..65]);

[Maple Plot]

> b := [seq(100-a[k],k=1..nops(a))];
pts := [seq([k-1, b[k]],k=1..nops(b))]:
plot(pts,style=point, view=[4..11,35..43]);

[Maple Math]

[Maple Plot]

>