# GNU Scientific Library (GSL)

GSL is the go-to library for programs involving deep mathematical expressions.

## We'll cover the following

The GNU Scientific Library provides a broad range of numerical and mathematical functions. If you want to do something in C that you have been doing in MATLAB, or Python/NumPy/SciPy, or R, then probably you will need to look at something like GSL for functions you need (or code them up yourself).

There is a list of main categories here. Things you might be interested are:

- Vectors and Matrices
- Linear Algebra
- FFTs
- Random Number Generation & Random Number Distributions
- Statistics
- ODEs
- Interpolation
- Numerical Differentiation
- Least-Squares Fitting
- Nonlinear Least-Squares Fitting
- Multidimensional Minimization

## Linking to GSL

Of course before you can link to the gsl library, you have to make sure it is installed on your computer. See the gsl documentation for how to install it.

To link your code to the gsl you will have to do two things. First you will have to use the `#include`

directive to include the relevant header files. In the gsl documentation for each function, it tells you which header file(s) you will need. Second, you will have to use a flag when compiling to tell the compiler to include the library files themselves. Here is an example program from the gsl documentation that uses linear algebra routines to solve a linear system *A__x* = *b*:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy