Skip to content

BCs with few knots incorrect #55

@asparc

Description

@asparc

Hi!

Thanks for making this very useful tool. It's very easy to use. However, I think I stumbled upon some unexpected behaviour.

I wanted to make a spline with boundary conditions on the second derivative. So I expect the spline to evaluate to zero at both boundaries, like so:

julia> B1 = RecombinedBSplineBasis(Derivative(2), BSplineBasis(4, [0,0.25,0.5,0.75,1]));
julia> C1 = collocation_matrix(B1, [0,1], Derivative(2), Matrix{Float64});
julia> coefs1 = [1,1,1,1,1];
julia> println("2nd derivative at boundaries: ", C1*coefs1)
2nd derivative at boundaries: [-1.4210854715202004e-14, -1.4210854715202004e-14]  

So far, this is expected behaviour. However, when I reduce the number of knots from 5 to 3, which should still be valid, I get non-zero values for the second derivative at the right boundary:

julia> B2 = RecombinedBSplineBasis(Derivative(2), BSplineBasis(4, [0,0.5,1]));
julia> C2 = collocation_matrix(B2, [0,1], Derivative(2), Matrix{Float64});
julia> coefs2 = [1,1,1];
julia> println("2nd derivative at boundaries: ", C2*coefs2)
2nd derivative at boundaries: [-3.552713678800501e-15, 17.999999999999996]

Could this be a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions