collocation, a MATLAB code which exemplifies the collocation method, a general technique which begins with an equation satisfied by a function f(x) defined over a continuous domain, and uses collocation to produce a function g(x) from some specified collocation function space, which solves the equation exactly, but only at a discrete set of points.
While some functional equations can be solved exactly, a computational technique must generally be designed to deal with a discrete set of data. The hope is that, if the correct family of collocation spaces is chosen, and enough points are used, and are wisely placed, that the collocation function g(x) will converge to the unknown function f(x), and will do so rapidly.
The most common example of collocation is interpolation, which comes in two versions:
A more involved case involves two point boundary value problems. Here, a function y(x) is supposed to exist over an interval [a,b], with known values at the endpoints, satisfying a second order differential equation in between, which might have the form:
y(a) = ya y''(x) = f(x) for a < x < b y(b) = ybA collocation approach would select N points between A and B, represent the collocation function G(X) in some way that involves N unknown coefficients, and then write out the collocation equations as a linear system that can be solved for the coefficients.
For instance, if we take the interval to be [0,4], F(X) to be EXP(X), and use N = 5 points, equally spaced, and assume G(X) has the form C0+C1*X+C2*X^2+C3*X^3+C4*X^4, our collocation equations become:
C0 + C1 * 0 + C2 * 0^2 + C3 * 0^3 + C4 * 0^4 = YA 2 * C2 + 6 * C3 * 1^1 + 12 * C4 * 1^2 = EXP(1) 2 * C2 + 6 * C3 * 2^1 + 12 * C4 * 2^2 = EXP(2) 2 * C2 + 6 * C3 * 3^1 + 12 * C4 * 3^2 = EXP(3) C0 + C1 * 4 + C2 * 4^2 + C3 * 4^3 + C4 * 4^4 = Ybwhich can be rewritten as:
| 1 0 0 0 0 | C0 YA | 0 0 2 6 12 | C1 EXP(1) | 0 0 2 12 48 | * C2 = EXP(2) | 0 0 2 18 108 | C3 EXP(3) | 1 4 16 64 256 | C4 YBand this linear system can be solved for C, so that we know the form of our collocation function G(X).
The computer code and data files described and made available on this web page are distributed under the MIT license
collocation is available in a MATLAB version.
lagrange_interp_1d, a MATLAB code which defines and evaluates the Lagrange polynomial p(x) which interpolates a set of data, so that p(x(i)) = y(i).