23.2 Orthogonal Collocation
- : [r, amat, bmat, q] = colloc (n, "left", "right")
-
Compute derivative and integral weight matrices for orthogonal collocation.
Reference: J. Villadsen, M. L. Michelsen, Solution of Differential Equation Models by Polynomial Approximation.
Here is an example of using colloc
to generate weight matrices for solving the second order differential equation u’ - alpha * u” = 0 with the boundary conditions u(0) = 0 and u(1) = 1.
First, we can generate the weight matrices for n points (including the endpoints of the interval), and incorporate the boundary conditions in the right hand side (for a specific value of alpha).
n = 7; alpha = 0.1; [r, a, b] = colloc (n-2, "left", "right"); at = a(2:n-1,2:n-1); bt = b(2:n-1,2:n-1); rhs = alpha * b(2:n-1,n) - a(2:n-1,n);
Then the solution at the roots r is
u = [ 0; (at - alpha * bt) \ rhs; 1] ⇒ [ 0.00; 0.004; 0.01 0.00; 0.12; 0.62; 1.00 ]
© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v6.3.0/Orthogonal-Collocation.html