# daepy.collocation¶

class daepy.collocation.CollocationSolution(N, degree, breakpoints, continuous=False)

Multivariate piecewise polynomial where N is the number of components, degree is the degree of the continuous components, breakpoints are the ends of the subintervals and continuous is an (N,) numpy array of booleans determining which components are continuous. If continuous is True or False then all components are set to be continuous or not respectively.

Each component is a UnivariateCollocationSolution. These can be accessed by indexing the object or via the components attribute which is a list of the UnivariateCollocationSolution components.

Note

Labelling a component as continuous does not guarantee that it will be continuous, it only means that it will be represented by poynomials one degree higher than components labelled as not continuous.

get_coeffs()

Returns the polynomial coefficients.

update_coeffs(vals)

Update the polynomial coefficients.

fit(x, data, degree=None)

Fit the polynomials to an (N,K) numpy array data at points given by (K,) numpy array x. Optionally limit the fitting to degree degree.

interpolate(fun_list)

Interpolate a list of functions.

fitting_matrix()

Return the matrix $$F$$ such that $$c = Fd$$ are the polynomial coefficients where $$d$$ is fitting data.

eval(x)

Evaluate the piecewise polynomials. This can also be achieved by simply calling the object like a function, that is sol(x) is equivalent to sol.eval(x).

eval_matrix(x)

Return the matrix $$E$$ such that $$Ec = y(x)$$ where $$c$$ are the polynomial coefficients and $$y(x)$$ is the piecewise polynomial evaluated at points x.

derivative(x)

Calculate the derivative at points x.

derivative_matrix(x=None)

Return the matrix $$D$$ such that $$Dc = y'(x)$$ where $$c$$ are the polynomial coefficients and $$y'(x)$$ is the derivative of the piecewise polynomial evaluated at points x. If x is not given then it is taken to be the collocation points and the matrix is constructed using a faster routine than for general x.

continuity_error()

Return the continuity error for continuous variables.

continuity_jacobian()

Return the jacobian of the continuity error for continuous variables.

integral()

Integrate the piecewise polynomial over the whole interval.

antiderivative(x)

Calculate the antiderivative of the piecewise polynomial at points x. The antiderivative at 0 is 0.

class daepy.collocation.UnivariateCollocationSolution(degree, breakpoints, continuous=False)
update_coeffs(coeffs)

Update the polynomial coefficients.

fit(x, data, degree=None)

Fit the polynomials to an (K,) numpy array data at points given by (K,) numpy array x. Optionally limit the fitting to degree degree.

interpolate(fun)

Interpolate a function.

fitting_matrix()

Return the matrix $$F$$ such that $$c = Fd$$ are the polynomial coefficients where $$d$$ is fitting data.

eval(x)

Evaluate the piecewise polynomials. This can also be achieved by simply calling the object like a function, that is sol(x) is equivalent to sol.eval(x).

eval_matrix(x)

Return the matrix $$E$$ such that $$Ec = y(x)$$ where $$c$$ are the polynomial coefficients and $$y(x)$$ is the piecewise polynomial evaluated at points x.

derivative(x)

Calculate the derivative at points x.

derivative_matrix(x=None)

Return the matrix $$D$$ such that $$Dc = y'(x)$$ where $$c$$ are the polynomial coefficients and $$y'(x)$$ is the derivative of the piecewise polynomial evaluated at points x. If x is not given then it is taken to be the collocation points and the matrix is constructed using a faster routine than for general x.

continuity_error()

Return the continuity error for if continuous, otherwise return None.

continuity_jacobian()

Return the jacobian of the continuity error if continuous, otherwise return an empty numpy array.

single_integral(coeffs)

Integrate a single polynomial with coefficients coeffs. To integrate the piecewise polynomial over the whole interval use integral().

integral()

Integrate the piecewise polynomial over the whole interval.

antiderivative(x)

Calculate the antiderivative of the piecewise polynomial at points x. The antiderivative at 0 is 0.

deriv()

Return the derivative as a new UnivariateCollocationSolution. If you merely want to evaluate the derivative at a set of points then it is faster to use derivative().