%% Gaussian Quadrature
% This Graphical User Interface (GUI) illustrates some features of various
% quadrature rules for evaluating 
%
% $$\int_a^b w(x) f(x)~\mathrm{d}x \approx \sum_{i=1}^n w_i f(x_i)$$
%
% *Reminder*
%
% * $w(x)$ is the (rule-dependent) _weight function_
% * $w_i$ are the _quadrature weights_
% * $x_i$ are the _quadrature nodes_
%


%% Introduction
% After saving all of the MATLAB code downloadable below, running
% gauss_quad_gui_run.m produces the following window:

gauss_quad_gui

%% Using the GUI
% The various elements of the GUI are as follows
%
% *Plot of integrand w(x)f(x)* (upper left)
%
% This is a plot of $w(x)$ times the
% given function $f(x)$, over the relevant (rule-dependent) interval.
%
% The function f may be specified below the plot, either by using the text
% box or by selecting any of the preset functions.
%
% *NB*: in MATLAB's notation, the multiplication (|*|), division (|/|), and
% exponentiation (|^|) operators MUST be preceded by a dot (.) e.g.
% $2x$ is |2.*x| in MATLAB's notation.
%
% *Quadrature Value vs. Node Count* (upper right)
%
% This shows successive approximations with a varying number of
% nodes, specifed just below the plot. This allows visualisation of how
% (and indeed whether) the approximants converge.
%
% *Quadrature Weights at Nodes* (lower left)
%
% This shows the _quadrature weights_ $w_i$ plotted as vertical stems at
% the _quadrature nodes_ $x_i$. The number $n$ of nodes/weights can be
% controlled with the box at the lower right part of the window.
%
% *Quadrature Type* (lower right)
%
% This selects the quadrature rule. The options are summarised in the table
% below. See also the lectures on Gaussian quadrature.
%
% <html>
% <table border=1>
% <tr>
%   <td>Name</td>
%   <td>Weight Function</td>
%   <td>Interval</td>
%   <td>Nodes</td>
% <tr>
%   <td>Closed Newton-Cotes</td>
%   <td>1</td>
%   <td>[-1,1]</td>
%   <td>Equally spaced, including endpoints</td>
% </tr>
% <tr>
%   <td>Open Newton-Cotes</td>
%   <td>1</td>
%   <td>[-1,1]</td>
%   <td>Equally spaced, excluding endpoints</td>
% </tr>
% <tr>
%   <td>Legendre</td>
%   <td>1</td>
%   <td>[-1,1]</td>
%   <td>Roots of n-th degree Legendre polynomial</td>
% </tr>
% <tr>
%   <td>Chebyshev</td>
%   <td>1/sqrt(1-x^2)</td>
%   <td>[-1,1]</td>
%   <td>Roots of n-th degree Chebyshev polynomial</td>
% </tr>
% <tr>
%   <td>Laguerre</td>
%   <td>exp(-x)</td>
%   <td>[0,infinity]</td>
%   <td>Roots of n-th degree Laguerre polynomial</td>
% </tr>
% <tr>
%   <td>Hermite</td>
%   <td>exp(-x^2)</td>
%   <td>[-infinity,infinity]</td>
%   <td>Roots of n-th degree Hermite polynomial</td>
% </tr>
% </table>
% </html>

%% MATLAB Code
%
% * <gauss_quad_gui.m> (GUI Code)
% * <gauss_quad_gui.fig> (Required - GUI Figure)
%
% All files as .zip archive: <gaussian_quadrature_all.zip>