# Gaussian Quadrature

This Graphical User Interface (GUI) illustrates some features of various quadrature rules for evaluating

**Reminder**

- is the (rule-dependent)
*weight function* - are the
*quadrature weights* - are the
*quadrature nodes*

## Contents

## 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 times the given function , 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. 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* plotted as vertical stems at the *quadrature nodes* . The number 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.

Name | Weight Function | Interval | Nodes |

Closed Newton-Cotes | 1 | [-1,1] | Equally spaced, including endpoints |

Open Newton-Cotes | 1 | [-1,1] | Equally spaced, excluding endpoints |

Legendre | 1 | [-1,1] | Roots of n-th degree Legendre polynomial |

Chebyshev | 1/sqrt(1-x^2) | [-1,1] | Roots of n-th degree Chebyshev polynomial |

Laguerre | exp(-x) | [0,infinity] | Roots of n-th degree Laguerre polynomial |

Hermite | exp(-x^2) | [-infinity,infinity] | Roots of n-th degree Hermite polynomial |

## MATLAB Code

- gauss_quad_gui.m (GUI Code)
- gauss_quad_gui.fig (Required - GUI Figure)

All files as .zip archive: gaussian_quadrature_all.zip