1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
<html lang="en">
<head>
<title>Orthogonal Collocation - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Numerical-Integration.html#Numerical-Integration" title="Numerical Integration">
<link rel="prev" href="Functions-of-Multiple-Variables.html#Functions-of-Multiple-Variables" title="Functions of Multiple Variables">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Orthogonal-Collocation"></a>
Previous: <a rel="previous" accesskey="p" href="Functions-of-Multiple-Variables.html#Functions-of-Multiple-Variables">Functions of Multiple Variables</a>,
Up: <a rel="up" accesskey="u" href="Numerical-Integration.html#Numerical-Integration">Numerical Integration</a>
<hr>
</div>
<h3 class="section">22.2 Orthogonal Collocation</h3>
<!-- ./DLD-FUNCTIONS/colloc.cc -->
<p><a name="doc_002dcolloc"></a>
<div class="defun">
— Loadable Function: [<var>r</var>, <var>amat</var>, <var>bmat</var>, <var>q</var>] = <b>colloc</b> (<var>n, "left", "right"</var>)<var><a name="index-colloc-1780"></a></var><br>
<blockquote><p>Compute derivative and integral weight matrices for orthogonal
collocation using the subroutines given in J. Villadsen and
M. L. Michelsen, <cite>Solution of Differential Equation Models by
Polynomial Approximation</cite>.
</p></blockquote></div>
<p>Here is an example of using <code>colloc</code> to generate weight matrices
for solving the second order differential equation
<var>u</var>' - <var>alpha</var> * <var>u</var>” = 0 with the boundary conditions
<var>u</var>(0) = 0 and <var>u</var>(1) = 1.
<p>First, we can generate the weight matrices for <var>n</var> points (including
the endpoints of the interval), and incorporate the boundary conditions
in the right hand side (for a specific value of
<var>alpha</var>).
<pre class="example"> 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);
</pre>
<p>Then the solution at the roots <var>r</var> is
<pre class="example"> u = [ 0; (at - alpha * bt) \ rhs; 1]
[ 0.00; 0.004; 0.01 0.00; 0.12; 0.62; 1.00 ]
</pre>
</body></html>
|