Professor of Mathematics (Emeritus)

Loyola Marymount University

Los Angeles, CA

*
*

One of the advantages of multiple-precision is that the difficulties presented by problems that

are ill-conditioned or algorithms that are unstable can often be overcome by raising precision.

If we need a result correct to 15 digits and there is a simple algorithm that loses 10 digits to

cancellation error, it may be easier to write a program to use FM and carry 30 digits, instead of

spending the time to develop a sophisticated algorithm that can get 15 digits using double precision.

William Kahan is a numerical analysis guru whose web page http://www.cs.berkeley.edu/~wkahan/

has many papers showing in grisly detail some of the terrible things that can happen to the unwary

people who design or use numerical software.

In one of Kahan's articles, "How Futile are Mindless Assessments of Roundoff in Floating-Point

Computation?", he says,

"How can you separate numerically trustworthy results from the treacherous ones?"

"Without error-analysis, you can't. And if you can't, the simplest way to evade numerical

embarrassment is to perform computation carrying extravagantly more precision throughout

than you think necessary, and pray that it is enough. Usually somewhat more than twice the

precision you trust in the data and seek in the results is enough."

FM can make it relatively painless to check numerical results by re-running them with

extravagant precision.

Some of the .chk output files contain timing results. The times may vary when you run the programs.

The routines on this page are mostly brute force solutions and not state-of-the-art methods.

They all use the basic FM package, and should be compiled and linked in a similar way to the

other Fortran sample programs discussed in the FM user manual.

The actual routines shown on this page are in this archive that contains all the FM files from this

website: FM_files.zip

FM_Sample_Routines.f95
is a file that collects all the subroutines on this page into one file.

This is usually more convenient when using these routines, since only one object file is needed

when building programs that use them.

See the top of the file for a list of the routines.

The individual file pointers here display as pdf files for browsing. The longer files are cut

off after 20 pages.

** Using FM for Special Functions **

Some programs don't need multiple precision, but do need mathematical special functions

that are not part of the Fortran standard. In this case it is easy to set FM's precision level

to give full double precision accuracy and then use FM's version of these functions.

SampleDPfunctions.f95
is a small program with several examples using FM for non-Fortran

functions such as binomial coefficients, log integral, psi, polygamma, and incomplete gamma.

SampleDPfunctions.chk
is the expected output from the program. Note that the first example

checks Fortran's built-in gamma function against FM. At the time this routine was created,

some Fortran compilers did not give correctly rounded results for all valid input arguments

to gamma, so your output might differ from this file in the first sample case.

** Function Minimization or Maximization **

fminFMv2.f95 is a program that uses FM_FIND_MIN, a multiple-precision max/min subroutine.

fminFMv2.chk is the output from the fminFMv2 program.

** Integrals **

SampleFMintegrate.f95 is a sample program using FM_INTEGRATE.

SampleFMintegrate.chk is the output from the SampleFMintegrate program.

OscillateFM.f95 is a program that uses FM_INTEGRATE to integrate sin(1/x) from 0 to 1.

OscillateFM.chk is the output from the OscillateFM program.

** Ordinary Differential Equations **

DiffEqFM.f95 is a sample program using FM_RK14.

DiffEqFM.chk is the output from the DiffEqFM program.

** Real Roots **

RootsFM.f95 is a sample program using routines FM_SECANT and FM_FPRIME.

RootsFM.chk is the output from the RootsFM program.

** Real Linear Systems **

HarmonicFitFM.f95 is a sample program using routines FM_GENEQ and FM_LIN_SOLVE.

HarmonicFitFM.chk is the output from the HarmonicFitFM program.

** Complex Roots **

AllRootsZM.f95 is a sample program using routine ZM_ROOTS.

AllRootsZM.chk is the output from the AllRootsZM program.

** Complex Linear Systems and Eigenvalues **

EigenSystemFM.f95
is a sample program that tries to find the complex eigenvalues and

eigenvectors of a real matrix. It uses routines FM_LIN_SOLVE,

ZM_ROOTS, ZM_FPRIME, ZM_LIN_SOLVE, and ZM_INVERSE.

EigenSystem.chk is the screen output from the EigenSystem program.

EigenSystem.out is the file output from the EigenSystem program.

Back to the main FM page