You can simply take the derivative, but note you are differentiating w/ respect to the parameter:
pts = {{1, 1}, {2, 3}, {3, -1}, {4, 1}, {5, 0}};
f = BSplineFunction[pts];
g[t_] = D[f[t], t] (* g is a new BSplineFunction *)
use chain rule to get dydx
:
dydx[t_?NumericQ] := #[[2]]/#[[1]] &@g[t];
tangents = Table[{f[t], f[t] + .2 {1, dydx[t]}}, {t, 0, 1, .1}];
ParametricPlot[f[t], {t, 0, 1} ,
Epilog -> Arrow /@ tangents, AspectRatio -> 1]
obtaining the extrema..
ext = Table[ t /. FindRoot[dydx[t], {t, s}] , {s, {.2, .5, .9}}];
(* or use FindRoot[ g[t][[2]] , {t, .. }] *)
Show[Graphics[{ BSplineCurve[pts] , Arrow /@ tangents , Red,
PointSize[.02], Point[f /@ ext ] , Blue , Point /@ pts} ], Frame -> True]
note that a bspline doesn't pass through its control points (in blue) so this is not a good way to approximate data.
( note this works fine w/ SplineDegree->5
, but you need at least 6 points. )
BSplineFunction
that would be interesting to see. $\endgroup$Interpolation[]
instead? $\endgroup$