C Numerical Library
™
User's Guide
VOLUME 1 of 4: C Math Library
™
[CHAPTERS 1-7]
VERSION 5.5
Visual Numerics, Inc.
Corporate Headquarters
2500 Wilcrest Drive, Ste 200
Houston, Texas 77042-2759
USA
PHONE: 713-784-3131
FAX: 713-781-9260
e-mail: info@vni.com
Visual Numerics
International Ltd.
Centennial Court
Suite 1, North Wing
Easthampstead Road
BRACKNELL BERSHIRE
RG12 1YQ
United Kingdom
PHONE: +44-1-344-45-8700
FAX: +44-1-344-45-8748
e-mail: info@vniuk.co.uk
Visual Numerics SARL
Tour Europe
33 Place des Corolles Cedex
F-92049 Paris La Defense
France
PHONE: +33-1-46-93-94-20
FAX: +33-1-46-93-94-39
e-mail: info@vni.paris.fr
Visual Numerics S. A. de C.V.
Florencia 57 Piso 10-01
Col. Juarez
Mexico D. F. C. P. 06000
Mexico
PHONE: +52-5514-9730 or 9628
FAX: +52-5514-5880
Visual Numerics International GmbH
Zettachring 10
D-70567 Stuttgart
Germany
PHONE: +49-711-13287-0
FAX: +49-711-13287-99
e-mail: vni@visual-numerics.de
Visual Numerics Japan, Inc
GOBANCHO HIKARI Building 4
th
Floor
14 Goban-cho ChIiyoda-KU
Tokyo, 113
JAPAN
PHONE: +81-3-5211-7760
FAX: +81-3-5211-7769
e-mail: vnijapan@vnij.co.jp
Visual Numerics, Inc.
7/F, #510, Chung Hsiao E. Road
Section 5
Taipei, TAIWAN 110
Republic of China
PHONE: (886) 2-727-2255
FAX: (886) 2-727-6798
e-mail: info@vni.com.tw
World Wide Web site: http://www.vni.com
Visual Numerics Korea, Inc.
HANSHIN BLDG. Room 801
136-Mapo-Dong, Mapo-gu
Seoul 121-050
Korea
PHONE:+82-2-3273-2632 or 2633
FAX: +82-2-3273-2634
e-mail: info@vni.co.kr
COPYRIGHT NOTICE: Copyright 1990-2003, an unpublished work by Visual Numerics, Inc. All rights reserved.
VISUAL NUMERICS, INC., MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. Visual Numerics, Inc., shall not be liable for errors contained herein or for incidental, consequential, or other indirect
damages in connection with the furnishing, performance, or use of this material.
TRADEMARK NOTICE: IMSL, Visual Numerics, IMSL FORTRAN Numerical Libraries, IMSL Productivity Toolkit, IMSL
Libraries Environment and Installation Assurance Test, C Productivity Tools, FORTRAN Productivity Tools, IMSL C/Math/Library,
IMSL C/Stat/Library, IMSL Fortran 90 MP Library, and IMSL Exponent Graphics are registered trademarks or trademarks of Visual
Numerics, Inc., in the U.S. and other countries. Sun, SunOS, and Solaris are registered trademarks or trademarks of Sun Microsystems,
Inc. SPARC and SPARCompiler are registered trademarks or trademarks of SPARC International, Inc. Silicon Graphics is a registerd
trademark of Silicon Graphics, Inc. IBM, AIX, and RS/6000 are registered trademarks or trademarks of International Business
Machines Corporation. HP is a trademark of Hewlett-Packard. Silicon Graphics and IRIX are registered trademarks or trademarks of
Silicon Graphics, Inc. DEC and AXP are registered trademarks or trademarks of Digital Equipment Corporation. All other trademarks
are the property of their respective owners.
Use of this document is governed by a Visual Numerics Software License Agreement. This document contains confidential and
proprietary information constituting valuable trade secrets. No part of this document may be reproduced or transmitted in any form
without the prior written consent of Visual Numerics.
RESTRICTED RIGHTS LEGEND: This documentation is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by
the U.S. Government is subject to the restrictions set forth in subparagraph (c)(1)(ll) of the Rights in Technical Data and Computer
Software clause at DFAR 252.227-7013, and in subparagraphs (a) through (d) of the Commercial Computer Software - Restricted
Rights clause at FAR 52.227-19, and in similar clauses in the NASA FAR Supplement, when applicable. Contractor/Manufacturer is
Visual Numerics, Inc., 2500 Wilcrest Drive, Ste 200, Houston, Texas 77042.
IMSL
Fortran and C and Java
Application Development Tools
IMSL C/Math/Library Table of Contents · i
CMath Library /V1- Table of
Contents
Introduction ix
Chapter 1: Linear Systems 1
Chapter 2: Eigensystem Analysis 115
Chapter 3: Interpolation and Approximation 139
Chapter 4: Quadrature 235
Chapter 5: Differential Equations 289
Chapter 6: Transforms 339
Chapter 7: Nonlinear Equations 383
Appendix A: References A-1
Appendix B: Alphabetical Summary of Routines B-1
Index i
Introduction
IMSL C/Math/Library
The IMSL C/Math/Library is a library of C functions useful in scientific
programming. Each function is designed and documented to be used in research
activities as well as by technical specialists. A number of the example programs
also show graphs of resulting output.
Getting Started
To use any of the IMSL C/Math/Library functions, you first must write a program
in C to call the function. Each function conforms to established conventions in
programming and documentation. We give first priority in development to
efficient algorithms, clear documentation, and accurate results. The uniform
design of the functions makes it easy to use more than one function in a given
application. Also, you will find that the design consistency enables you to apply
your experience with one IMSL C/Math/Library function to all other IMSL
functions that you use.
ANSI C vs. Non-ANSI C
All of the examples in this user’s manual conform to ANSI C. If you are not using
ANSI C, you will need to modify your examples in which functions are declared
or in which arrays are initialized as the type float.
The following is an ANSI C program in which a function is declared. The
program estimates the value of the following:
()
1
1/ 2
0
ln 4xx dx
-
=-
ò
1 #include <math.h>
2 #include <imsl.h>
3
4 float fcn(float x);
5
6 main()
7 {
Introduction IMSL C/Math/Library · ix
x · Getting Started IMSL C/Math/ Library
8 float q, exact;
9 /* evaluate the integral */
10 q = imsl_f_int_fcn_sing (fcn, 0.0, 1.0, 0);
11 /* print the result and the exact answer */
12 exact = -4.0;
13 printf("integral = %10.3f\nexact = %10.3f\n", q, exact);
14 }
15
16 float fcn(float x)
17 {
18 return log(x)/sqrt(x);
19 }
If using non-ANSI C, you would need to modify lines 4 and 16 as follows:
4 float fcn(); /* function is not prototyped */
.
.
.
16 float fcn(x) /*Only variable of function defined here */
16a float x; /* Type of variable declared here */
Non-ANSI C does not allow for automatic aggregate initialization, and thus, all
auto arrays that are initialized as type float in ANSI C must be initialized as type
static float in non-ANSI C. The next program contains arrays that are initialized
as type float.
1 #include <imsl.h>
2
3 main()
4 {
5 int n = 3;
6 float *x;
7 float a[] = {1.0, 3.0, 3.0,
8 1.0, 3.0, 4.0,
9 1.0, 4.0, 3.0};
10
11 float b[] = {1.0, 4.0, -1.0};
12 /* Solve Ax = b for x */
13 x = imsl_f_lin_sol_gen (n, a, b, 0);
14 /* Print x */
15 imsl_f_write_matrix ("Solution, x, of Ax = b", 1, 3, x, 0);
16 }
If using non-ANSI C, you would need to modify lines 7 and 11 as follows:
7 static float a[] = {1.0, 3.0, 3.0,
.
.
.
11 static float b[] = {1.0, 4.0, -1.0};
The imsl.h File
The include file <imsl.h> is used in all of the examples in this manual. This file
contains prototypes for all IMSL-defined functions; the spline structures,
Imsl_f_ppoly, Imsl_d_ppoly, Imsl_f_spline, and Imsl_d_spline; enumerated data