Lagrange Interpolation example from the Numerical Recipes Book

  • See the course page for links to the Book and the software.
  • Read about Lagrange Interpolation in Numerical Recipes Chapter 3.1
    (actually they use the related Neville's Algorithm.
  • In a unix shell, in a unique folder dedicated to only this example, do the following :
    • Place in this folder the Neville's Algorithm software which is called polint.c.
    • You also need the include files nr.h and nrutil.h as well as nrutil.c.
    • Take the examaple driver routine xpolint.c also from the Numerical Recipes site.
    • Also download the generic Makefile. You only need to edit theoutput file name ... if you wish.
    • Browse all of these files.
    • Now make the executable
    • Run it
    • Check you agree that the output is what was expected from the code
    • Edit xpolint.c to swap the functions that are to be interpolated with your own choices, make again.
    • You should rename xpolint.c to xpolint.cpp to cause the compiler to use cpp as the base language.

There you go .... you implemented a development cycle involving several sources and made some of your own modifications ... !

Note ... if you are using the software for the c-code in a c++ compile environment, then wrap the c-code in the headers nr.h and nrutil.h in this code segment

 #ifdef __cplusplus
 extern "C" {

.... the c-code is here ....

 #ifdef __cplusplus
 } //extern "C"