# Derivative of B-spline

The derivative of B-spline basis function can be expressed as follows:

\[\begin{aligned} \dot{B}_{(i,p,k)}(t) &=\frac{d}{dt}B_{(i,p,k)}(t) \\ &=p\left(\frac{1}{k_{i+p}-k_{i}}B_{(i,p-1,k)}(t)-\frac{1}{k_{i+p+1}-k_{i+1}}B_{(i+1,p-1,k)}(t)\right) \end{aligned}\]

Note that $\dot{B}_{(i,p,k)}\in\mathcal{P}[p-1,k]$.

```
k = KnotVector([0.0, 1.5, 2.5, 5.5, 8.0, 9.0, 9.5, 10.0])
P = BSplineSpace{3}(k)
plot(
plot(BSplineDerivativeSpace{0}(P), label="0th derivative", color=:black),
plot(BSplineDerivativeSpace{1}(P), label="1st derivative", color=:red),
plot(BSplineDerivativeSpace{2}(P), label="2nd derivative", color=:green),
plot(BSplineDerivativeSpace{3}(P), label="3rd derivative", color=:blue),
)
```

`"/home/runner/work/BasicBSpline.jl/BasicBSpline.jl/docs/build/bsplinebasisderivativeplot.html"`

`BasicBSpline.BSplineDerivativeSpace`

— Type`BSplineDerivativeSpace{r}(P::AbstractBSplineSpace)`

Construct derivative of B-spline space from given differential order and B-spline space.

\[D^{r}(\mathcal{P}[p,k]) =\left\{t \mapsto \left. \frac{d^r f}{dt^r}(t) \ \right| \ f \in \mathcal{P}[p,k] \right\}\]

**Examples**

```
julia> P = BSplineSpace{2}(KnotVector([1,2,3,4,5,6]))
BSplineSpace{2, Int64}(KnotVector([1, 2, 3, 4, 5, 6]))
julia> dP = BSplineDerivativeSpace{1}(P)
BSplineDerivativeSpace{1, BSplineSpace{2, Int64}, Int64}(BSplineSpace{2, Int64}(KnotVector([1, 2, 3, 4, 5, 6])))
julia> degree(P), degree(dP)
(2, 1)
julia> P = UniformBSplineSpace{2}(UniformKnotVector(1:6))
UniformBSplineSpace{2, Int64, UnitRange{Int64}}(UniformKnotVector(1:6))
julia> dP = BSplineDerivativeSpace{2}(P)
BSplineDerivativeSpace{2, UniformBSplineSpace{2, Int64, UnitRange{Int64}}, Int64}(UniformBSplineSpace{2, Int64, UnitRange{Int64}}(UniformKnotVector(1:6)))
julia> degree(P), degree(dP)
(2, 0)
```

`BasicBSpline.derivative`

— Function```
derivative(::BSplineDerivativeSpace{r}) -> BSplineDerivativeSpace{r+1}
derivative(::AbstractBSplineSpace) -> BSplineDerivativeSpace{1}
```

Derivative of B-spline related space.

**Examples**

```
julia> BSplineSpace{2}(KnotVector(0:5))
BSplineSpace{2, Int64}(KnotVector([0, 1, 2, 3, 4, 5]))
julia> BasicBSpline.derivative(ans)
BSplineDerivativeSpace{1, BSplineSpace{2, Int64}, Int64}(BSplineSpace{2, Int64}(KnotVector([0, 1, 2, 3, 4, 5])))
julia> BasicBSpline.derivative(ans)
BSplineDerivativeSpace{2, BSplineSpace{2, Int64}, Int64}(BSplineSpace{2, Int64}(KnotVector([0, 1, 2, 3, 4, 5])))
```

`BasicBSpline.bsplinebasis′₊₀`

— Function`bsplinebasis′₊₀(::AbstractFunctionSpace, ::Integer, ::Real) -> Real`

1st derivative of B-spline basis function. Right-sided limit version.

\[\dot{B}_{(i,p,k)}(t) =p\left(\frac{1}{k_{i+p}-k_{i}}B_{(i,p-1,k)}(t)-\frac{1}{k_{i+p+1}-k_{i+1}}B_{(i+1,p-1,k)}(t)\right)\]

`bsplinebasis′₊₀(P, i, t)`

is equivalent to `bsplinebasis₊₀(derivative(P), i, t)`

.

`BasicBSpline.bsplinebasis′₋₀`

— Function`bsplinebasis′₋₀(::AbstractFunctionSpace, ::Integer, ::Real) -> Real`

1st derivative of B-spline basis function. Left-sided limit version.

\[\dot{B}_{(i,p,k)}(t) =p\left(\frac{1}{k_{i+p}-k_{i}}B_{(i,p-1,k)}(t)-\frac{1}{k_{i+p+1}-k_{i+1}}B_{(i+1,p-1,k)}(t)\right)\]

`bsplinebasis′₋₀(P, i, t)`

is equivalent to `bsplinebasis₋₀(derivative(P), i, t)`

.

`BasicBSpline.bsplinebasis′`

— Function`bsplinebasis′(::AbstractFunctionSpace, ::Integer, ::Real) -> Real`

1st derivative of B-spline basis function. Modified version.

\[\dot{B}_{(i,p,k)}(t) =p\left(\frac{1}{k_{i+p}-k_{i}}B_{(i,p-1,k)}(t)-\frac{1}{k_{i+p+1}-k_{i+1}}B_{(i+1,p-1,k)}(t)\right)\]

`bsplinebasis′(P, i, t)`

is equivalent to `bsplinebasis(derivative(P), i, t)`

.