Using Numerical Recipes

This shows how to write programs that call Numerical Recipres functions, how to compile and link these programs. The Numerical Recipes Library libnrecc.a is located in the directory /usr/local/nrcp/  .   All the header files are also in this directory. The source code is available in the directory /usr/local/nrcp/C/ansi-c/ .

The program nrcp_test.cintegrates two functions f(x)=1   and g(x)=x  from  the limits 0 to 1.  It uses the function qsimp to do the integration.

To compile the program

cc -c nrcp_test.c -I/usr/local/nrcp/

To link

cc -o  nrcp_test  nrcp_test.o  -L/usr/local/nrcp/ -lnrecc -lm

To run

./nrcp_test

Sample program (prog.c) for solving a set of orinary differential equations (ODEs) using the Numerical Recipes function odeint(). This program evolves  the position and momentum of a simple harmonic oscillalor which starts from rest at x=1.