Python Source
-
allen_cahn_pde,
a Python code which
sets up the Allen-Cahn reaction-diffusion
partial differential equations (PDE)
du/dt = nu * uxx - u * (u^2-1) / (2*xi)
in one space dimension and time.
-
alpert_rule,
a Python code which
sets up an Alpert quadrature rule to approximate the
integrals of functions which are
regular, log(x) singular, or 1/sqrt(x) singular.
-
analemma,
a Python code which
evaluates the equation of time, a formula for the difference between
the uniform 24 hour day and the actual position of the sun,
based on a C program by Brian Tung.
-
animation_test,
a Python code which
computes a sequence of solutions to a partial differential equation,
using matplotlib(), displaying each solution to the screen without
requiring the user to hit RETURN to see the next image.
-
anishchenko_ode,
a Python code which
sets up and solves the Anishchenko ordinary differential equation
(ODE), which has chaotic behavior and an attractor.
-
annulus_distance,
a Python code which
estimates the typical distance
between a pair of points randomly selected inside a circular
annulus.
-
annulus_grid,
a Python code which
computes a grid of points
over the interior of a circular annulus.
-
annulus_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of an annulus centered at the origin.
-
annulus_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate the integral of a function
over the interior of a circular annulus in 2D.
-
annulus_rule,
a Python code which
computes a quadrature rule for estimating integrals of a function
over the interior of a circular annulus in 2D.
-
approx_bernstein,
a Python code which
approximates a function f(x) in the interval [a,b]
by constructing a Bernstein polynomial of order n.
-
arclength,
a Python code which
estimates the arclength of curves of the form (x,f(x)) or
(x(t),y(t)).
-
arenstorf_ode,
a Python code which
sets up an ordinary differential equation (ODE) which defines
a stable periodic orbit of a spacecraft around the Earth and the Moon.
-
args,
a Python code which
reports the command line arguments with which it was invoked;
-
arneodo_ode,
a Python code which
sets up and solves the Arneodo ordinary differential equation
(ODE), which has chaotic behavior and an attractor.
-
asa005,
a Python code which
evaluates the Cumulative Density Function (CDF) of the noncentral T
Probability Density Function (PDF), by BE Cooper.
This is a version of Applied Statistics Algorithm 5;
-
asa006,
a Python code which
computes the Cholesky factorization of a symmetric positive
definite (SPD) matrix, by Michael Healy.
This is a version of Applied Statistics Algorithm 6;
-
asa007,
a Python code which
computes the inverse of a symmetric positive definite (SPD) matrix,
by Michael Healy.
This is a version of Applied Statistics Algorithm 7.
-
asa032,
a Python code which
evaluates the incomplete Gamma function,
by G Bhattacharjee.
This is a version of Applied Statistics Algorithm 32.
-
asa047,
a Python code which
minimizes a scalar function of several variables
using the Nelder-Mead algorithm,
by R ONeill.
This is a version of Applied Statistics Algorithm 47.
-
asa053,
a Python code which
produces sample matrices from the Wishart distribution,
by William Smith and Ronald Hocking.
This is a version of Applied Statistics Algorithm 53.
-
asa063,
a Python code which
evaluates the incomplete Beta function,
by KL Majumder and G Bhattacharjee.
This is a version of Applied Statistics Algorithm 63.
-
asa066,
a Python code which
evaluates the Cumulative Density Function (CDF) of the normal
distribution, by David Hill.
This is a version of Applied Statistics Algorithm 66.
-
asa076,
a Python code which
evaluates the Owen T function, needed to compute the
Cumulative Density Function (CDF) of the
noncentral T distribution,
by Young and Minder.
This is a version of Applied Statistics Algorithm 76.
-
asa082,
a Python code which
computes the determinant of an orthogonal matrix;
this is a version of Applied Statistics Algorithm 82,
by J C Gower.
-
asa091,
a Python code which
evaluates the percentage points of the Chi-Squared distribution,
by Best and Roberts.
This is a version of Applied Statistics Algorithm 91.
-
asa103,
a Python code which
evaluates the digamma or psi function,
by Jose Bernardo.
This is a version of Applied Statistics Algorithm 103.
-
asa109,
a Python code which
inverts the incomplete Beta function,
by Cran, Martin and Thomas.
This is a version of Applied Statistics Algorithm 109.
-
asa111,
a Python code which
evaluates the percentage points of the normal distribution,
by Beasley and Springer.
This is a version of Applied Statistics Algorithm 111.
-
asa121,
a Python code which
evaluates the trigamma function,
by BE Schneider.
This is a version of Applied Statistics Algorithm 121.
-
asa147,
a Python code which
evaluates the incomplete Gamma function,
by Chi Leung Lau.
This is a version of Applied Statistics Algorithm 147.
-
asa152,
a Python code which
evaluates the Probability Density Function (PDF)
and Cumulative Density Function
(CDF) associated with the hypergeometric distribution,
by Richard Lund;
this is a version of Applied Statistics Algorithm 152.
-
asa183,
a Python code which
implements a random number generator (RNG),
by Wichman and Hill.
This is a version of Applied Statistics Algorithm 183.
-
asa226,
a Python code which
evaluates the Cumulative Density Function (CDF)
of the noncentral Beta distribution,
by Russell Lenth.
This is a version of Applied Statistics Algorithm 226.
-
asa239,
a Python code which
evaluates the incomplete Gamma function,
by Shea.
This is a version of Applied Statistics Algorithm 239.
-
asa241,
a Python code which
evaluates the percentage points of the normal distribution,
by Michael Wichura.
This is a version of Applied Statistics Algorithm 241.
-
asa243,
a Python code which
evaluates the Cumulative Density Function (CDF)
of the noncentral T distribution,
by Russell Lenth;
this is a version of Applied Statistics Algorithm 243.
-
asa245,
a Python code which
evaluates the logarithm of the Gamma function,
by Allan Mcleod;
this is a version of Applied Statistics Algorithm 245.
-
asa299,
a Python code which
computes the lattice points in an M-dimensional simplex,
by Chasalow and Brand;
this is a version of Applied Statistics Algorithm 299;
-
atbash,
a Python code which
applies the Atbash substitution cipher to a string of text.
-
autocatalytic_ode,
a Python code which
sets up and solves the autocatalytic ordinary differential equation
(ODE), which has chaotic behavior and an attractor.
-
axon_ode,
a Python code which
sets up the ordinary differential equations (ODE) for the
Hodgkin-Huxley model of an axon.
-
backtrack_binary_rc,
a Python code which
carries out a backtrack search for a set of binary decisions, using
reverse communication (RC).
-
backward_euler,
a Python code which
solves one or more ordinary differential equations (ODE)
using the (implicit) backward Euler method, using fsolve() for
the implicit equation.
-
backward_euler_fixed,
a Python code which
solves one or more ordinary differential equations (ODE)
using the (implicit) backward Euler method, using fixed point iteration
for the implicit equation.
-
ball_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected from the interior of
the unit ball in 3D.
-
ball_grid,
a Python code which
computes grid points inside a 3D ball.
-
ball_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit ball in 3D.
-
ball_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate integrals of a function
over the interior of the unit ball in 3D;
-
ball_positive_distance,
a Python code which
computes the expected value of the distance
between a pair of points randomly selected from the interior
of the unit positive ball in 3D.
-
bank,
a Python code which
computes the check digit associated with a US Bank Routing Number
check digit, or reports whether a 9-digit code is actually valid.
-
barycentric_interp_1d,
a Python code which
defines and evaluates the barycentric Lagrange polynomial p(x)
which interpolates a set of data, so that p(x(i)) = y(i).
The barycentric approach means that very high degree polynomials can
safely be used.
-
bdf2,
a Python code which
solves one or more ordinary differential equations (ODE)
using BDF2, the (implicit) backward difference formula
of order 2, using fsolve() to solve the implicit equation.
-
bellman_ford,
a Python code which
implements the Bellman-Ford algorithm for finding the shortest
distance from a given node to all other nodes in a directed graph
whose edges have been assigned real-valued lengths.
-
bernstein_approximation,
a Python code which
looks at some simple cases of approximation of a function f(x)
by a Bernstein polynomial.
-
bernstein_polynomial,
a Python code which
evaluates the Bernstein polynomials;
-
besselj,
a Python code which
evaluates Bessel J functions of noninteger order;
-
bicycle_lock,
a Python code which
simulates the process of determining the secret combination of
a bicycle lock, an integer between 000 and 999.
-
biharmonic_exact,
a Python code which
evaluates exact solutions w(x,y) to the biharmonic equation
del^2 w = 0 or wxxxx + 2 wxxyy + wyyyy = 0
-
biochemical_linear_ode,
a Python code which
sets up a linear biochemical ordinary differential equation (ODE).
-
biochemical_nonlinear_ode,
a Python code which
sets up a nonlinear biochemical ordinary differential
equation (ODE).
-
bioconvection_ode,
a Python code which
approximates solutions to a system of
ordinary differential equations (ODE) which
model a bioconvection problem, and which are related to
the Lorenz system.
-
bird_egg,
a Python code which
evaluates some formulas for the shapes of bird eggs.
-
bisect,
a Python code which
seeks a solution to the equation F(X)=0 using bisection
within a user-supplied change of sign interval [A,B].
The procedure is written using classes.
-
bisection_rc,
a Python code which
seeks a solution to the nonlinear equation F(X)=0 using bisection
within a user-supplied change of sign interval [A,B].
The procedure is written using reverse communication (RC).
-
black_scholes,
a Python code which
implements some simple approaches to
the Black-Scholes option valuation theory,
by Desmond Higham.
-
blood_pressure_ode,
a Python code which
sets up and solves an ordinary differential equation (ODE)
which models the variation in blood pressure in the human artery.
-
blowup_ode,
a Python code which
sets up an ordinary differential equation (ODE) y'=y^2.
whose solution "blows up" in finite time.
-
boundary_locus,
a Python code which
uses the boundary locus method to display the region of
absolute stability for a solver of ordinary differential
equations (ODE).
-
boundary_locus2,
a Python code which
uses the boundary locus method to plot the boundary of the
absolute stability region for a solver of ordinary differential
equations (ODE), based on a procedure by Randall Leveque.
-
boundary_word_equilateral,
a Python code which
describes the outline of an object on a grid of equilateral
triangles, using a string of symbols that represent the
sequence of steps tracing out the boundary.
-
boundary_word_hexagon,
a Python code which
describes the outline of an object on a grid of hexagons,
using a string of symbols that represent the sequence of steps
tracing out the boundary.
-
boundary_word_square,
a Python code which
describes the outline of an object on a grid of squares,
using a string of symbols that represent the sequence of steps
tracing out the boundary.
-
box_distance,
a Python code which
estimates the distribution and expected value of the distance between
two points picked uniformly at random within a box.
-
brc_data,
a Python code which
creates a file of randomly generated temperature readings to be
associated with weather stations at 413 world cities. A file like
this, with 1 billion records, is used for the billion
record challenge (BRC).
-
brownian_motion_simulation,
a Python code which
simulates Brownian motion in an M dimensional region.
-
broyden,
a Python code which
implements the Broyden iterative method for nonlinear equations,
by Tim Kelley.
-
brusselator_ode,
a Python code which
sets up the Brusselator ordinary differential equation
(ODE) system.
-
burgers_exact,
a Python code which
evaluates exact solutions of the
time-dependent 1D viscous Burgers equation.
-
bvp_fd,
a Python code which
demonstrates the use of the finite difference method (FDM)
to solve a boundary value problem (BVP).
-
bvec,
a Python code which
demonstrates how signed integers can be stored as
binary vectors, and arithmetic can be performed on them.
-
c8lib,
a Python code which
implements certain elementary functions for
64 bit precision complex (C8) variables;
-
caesar,
a Python code which
applies a Caesar Shift Cipher to a string of text.
-
calpak,
a Python code which
computes various simple calendrical quantities. It can work with
various calendars including Egyptian, English, French Revolutionary,
Gregorian, Julian, and Julian Ephemeris Date. It can convert a
date from one calendar to another. It can return the day of the week
for a given date. It can convert from day-number/year to day/month/year
format. It can calculate the time difference between two dates.
-
candy_count,
a Python code which
counts the types of candy in a rectangular container, which might be
a vector, matrix, or 3D box. The candy is assumed to have C possible
types, and to have been entered into the container in a cycle that
begins with type 1. While the vector case is easy, it is already
difficult to come up with a general formula for the MxN matrix case.
-
casino_simulation,
a Python code which
simulates a casino game that gives you 20% of your bet for heads,
and only takes 17% for tails. How much will you end up winning?
-
cauchy_method,
a Python code which
solves one or more ordinary differential equations (ODE)
using the Cauchy method.
-
cauchy_principal_value,
a Python code which
uses Gauss-Legendre quadrature to estimate the Cauchy Principal Value
(CPV) of certain singular integrals.
-
caustic,
a Python code which
generates an image of a caustic, by drawing n equally spaced points in
a circle, and then connecting specific pairs of points using a spacing
parameter m.
-
ccn_rule,
a Python code which
defines a Clenshaw Curtis Nested (CCN) quadrature rule.
-
ccs_io
a Python code which
reads and writes sparse linear systems
stored in the Compressed Column Storage (CCS) format.
-
ccs_to_st
a Python code which
converts a sparse matrix from Compressed Column Storage (CCS) to
sparse triplet (ST) format.
-
cellular_automaton,
a Python code which
prints or plots the evolution of Cellular Automaton rule #30.
-
cfd_barba,
a Python code which
contains some of the iPython workbooks
associated with the "12 Steps to Navier-Stokes" presentation
by Lorena Barba.
-
cg,
a Python code which
implements a simple version of the conjugate gradient (CG) method
for solving a system of linear equations of the form A*x=b,
suitable for situations in which the matrix A is symmetric positive
definite (SPD).
-
cg_rc,
a Python code which
implements the conjugate gradient (CG) method for solving
a symmetric positive definite (SPD) sparse linear system A*x=b,
using reverse communication (RC).
-
change_diophantine,
a Python code which
sets up a Diophantine equation to solve the change making problem,
which counts the number of ways a given sum can be formed
using coins of various denominations.
-
change_dynamic,
a Python code which
uses dynamic programming to solve the change making problem,
in which a given sum is to be formed using coins of various
denominations.
-
change_greedy,
a Python code which
uses the greedy method to seek a solution to the change making problem,
which tries to match a given amount by selecting coins of various
denominations.
-
change_polynomial,
a Python code which
uses a polynomial multiplication algorithm to count the ways of making
various sums using a given number of coins.
-
chebyshev,
a Python code which
computes the Chebyshev interpolant/approximant to a given function
over an interval.
-
chebyshev_interp_1d,
a Python code which
determines the combination of Chebyshev polynomials which
interpolates a set of data, so that p(x(i)) = y(i).
-
chebyshev_polynomial,
a Python code which
considers the Chebyshev polynomials T(i,x), U(i,x), V(i,x) and W(i,x).
Functions are provided to evaluate the polynomials, determine their
zeros, produce their polynomial coefficients, produce related
quadrature rules, project other functions onto these polynomial
bases, and integrate double and triple products of the polynomials.
-
chebyshev1_exactness,
a Python code which
tests the exactness of
Gauss-Chebyshev type 1 quadrature rules.
-
chebyshev1_rule,
a Python code which
computes and writes out a Gauss-Chebyshev type 1 quadrature rule
of given order.
-
chebyshev2_exactness,
a Python code which
tests the exactness of Gauss-Chebyshev type 2
quadrature rules.
-
chebyshev2_rule,
a Python code which
computes and writes out a Gauss-Chebyshev type 2 quadrature rule
of given order.
-
chen_ode,
a Python code which
sets up and solves the Chen system
of ordinary differential equations (ODE).
-
chinese_remainder_theorem,
a Python code which
demonstrates the Chinese remainder theorem, for reconstructing a
number based on its remainders against a set of bases.
-
chrpak,
a Python code which
manipulates characters and strings;
-
chuckaluck_simulation,
a Python code which
simulates the Chuck-a-Luck gambling game.
-
circle_arc_grid,
a Python code which
computes grid points along a circular arc.
-
circle_circles_packing,
a Python code which
tries to randomly pack as many non-overlapping circles of equal size
into a larger circle, with a typical final coverage density of
about 0.547. This is an
example of random sequential adsorption (RSA).
-
circle_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected on the circumference
of the unit circle.
-
circle_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the circumference of the unit circle in 2D.
-
circle_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
along the circumference of the unit circle in 2D;
-
circle_positive_distance,
a Python code which
estimates the mean and variance of the distance between
a random pair of points on the circumference
of the unit positive circle in 2D.
-
circle_rule,
a Python code which
computes quadrature rules for the unit circle in 2D,
to approximate integrals of f(x,y) over the
circumference of the circle of radius 1 and center (0,0).
-
clausen,
a Python code which
evaluates a Chebyshev interpolant to the Clausen function Cl2(x).
-
clenshaw_curtis_rule,
a Python code which
implements a Clenshaw Curtis quadrature rule;
-
clock_solitaire_simulation,
a Python code which
simulates the game of clock solitaire. The deck is dealt into 13
piles of 4 cards each. Repeatedly, the top card a pile is removed,
and its rank indicates the next pile to consider. Game continues
until an empty pile is reached. The game is won if all piles are
empty. The quantity of interest is the probability of winning.
-
closest_pair_brute,
a Python code which
uses brute force to solve a 2D version of the closest pair problem,
which identifies the closest pair of points in a given collection.
-
closest_pair_divcon,
a Python code which
uses a divide and conquer approach to solve a 2D version of
the closest pair problem.
-
closest_point_brute,
a Python code which
uses brute force to find the nearest of a set of N points in D
dimensions to a given test point. This is sometimes called a
nearest neighbor calculation.
-
cobweb_plot,
a Python library which
displays a cobweb plot illustrating the process of function iteration,
by John D Cook.
-
coin_simulation,
a Python code which
looks at ways of simulating or visualizing the results of
many tosses of a fair or biased coin.
-
collatz,
a Python code which
computes and analyzes the Collatz
sequence, also known as the hailstone sequence or 3n+1 sequence;
-
collatz_dict,
a Python code which
demonstrates how the Python dict variable type can be used to
efficiently record data about the Collatz iteration.
-
collatz_polynomial,
a Python code which
implements the Collatz polynomial iteration, a polynomial analog of
the numerical iteration that is also known as the 3n+1 conjecture or
the hailstone sequence.
-
collatz_recursive,
a Python code which
demonstrates recursive programming by considering
the simple Collatz 3n+1 problem.
-
columns,
a Python code which
copies columns clo:chi from a text file to a new text file.
-
combination_lock,
a Python code which
simulates the process of determining the secret combination of a lock.
-
combo,
a Python code which
ranks, unranks, enumerates, lists and
randomly selects balanced sequences, cycles, graphs, Gray codes,
subsets, partitions, permutations, restricted growth functions,
Pruefer codes and trees.
-
companion_matrix,
a Python code which
computes the companion matrix for a polynomial.
The polynomial may be represented in the standard monomial basis,
or as a sum of Chebyshev, Gegenbauer, Hermite, Laguerre, or Lagrange
basis polynomials. All the roots of the polynomial can be determined as
the eigenvalues of the corresponding companion matrix.
-
compass_search,
a Python code which
seeks the minimizer of a scalar function of several variables
using compass search, a direct search algorithm
that does not use derivatives.
-
complex_numbers_test,
demonstrates some of the features of using complex numbers.
-
components,
a Python code which
organizes contiguous cells into labeled clusters, for a
1D, 2D, or 3D array. This code has uses in image analysis
and percolation simulation.
-
condition,
a Python code which
implements methods of computing or estimating
the condition number of a matrix.
-
conservation_ode,
a Python code which
monitors the conservation of a quantity
that should be constant, during the solution of an
ordinary differential equation (ODE).
-
continued_fraction,
a Python code which
implements some simple algorithms for dealing with simple and
generalized continued fractions.
-
convergence,
a Python code which
is given a sequence of approximation errors and estimates the order
of convergence, assuming the results correspond to a
a sequence of decreasing mesh sizes h, or increasing mesh counts n.
-
ConvexHull_test,
a Python code which
calls ConvexHull(), which
is a scipy.spatial function to compute the convex hull of a set
of points.
-
cordic,
a Python code which
computes a few special functions using the CORDIC algorithm.
-
cosine_transform,
a Python code which
demonstrates some simple properties of the discrete cosine transform
(DCT).
-
counterfeit_detection,
a Python code which
considers problems in which one or more counterfeit coins
are to be identified by the fact that they do not have the
standard weight.
-
cpr,
a Python code which
implements the Chebyshev Proxy Rootfinder (CPR) to locate all the
real zeros of a smooth real function f(x) within an interval [a,b],
by John Boyd.
-
craps_simulation,
a Python code which
simulates the gambling game of craps, in which a player rolls two dice.
On the first roll, the player wins immediately if a 7 or 11 is rolled,
and loses immediately if a 2, 3 or 12 is rolled. Otherwise, the sum
of the dice on this first roll is called the point. The player now
continues to roll the dice, winning if the point is rolled again,
and losing if a 7 is rolled.
-
crs_io
a Python code which
reads and writes sparse linear systems
stored in the Compressed Row Storage (CRS) format.
-
csv_test,
a Python code which
tests the csv() library
for reading and writing Comma Separated Value (CSV) data files.
-
cube_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected in the interior
of the unit cube in 3D.
-
cube_exactness,
a Python code which
tests the exactness of quadrature rules
over the interior of a cube in 3D.
-
cube_grid,
a Python code which
computes a grid of points
over the interior of a cube in 3D.
-
cube_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit cube in 3D.
-
cube_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
over the interior of the unit cube in 3D.
-
cube_surface_distance,
a Python code which
estimates the expected value of the distance
between a pair of points randomly selected
on the surface of the unit cube.
-
cuda_loop,
a Python code which
shows how, in a CUDA program running on a Graphics Processing
Unit (GPU), the choice of block and thread factors determines
the allocation of tasks to processors.
-
cvt_1d_lloyd,
a Python code which
computes an N-point Centroidal Voronoi Tessellation (CVT)
within the interval [0,1], under a uniform density,
using the Lloyd iteration to compute the Voronoi regions exactly.
-
cvt_1d_sampling,
a Python code which
computes an N-point Centroidal Voronoi Tessellation (CVT)
within the interval [0,1], under a uniform density,
using sampling to estimate the Voronoi regions.
-
cvt_2d_sampling,
a Python code which
computes an N-point Centroidal Voronoi Tessellation (CVT)
within the unit square [0,1]x[0,1], under a uniform density,
using sampling to estimate the Voronoi regions.
-
cvxopt_svm,
a Python code which
solves a support vector machine (SVM) problem by formulating it
as a quadratic programming problem to be solved by cvxopt().
-
cvxopt_test,
a Python code which
calls cvxopt(), which solves problems in convex optimization
and quadratic programming.
-
cycle_brent,
a Python code which
carries out an iterated function evaluation, and seeks to determine
the nearest element of a cycle, and the cycle length,
using the Brent method.
-
cycle_floyd,
a Python code which
carries out an iterated function evaluation, and seeks to determine
the nearest element of a cycle, and the cycle length,
using the Floyd method.
-
delaunay_test,
a Python code which
demonstrates the use of the scipy.spatial function Delaunay(),
to compute a Voronoi diagram, and matplotlib.pyplot.triplot(),
to display it.
-
delsq,
a Python code which
is given a grid G, and returns a corresponding sparse matrix D that
defines the Laplacian operator on G.
-
dg1d_poisson,
a Python code which
applies the discontinuous Galerkin method (DG) to a 1D version of
the Poisson equation,
based on a code by Beatrice Riviere.
-
dice_simulation,
a Python code which
simulates N tosses of M dice, making a histogram of the resulting sums.
-
differ,
a Python code which
is given function values at equally spaced locations, and the
order of a derivative, and uses the finite difference method (FDM)
to compute a linear combination of these function values which
approximates that derivative.
-
diffusion_pde,
a Python code which
solves the diffusion partial differential equation (PDE)
dudt - mu * d2udx2 = 0 in one spatial dimension, with
a constant diffusion coefficient mu, and periodic boundary
conditions, using the forward time, centered space (FTCS)
difference method.
-
digital_dice,
a Python code which
carries out the probability simulations
described in "Digital Dice", by Paul Nahin;
-
digraph_adj,
a Python code which
carries out operations on abstract digraphs, a kind of graph with
directed edges, described by an adjacency matrix.
-
digraph_dict,
a Python code which
carries out operations on abstract digraphs, with directed edges,
represented by a Python dictionary.
The dictionary has a key for each node; the values list
the nodes which are immediately reachable from the key node.
-
dijkstra,
a Python code which
implements a simple version of the Dijkstra minimum distance algorithm
for graphs.
-
diophantine,
a Python code which
finds one solution of a Diophantine equation in any number of
variables.
-
diophantine_nd,
a Python code which
is given a Diophantine equation in N variables, and
returns all nonnegative solutions, or all strictly positive solutions.
-
disk_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected inside the unit disk.
-
disk_grid,
a Python code which
computes grid points within the interior of
a disk of user specified radius and center in 2D,
using matplotlib() to create an image of the grid.
-
disk_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of a disk of radius R centered at the origin.
-
disk_integrands,
a Python code which
defines several test integrals over the unit disk, making it possible
to check the accuracy of quadrature rules.
-
disk_monte_carlo,
a Python code which
applies a Monte Carlo (MC) method to estimate integrals of a function
over the interior of the general disk in 2D;
-
disk_positive_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected inside the unit positive
disk.
-
disk_rule,
a Python code which
computes a quadrature rule
over the interior of the general disk in 2D.
-
disk_triangle_picking,
a Python code which
estimates the expected value of the area of a triangle formed
by three randomly selected points in the unit disk.
-
disk01_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit disk in 2D.
-
disk01_integrands,
a Python code which
defines several test integrals over the unit disk, making it
possible to check the accuracy of quadrature rules.
-
disk01_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate integrals of a function
over the interior of the unit disk in 2D;
-
disk01_positive_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate integrals of a function
over the interior of the unit positive disk in 2D;
-
disk01_rule,
a Python code which
computes a quadrature rule
to approximate the integral of a function
over the interior of the unit disk in 2D,
with radius 1 and center (0,0).
-
divdif,
a Python code which
creates, prints and manipulates divided difference polynomials from
a table of values (x,f(x)). The code can compute the coefficients of
the Newton and power sum forms of the interpolating polynomial. It
can compute the derivative or antiderivate polynomial. It can compute
the form of the Lagrange basis polynomials. It can compute the
points and weights for Newton Cotes quadrature rules. It can compute
the weights for a Lagrange interpolation scheme.
-
dolfin-convert,
a Python code which
converts mesh file from gmsh(), medit(), METIS or SCOTCH format to an
XML format suitable for use by dolfin() or fenics(),
by Anders Logg.
-
doomsday,
a Python code which
is given the year, month and day of a date, and uses
John Conway's doomsday algorithm to determine the corresponding
day of the week.
-
dosage_ode,
a Python code which
sets up a system of ordinary differential equations (ODE) to
simulate the blood levels of a medicinal drug that should
stay between medicinal and toxic limits.
-
double_well_ode,
a Python code which
sets up an ordinary differential equation (ODE)
which models the motion of a particle in a double well potential.
-
duel_simulation,
a Python code which
simulates N repetitions of a duel between two players, each of
whom has a known firing accuracy.
-
dueling_idiots,
a Python code which
carries out the probability simulations
described in "Dueling Idiots", by Paul Nahin;
-
duffing_ode,
a Python code which
sets up a second-order ordinary differential equation (ODE)
whose solution can exhibit chaotic behavior.
-
e_spigot,
a Python code which
produces N digits of the decimal expansion of e.
-
eigs_test,
a Python code which
calls np.linalg.eig(), which
is a built-in system function which computes the eigenvalues and
eigenvectors of a matrix.
-
elements,
a Python code which
stores the atomic number, atomic weight, element name and element
symbol for the chemical elements.
-
ellipse,
a Python code which
carries out geometric calculations for ellipses and ellipsoids,
including area, distance to a point, eccentricity, perimeter,
points along the perimeter, random sampling, conversion between
standard and quadratic forms.
-
ellipse_distance,
a Python code which
computes the expected value of the distance
between a pair of points randomly selected on the circumference
of the ellipse (x/a)^2+(y/b)^2=1 in 2D.
-
ellipse_grid,
a Python code which
computes grid points
over the interior of an ellipse in 2D.
-
ellipse_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate the value of integrals
over the interior of an ellipse in 2D.
-
ellipsoid,
a Python code which
carries out geometric calculations for ellipsoids, including
area, random sampling, conversion between standard and quadratic
forms.
-
ellipsoid_grid,
a Python code which
computes a grid of points
over the interior of an ellipsoid in 3D.
-
ellipsoid_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate the value of integrals
over the interior of an ellipsoid in M dimensions.
-
elliptic_integral,
a Python code which
evaluates complete elliptic integrals of first, second and third kind,
using the Carlson elliptic integral functions.
-
epicycloid,
a Python code which
plots an epicycloid curve.
-
eros,
a Python code which
implements elementary row operations (EROs) for the
interactive solution of a system of linear equations.
-
euclid,
a Python code which
investigates various versions of Euclid's algorithm for computing
the greatest common divisor (GCD) of two integers.
-
euler,
a Python code which
solves one or more ordinary differential equations (ODE)
using the forward Euler method.
-
exactness,
a Python code which
tests the exactness of quadrature rules that estimate the
integral of a function with a density, such as 1, exp(-x) or
exp(-x^2), over an interval such as [-1,+1], [0,+oo) or (-oo,+oo).
-
exp_ode,
a Python code which
sets up an ordinary differential equation (ODE)
whose solution is an exponential function.
-
fair_dice_simulation,
a Python code which
simulates N tosses of 2 dice, making a histogram of the resulting sums.
-
fd_predator_prey,
a Python code which
solves a time-dependent predator prey system using the
finite difference method (FDM).
-
fd1d_advection_lax_wendroff,
a Python code which
applies the finite difference method (FDM) to solve the time-dependent
advection equation ut = - c * ux in one spatial dimension, with
a constant velocity, using the Lax-Wendroff method to approximate the
time derivative,
creating a graphics file with matplotlib().
-
fd1d_bvp,
a Python code which
applies the finite difference method (FDM)
to a two point boundary value problem (BVP) in one spatial dimension.
-
fd1d_heat_explicit,
a Python code which
implements a finite difference method (FDM), explicit in time,
to solve the time dependent 1D heat equation;
-
fd1d_heat_implicit,
a Python code which
implements a finite difference method (FDM), implicit in time,
to solve the time dependent 1D heat equation;
-
fd1d_wave,
a Python code which
applies the finite difference method (FDM) to solve the time-dependent
wave equation utt = c * uxx in one spatial dimension.
-
fd2d_convergence_test,
a Python code which
calls fd2d_poisson(), which
repeatedly solves a Poisson equation on a sequence of finer meshes,
so that the relationship between mesh size H and error norm E can
be explored.
-
fd2d_heat_steady,
a Python code which
implements a finite difference method (FDM) for the steady
time-independent 2D heat equation;
-
fem_basis,
a Python code which
defines and evaluates finite element method (FEM) basis functions
for any degree in an M dimensional simplex (1D interval, 2D triangle,
3D tetrahedron, and higher dimensional generalizations.)
-
fem_to_xml,
a Python code which
reads a pair of FEM files defining node coordinates and elements,
of a 1D, 2D or 3D mesh, namely
a file of node coordinates and a file of elements defined by
node indices, and creates a corresponding XML file for input
to dolfin() or fenics().
-
fem1d,
a Python code which
applies the finite element method (FEM) to a boundary value problem
(BVP) in one spatial dimension, using a procedural approach.
-
fem1d_bvp_linear,
a Python code which
applies the finite element method (FEM), with piecewise linear
elements, to a two point boundary value problem (BVP) in one
spatial dimension, and compares the computed and exact solutions
with the L2 and seminorm errors.
-
fem1d_bvp_quadratic,
a Python code which
applies the finite element method (FEM),
with piecewise quadratic elements,
to a two point boundary value problem (BVP) in one spatial dimension,
and compares the computed and exact solutions
with the L2 and seminorm errors.
-
fem1d_heat_explicit,
a Python code which
uses the finite element method (FEM) and explicit time stepping
to solve the time dependent heat equation in 1D.
-
fem1d_model,
a Python code which
applies the finite element method (FEM) to a boundary value problem
(BVP) in one spatial dimension, using a procedural approach.
-
fem2d_bvp_linear,
a Python code which
applies the finite element method (FEM),
with piecewise bilinear elements,
to a 2D boundary value problem (BVP) in a rectangle.
-
fern,
a Python code which
computes and displays the Barnsley fractal fern.
-
fibonacci_spiral,
a Python code which
displays points on a Fibonacci spiral, suggesting the arrangement
of seeds in a sunflower, for instance.
-
file_name_sequence,
a Python code which
generates a sequence of filenames, which can
be useful when generating a sequence of still snapshots
to be animated later.
-
filum,
a Python code which
performs various operations on files;
-
fire_simulation,
a Python code which
simulates a forest fire over a rectangular array of trees,
starting at a single random location. It is intended as a starting
point for the development of a parallel version.
-
fisher_exact,
a Python code which
returns an exact solution of the Kolmogorov Petrovsky Piskonov Fisher
partial differential equation (PDE) ut=uxx+u*(1-u).
-
fisher_pde_ftcs,
a Python code which
estimates a solution of the Kolmogorov Petrovsky Piskonov Fisher
partial differential equation (PDE) ut=uxx+u*(1-u), using the
forward time centered space (FTCS) method, with an oscillating
Dirichlet condition on the left, and a zero Neumann condition
on the right. An animation of the solution is created.
-
fitzhugh_nagumo_ode,
a Python code which
sets up the Fitzhugh-Nagumo system of
ordinary differential equations (ODE).
-
flame_exact,
a Python code which
returns the exact solution of an ordinary differential equation (ODE)
which models the growth of a ball of flame in a combustion process.
The exact solution is defined in terms of the Lambert W function.
-
flame_ode,
a Python code which
sets up an ordinary differential equation (ODE) which models
the growth of a ball of flame in a combustion process.
The exact solution is defined in terms of the Lambert W function.
-
flame_odefun,
a Python code which
uses odefun() from the multiple precision package mpmath() to
solve an ordinary differential equation (ODE) which models
the growth of a ball of flame in a combustion process.
The exact solution is defined in terms of the Lambert W function.
-
flies_simulation,
a Python code which
simulates an experiment in which two flies land on a plate of radius 1.
By repeating the experiment many times, the average distance between
the flies is to be estimated.
-
florida_cvt_geo,
a Python code which
explores the creation of a centroidal Voronoi Tessellation (CVT) of
the state of Florida, based solely on geometric considerations.
-
florida_cvt_pop,
a Python code which
explores the creation of a centroidal Voronoi Tessellation (CVT) of
the state of Florida, based on population considerations.
-
floyd,
a Python code which
implements the Floyd algorithm for finding the shortest distance
between pairs of nodes on a directed graph.
-
fly_simulation,
a Python code which
simulates an experiment in which a fly lands on a plate of radius 1.
By repeating the experiment many times, the average distance of the
fly from the center is to be estimated.
-
fn,
a Python code which
evaluates elementary and special functions using
Chebyshev polynomials; functions include Airy, Bessel I, J, K and Y,
beta, confluent hypergeometric, error, gamma, log gamma, Pochhammer,
Spence; integrals include hyperbolic cosine, cosine, Dawson,
exponential, logarithmic, hyperbolic sine, sine; by Wayne Fullerton.
-
football_dynamic,
a Python code which
uses dynamic programming to count the ways of achieving
a given score in football, respecting the order of events.
-
football2_diophantine,
a Python code which
uses diophantine analysis to count the ways of achieving
a given score in football, ignoring the order of events.
-
football2_dynamic,
a Python code which
uses dynamic programming to count the ways of achieving
a given score in football, respecting the order of events.
-
four_fifths,
a Python code which
searches for a solution to the problem of finding
four fifth powers that sum to a fifth power, that is, integers a,
b, c, d and e such that a^5+b^5+c^5+d^5=e^5. Euler conjectured
that no solution was possible. The code is by Brian Hayes.
-
freefem_msh_io,
a Python code which
reads and writes files used by the FreeFem++ finite element program
to store mesh information.
-
fsolve_test,
a Python code which
calls fsolve() which
seeks the solution x of one or more nonlinear equations f(x)=0.
-
full_deck_simulation,
a Python code which
simulates a process in which a random card is drawn from
a deck of 52, and then replaced, continuing until every
card has been seen at least once.
-
gamblers_ruin_simulation,
a Python code which
simulates a game in which a gambler never stops playing until
all money is lost.
-
gauss_seidel,
a Python code which
uses the Gauss-Seidel iteration to solve a linear system
with a symmetric positive definite (SPD) matrix.
-
gauss_seidel_stochastic,
a Python code which
uses a stochastic version of the Gauss-Seidel iteration
to solve a linear system
with a symmetric positive definite (SPD) matrix.
-
gaussian,
a Python code which
evaluates the Gaussian function and its derivatives.
-
gaussian_2d,
a Python code which
evaluates a general Gaussian function of a 2D argument.
-
gaussian_prime_spiral,
a Python code which
computes a twisting spiral path along the Gaussian primes,
and displays a plot of the total trajectory.
-
ge_to_crs,
a Python code which
converts a matrix from General (GE) to
Compressed Row Storage (CRS) format.
-
gegenbauer_cc,
a Python code which
computes the Gegenbauer weighted integral of a function f(x)
using a Clenshaw-Curtis approach.
-
gegenbauer_exactness,
a Python code which
tests the exactness of Gauss-Gegenbauer quadrature rules.
-
gegenbauer_polynomial,
a Python code which
evaluates the Gegenbauer polynomial and associated functions.
-
gen_hermite_exactness,
a Python code which
tests the
exactness of generalized Gauss-Hermite quadrature rules.
-
gen_laguerre_exactness,
a Python code which
tests the exactness of generalized Gauss-Laguerre
quadrature rules.
-
geometry,
a Python code which
performs geometric calculations in 2, 3 and M dimensional space,
including the computation of angles, areas, containment, distances,
intersections, lengths, and volumes.
-
gl_fast_rule,
a Python code which
carries out the rapid computation of the Kth value and weight of
an N point Gauss-Legendre quadrature rule for approximating
the integral of a function over the interval [-1,+1],
by Ignace Bogaert.
-
glomin,
a Python code which
finds a global minimum of a scalar function of a scalar argument,
without the use of derivative information,
by Richard Brent.
-
glycolysis_ode,
a Python code which
sets up a pair of ordinary differential equations (ODE)
that model the biochemical process of glycolysis, for which
a limit cycle exists.
-
gmgsolve,
a Python code which
applies one step of the V-cycle of the geometric multigrid method,
by Mike Sussman.
-
gradient_descent,
a Python code which
uses gradient descent to solve a linear least squares (LLS) problem.
-
gram_polynomial,
a Python code which
evaluates the Gram polynomials, also known as the discrete
Chebyshev polyomials and associated functions.
-
gram_schmidt,
a Python code which
implements the Gram-Schmidt process to orthogonalize and normalize
a set of vectors.
-
graph_adj,
a Python code which
carries out operations on abstract graphs, with undirected edges,
represented by an adjacency matrix. Operations included breadth-first
search, the computation of a minimum spanning tree,
an Euler or Hamilton circuit, blocks, chromatic polynomial,
or transitive closure.
-
graph_class,
a Python code which
creates classes related to abstract graphs, and uses them to define
various algorithms include breadth-first search, depth-first search,
and shortest path.
-
graphics_test,
a Python code which
demonstrates techniques for creating a graphic display of
a variety of scientific data.
-
graphviz_test,
a Python code which
calls graphiviz(), which
displays representations of graphs.
-
grazing_ode,
a Python code which
sets up ordinary differential equations (ODE)
that model the populations of an edible plant, and the
herbivore that grazes on it.
-
grf_io,
a Python code which
reads or writes a GRF file which represents a mathematical graph;
-
gurobi_solution_read,
a Python code which
reads a file created by the optimization package gurobi(),
representing the solution of a polyomino tiling problem,
and writes an ASCII file that can be read by load().
-
gyroscope_ode,
a Python code which
sets up the ordinary differential equations (ODE) that simulate
the angular attitude and rotational speed of a gyroscope.
-
haar_transform,
a Python code which
computes the Haar transform of 1d or 2d data.
-
halton,
a Python code which
computes elements of a Halton Quasi Monte Carlo (QMC) sequence,
using a simple interface.
-
hammersley,
a Python code which
computes elements of a Hammersley Quasi Monte Carlo (QMC) sequence,
using a simple interface.
-
hamming,
a Python code which
implements some simple versions of Hamming codes which can detect
and correct errors in data.
-
hankel_cholesky,
a Python code which
computes the upper Cholesky factor R of a symmetric positive definite
(SPD) H matrix so that H = R' * R.
-
hankel_cholesky,
a Python code which
computes the upper Cholesky factor R of a symmetric positive definite
(SPD) Hankel matrix so that H = R' * R.
-
hankel_spd,
a Python code which
computes a lower triangular matrix L which is the Cholesky factor
of a symmetric positive definite (SPD) Hankel matrix H, that is,
H = L * L'.
-
hdf5_test,
a Python code which
demonstrates the use of the HDF5 library and file format.
-
heartbeat_ode,
a Python code which
sets up and solves an ordinary differential equation
(ODE) describing the beating of the heart, as suggested by Zeeman.
-
hello,
a Python code which
prints "Hello, world!".
-
hello_mpi,
a Python code which
prints "Hello, world!",
carried out in parallel using MPI and MPI4PY.
-
helmholtz_exact,
a Python code which
evaluates an exact formula for the solution of the Helmholtz equation,
a sort of eigenvalue equation that can arise after separation of
variables is a applied to the wave equation. This example considers
a problem in which Z(x,y) represents the vertical deflection of
the surface of a vibrating circular membrane such as a drumhead.
-
henon_heiles_ode,
a Python code which
sets up the Henon-Heiles system of ordinary differential
equations (ODE) which model the motion of a star around the galactic
center.
-
henon_orbit,
a Python code which
computes the orbit of the Henon map for various sets of initial data.
-
hermite_exactness,
a Python code which
tests the exactness of Gauss-Hermite quadrature rules
to estimate the integral of a function with density exp(-x^2)
over the interval (-oo,+oo).
-
hermite_polynomial,
a Python code which
evaluates the physicist's Hermite polynomial,
the probabilist's Hermite polynomial,
the Hermite function, and related functions.
-
hermite_rule,
a Python code which
returns a Gauss-Hermite quadrature rule
to estimate the integral of a function with density exp(-x^2)
over the interval (-oo,+oo).
-
hexagon_integrals,
a Python code which
returns the exact value of the integral of a monomial
over the interior of a hexagon in 2D.
-
hexagon_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
over the interior of a hexagon in 2D;
-
hexagon_stroud_rule,
a Python code which
computes one of four Stroud quadrature rules over the interior
of the unit hexagon.
-
hexahedron_jaskowiec_rule,
a Python code which
returns a symmetric Jaskowiec quadrature rule for the hexahedron,
with exactness up to total degree 21.
-
hexahedron_witherden_rule,
a Python code which
returns a symmetric Witherden quadrature rule for the hexahedron,
with exactness up to total degree 11.
-
high_card_simulation,
a Python code which
simulates a situation in which you see the cards in a deck one by one,
and must select the one you think is the highest and stop.
-
hilbert_curve,
a Python code which
computes the sequence of discrete Hilbert curves whose limit
is a space-filling curve.
-
hilbert_curve_3d,
a Python code which
converts 3D Hilbert curve data between spatial coordinates of a
lattice point (x,y,z) and the linear coordinate H which describes
the ordering of that point on the curve.
-
hits,
a Python code which
uses the HITS algorithm to assign authority and hub indices to
a set of nodes in a directed network.
-
humps,
a Python code which
evaluates the humps function, its first and second derivatives
and its antiderivative.
-
humps_ode,
a Python code which
sets up an ordinary differential equation (ODE)
whose solution is a double hump curve.
-
hyper_2f1,
a Python code which
evaluates the hypergeometric functions 2F1(a,b,c;x) for real
or complex argument x. For convenience, this function is simply
a wrapper for the corresponding function in the scipy.special() library.
-
hyperball_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected from the interior of the
unit hyperball in M dimensions.
-
hyperball_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit hyperball in M dimensions.
-
hyperball_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
over the interior of the unit ball in M dimensions;
-
hyperball_positive_distance,
a Python code which
computes the expected value of the distance
between a pair of points randomly selected from the interior of
the unit positive hyperball in M dimensions.
-
hypercube_distance,
a Python code which
estimates the expected value of the distance
between a pair of points randomly selected
in the M-dimensional unit hypercube.
-
hypercube_grid,
a Python code which
computes a grid of points
over the interior of a hypercube in M dimensions.
-
hypercube_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit hypercube in M dimensions.
-
hypercube_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
over the interior of the unit hypercube in M dimensions.
-
hypercube_surface_distance,
a Python code which
estimates the expected value of the distance
between a pair of points randomly selected
on the surface of the unit hypercube in D dimensions.
-
hypersphere,
a Python code which
carries out various operations for a D dimensional hypersphere,
including converting between Cartesian and spherical coordinates,
stereographic projection, sampling the surface of the sphere, and
computing the surface area and volume.
-
hypersphere_angle,
a Python code which
considers the problem of describing the typical value of the angle
between a pair of points randomly selected on the unit hypersphere
in M dimensions. Since by symmetry, this will be zero, we instead look
at the average of the absolute value of the dot product, and the
corresponding angle. In dimension 1, we have average dot product
of 1, and angle 0. As the dimension increases, the average dot product
rapidly decreases to 0, while the average angle goes to 90 degrees.
-
hypersphere_angle_distance,
a Python code which
considers the problem of describing the typical value of the angle
between a pair of points randomly selected on the unit hypersphere
in M dimensions. Since by symmetry, this will be zero, we instead look
at the average of the absolute value of the dot product, and the
corresponding angle. In dimension 1, we have average dot product
of 1, and angle 0. As the dimension increases, the average dot product
rapidly decreases to 0, while the average angle goes to 90 degrees.
-
hypersphere_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected from the surface of the unit
hypersphere in M dimensions.
-
hypersphere_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the surface of the unit hypersphere in M dimensions.
-
hypersphere_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
on the surface of the unit sphere in M dimensions;
-
hypersphere_positive_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected from the surface of the unit
positive hypersphere in M dimensions.
-
i4lib,
a Python code which
contains many utility routines, using single precision integer (I4)
arithmetic.
-
ill_bvp,
a Python code which
defines an ill conditioned boundary value problem (BVP), and calls on
scipy.integrate.solve_bvp() to solve it with various values of
the conditioning parameter.
-
image_boundary,
a Python code which
selects and displays the boundary edges in an image.
-
image_edge,
a Python code which
detects edges in an image.
-
image_rgb_to_gray,
a Python code which
makes a grayscale version of an RGB image.
-
insurance_simulation,
a Python code which
simulates a highly simplified model of term life insurance,
in which a customer agrees to pay an annual fee for a given
number of years, so that if the customer dies within that term,
the family receives a large payout.
-
is_gaussian_prime,
a Python code which
is true if a given complex number c is a Gaussian prime.
-
is_prime,
a Python code which
is true if a given integer n is prime.
-
isbn,
a Python code which
determines the check digit for an International Standard Book Number
(ISBN), or reports whether a given ISBN is valid.
-
ising_2d_simulation,
a Python code which
simulates the evolution of a 2D array of positive and negative
charges, each of which is likely to flip to be in agreement
with neighbors.
-
jaccard_distance,
a Python code which
computes the Jaccard distance between two sets.
-
jacobi,
a Python code which
implements the Jacobi iteration for the iterative solution of
linear systems.
-
jacobi_eigenvalue,
a Python code which
implements the Jacobi iteration for the iterative determination
of the eigenvalues and eigenvectors of a real symmetric matrix.
-
jacobi_exactness,
a Python code which
tests the exactness of rules for integrals with
a Jacobi weight function.
-
jacobi_poisson_1d,
a Python code which
uses Jacobi iteration to solve the linear system for a discretized
steady 1D Poisson equation.
-
jacobi_rule,
a Python code which
computes a Gauss-Jacobi quadrature rule.
-
jai_alai_simulation,
a Python code which
simulates a sequence matches of the game of jai alai.
-
jordan_matrix,
a Python code which
returns a random matrix in Jordan canonical form.
-
joukowsky_transform,
a Python code which
applies the Joukowsky transform to data, mapping between a circle
in the complex plane and various airfoil shapes.
-
julia_set,
a Python code which
computes and plots a Julia set,
the set of points in the complex plane that remain bounded
under a mapping of the form f(z) = z^2+c.
-
kdv_exact,
a Python code which
evaluates an exact solution of the Korteweg-deVries (KdV)
partial differential equation (PDE).
-
kepler_ode,
a Python code which
sets up the ordinary differential equations (ODE) for a
Kepler two-body gravitational system.
-
knapsack_01_brute,
a Python code which
uses brute force to solve small versions of the 0/1 knapsack problem,
in which a knapsack of limited weight capacity is to be packed as
full as possible, selecting items from a set of varying weights;
-
knapsack_brute,
a Python code which
uses brute force to solve small versions of the knapsack problem,
in which N items are available, each with given value and weight.
A thief's knapsack can carry no more than Wmax pounds. The thief
seeks a selection of items to carry in the knapsack of maximum
total value.
-
knapsack_dynamic,
a Python code which
uses dynamic programming to solve a knapsack problem.
-
knapsack_greedy,
a Python code which
uses a greedy algorithm to estimate a solution of the knapsack problem;
-
knapsack_random,
a Python code which
randomly chooses a subset of N items, each with given value and weight.
It then evaluates whether this is a feasible solution to a
problem in which a thief's knapsack can carry no more than Wmax pounds,
and it is desired to maximum the total value of the selected items.
-
knapsack_rational,
a Python code which
solves the rational knapsack problem, in which a knapsack of limited
weight capacity is filled with profitable items. This variation of
the 0/1 knapsack problem allows a fractional part of an item to
be included in the knapsack. The result is an upper bound on the
maximum possible profit for the 0/1 knapsack problem.
-
knapsack_values,
a Python code which
returns some simple examples of the knapsack problem,
in which N items are available, each with given value V and weight W.
A thief's knapsack can carry no more than K pounds. The thief
seeks a selection S of items to carry in the knapsack of maximum
total value.
-
kronrod_rule,
a Python code which
computes a Gauss and Gauss-Kronrod pair of quadrature rules
of arbitrary order,
by Robert Piessens, Maria Branders.
-
lagrange_approx_1d,
a Python code which
defines and evaluates the Lagrange polynomial p(x) of degree m
which approximates a set of nd data points (x(i),y(i)).
-
lagrange_basis_display,
a Python code which
displays the basis functions associated with a given set of nodes used
with the Lagrange interpolation scheme.
-
lagrange_interp_1d,
a Python code which
defines and evaluates the Lagrange polynomial p(x)
which interpolates a set of data depending on a 1D argument,
so that p(x(i)) = y(i).
-
laguerre_exactness,
a Python code which
tests the exactness of Gauss-Laguerre quadrature rules
for integrating functions with density exp(-x) over [0,+oo).
-
laguerre_polynomial,
a Python code which
evaluates the Laguerre polynomial, the generalized Laguerre
polynomials, and the Laguerre function.
-
laguerre_rule,
a Python code which
returns a Gauss-Laguerre quadrature rule of given order.
-
lambert_w,
a Python code which
evaluates Lambert's W function.
-
langford_ode,
a Python code which
sets up and solves the Langford system
of ordinary differential equations (ODE).
-
laplacian,
a Python code which
evaluates a discretized approximation to the Laplacian operator
on data on an evenly spaced grid, within a circle, an interval,
or a torus. For the case of the interval, the data may be supplied
on an unevenly spaced grid.
-
latin_center,
a Python code which
computes N points in an M dimensional Latin Center square;
-
latin_edge,
a Python code which
returns N points in an M dimensional Latin Edge square;
-
latin_random,
a Python code which
computes Latin Random Squares of N points in M dimensions;
-
leapfrog,
a Python code which
uses the leapfrog method to solve a second order ordinary
differential equation (ODE) of the form y''=f(t,y).
-
lebesgue,
a Python code which
is given a set of nodes in 1D, and
plots the Lebesgue function, and estimates the Lebesgue constant,
which measures the maximum magnitude of the potential error
of Lagrange polynomial interpolation.
-
legendre_exactness,
a Python code which
tests the exactness of quadrature rules for the Legendre
problem of integrating a function with density 1
over the interval [-1,+1].
-
legendre_polynomial,
a Python code which
evaluates the Legendre polynomial and associated functions.
-
legendre_product_polynomial,
a Python code which
defines Legendre product polynomials, creating a multivariate
polynomial as the product of univariate Legendre polynomials.
-
legendre_rule,
a Python code which
returns a Gauss-Legendre quadrature rule of given order.
-
legendre_shifted_polynomial,
a Python code which
evaluates the shifted Legendre polynomial, with the domain [0,1].
-
levenshtein_distance,
a Python code which
returns the Levenshtein distance between two strings.
-
levenshtein_matrix,
a Python code which
returns the Levenshtein distance matrix defined by two strings.
-
lindberg_exact,
a Python code which
evaluates the exact solution of the Lindberg ordinary differential
equations (ODE), a system that is extremely difficult to solve
accurately.
-
lindberg_ode,
a Python code which
sets up a system of 4 ordinary differential equations (ODE)
which are very stiff.
-
line_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected in the unit line segment.
-
line_grid,
a Python code which
computes a grid of points
over the interior of a line segment in 1D.
-
line_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the length of the unit line in 1D.
-
line_lines_packing,
an Octave code which
tries to randomly pack as many non-overlapping equal line segments
as possible into a larger line segment,
estimating Renyi's parking constant of 0.7475979202. This is an
example of random sequential adsorption (RSA).
-
line_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
over the length of the unit line in 1D.
-
line_ncc_rule,
a Python code which
computes a Newton Cotes Closed (NCC) quadrature rule,
using equally spaced points,
over the interior of a line segment in 1D.
-
linear_algebra,
a Python code which
carry out various linear algebra operations for matrices
stored in a variety of formats.
-
linpack_d,
a Python code which
factors and solves linear systems using real 64 bit arithmetic,
by Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart.
The matrix and vector data is assumed to be real.
-
linplus_c8,
a Python code which
carries out some linear algebra operations on complex matrices.
-
lissajous,
a Python code which
displays a Lissajous figure,
of the form x = sin ( a1 t + b1 ), y = sin ( a2 t + b2 ).
-
llsq,
a Python code which
solves the simple linear least squares (LLS) problem of finding the
formula of a straight line y=a*x+b which minimizes the root mean
square error to a set of N data points.
-
loadtxt_test,
a Python program which
calls the numpy() function loadtxt() to extract numeric data from a
text file.
-
lobatto_polynomial,
a Python code which
evaluates Lobatto polynomials, which are similar to Legendre
polynomials except that they are 0 at both endpoints.
-
local_min,
a Python code which
finds a local minimum of a scalar function of a scalar variable,
without the use of derivative information,
by Richard Brent.
-
local_min_rc,
a Python code which
finds a local minimum of a scalar function of a scalar variable,
without the use of derivative information,
using reverse communication (RC),
by Richard Brent.
-
locker_simulation,
a Python code which
simulates the locker problem, in which gym users have left
their wallets in lockers; someone has scrambled all the lockers,
and the gym users need a strategy that maximizes the chance
that everyone will find their wallet by searching a limited
number of lockers.
-
log_norm,
a Python code which
computes the logarithmic norm of a matrix, for norms 1, 2 and oo.
-
log_normal,
a Python code which
returns quantities related to the log normal Probability
Distribution Function (PDF).
-
log_normal_truncated_ab,
a Python code which
returns quantities related to the log normal Probability
Distribution Function (PDF) truncated to the interval [A,B].
-
logistic_bifurcation,
a Python code which
computes the bifurcation diagram for the logistic equation,
by John Cook.
-
logistic_exact,
a Python code which
evaluates an exact solution of the logistic equation,
an ordinary differential equation (ODE)
which models population growth in the face of a limited carrying capacity.
-
logistic_ode,
a Python code which
sets up and solves an ordinary differential equation (ODE)
which models population growth in the face of a limited
carrying capacity.
-
lorenz_ode,
a Python code which
sets up the Lorenz system
of ordinary differential equations (ODE),
creating graphics files using matplotlib().
-
lorenz_ode_sensitivity_test,
a Python code which
demonstrates sensitivity to initial conditions in the Lorenz system
of ordinary differential equations (ODE),
using an approach suggested by John D Cook.
-
lucas_lehmer,
a Python code which
determines whether a Mersenne number 2^n-1 is prime
by applying the Lucas-Lehmer test.
-
luhn,
a Python code which
computes the Luhn check digit for a string, or verifies a string,
as used for error detection in credit card numbers.
-
machar,
a Python code which
dynamically computes the values of
various machine characteristic constants,
by William Cody;
-
machine,
a Python code which
returns tabulated values of
the constants associated with computer arithmetic;
-
magic_matrix,
a Python code which
computes a magic matrix, for any odd order n, such that all rows and
columns have the same sum.
-
mandelbrot,
a Python code which
generates an image of the Mandelbrot set;
-
mandelbrot_orbit,
a Python code which
generates the Mandelbrot iterates arising from a single
starting point;
-
mario,
a Python code which
creates a sort of needlepoint image of Mario, as an array of
colored squares.
-
markov_text,
a Python code which
uses a Markov Chain Monte Carlo (MCMC) process to sample an existing
text file and create a new text that is randomized, but retains
some of the structure of the original one.
-
matrix_chain_brute,
a Python code which
finds the cost of the most efficient ordering to use when
multiplying a sequence of matrices, using brute force.
-
matrix_chain_dynamic,
a Python code which
finds the cost of the most efficient ordering to use when
multiplying a sequence of matrices, using dynamic programming..
-
matrix_exponential,
a Python code which
demonstrates some simple approaches to the problem of computing the
exponential of a matrix.
-
mcnuggets,
a Python code which
counts M(N), the number of ways a given number N of Chicken
McNuggets can be assembled, given that they are only available
in packages of 6, 9, and 20.
-
mcnuggets_diophantine,
a Python code which
uses Diophantine methods to find the ways a given number N of Chicken
McNuggets can be assembled, given that they are only available
in packages of 6, 9, and 20.
-
md,
a Python code which
carries out a molecular dynamics (MD) simulation, intended as
a starting point for implementing a parallel version.
-
mesh_boundary,
a Python code which
is given a mesh of a 2D region, formed by polygonal elements,
and determines a sequence of pairs of polygonal vertices that
define the boundary of the region.
-
mesh_etoe,
a Python code which
uses ETOV, the mesh element-to-vertex connectivity,
to construct ETOE, the element-to-element connectivity.
-
mgs,
a Python code which
is an obscure legacy code, which the student is encouraged to
study, understand, and document. This example is due to Diane O'Leary.
-
mhd_exact,
a Python code which
evaluates Hartmann's exact formula for a solution of the
magnetohydrodynamic (MHD) fluid flow equations in 2D.
-
middle_square,
a Python code which
implements the middle square algorithm for generating random integers.
This is a very early method, attributed to von Neumann, which actually
is deeply flawed, with short cycles.
-
midpoint,
a Python code which
solves one or more ordinary differential equations (ODE)
using the implicit midpoint method.
-
midpoint_adaptive,
a Python code which
solves one or more ordinary differential equations (ODE)
using the (implicit) midpoint method, with fsolve() solving
the implicit equation, and an adaptive time step.
Plots of the solution and timestep history are created.
-
midpoint_explicit,
a Python code which
solves one or more ordinary differential equations (ODE)
using the explicit midpoint method, also called the
modified Euler method.
-
midpoint_fixed,
a Python code which
solves one or more ordinary differential equations (ODE)
using the implicit midpoint method, using a simple fixed-point
iteration to solve the implicit equation.
-
monomial,
a Python code which
enumerates, lists, ranks, unranks and randomizes
multivariate monomials in a space of M dimensions, with total degree
less than N, equal to N, or in a given range.
-
monomial_value,
a Python code which
evaluates a monomial in M dimensions.
-
monopoly_matrix,
a Python code which
computes the adjacency and transition matrices for the game
of Monopoly.
-
monty_hall_simulation,
a Python code which
simulates the "Let's Make a Deal" game in which Monty Hall has
hidden a prize behind one of several doors, and the user wins
the prize if the correct door is selected.
-
mortality,
a Python code which
processes some sample mortality data.
-
movie_test,
a Python code which
creates a movie file from a sequence of solutions to a
partial differential equation, using matplotlib().
-
mxm,
a Python code which
sets up a matrix multiplication problem A=B*C of arbitrary size,
and compares the time required for IJK, IKJ, JIK, JKI, KIJ and KJI
orderings of the loops.
-
naca,
a Python code which
takes the parameters of certain NACA airfoils and returns the
coordinates of a sequence of points that outline the wing shape.
-
navier_stokes_2d_exact,
a Python code which
evaluates an exact solution to the incompressible time-dependent
Navier-Stokes equations (NSE) over an arbitrary domain in 2D.
-
navier_stokes_3d_exact,
a Python code which
evaluates an exact solution to the incompressible time-dependent
Navier-Stokes equations (NSE) over an arbitrary domain in 3D.
-
nearest_interp_1d,
a Python code which
interpolates a set of data using a piecewise constant interpolant
defined by the nearest neighbor criterion,
creating graphics files for processing by matplotlib().
-
neighbor_states,
a Python code which
creates a plot of the US based only on information about
pairs of US states which are neighbors.
-
neural_network,
a Python code which
illustrates the use of neural networks for deep learning,
using back propagation and stochastic gradient descent,
by Catherine Higham and Desmond Higham.
-
newton,
a Python code which
applies the Newton method to solve a single nonlinear equation f(x)=0.
-
newton_interp_1d,
a Python code which
finds a polynomial interpolant to data using Newton divided
differences.
-
ngrams,
a Python code which
analyzes a string or text against the observed frequency of
ngrams, that is, particular sequences of n letters, in English text.
-
normal,
a Python code which
implements a random number generator (RNG) for normally distributed
values;
-
normal_dataset,
a Python code which
creates a multivariate normal random dataset and writes it to a file.
-
normal_ode,
a Python code which
sets up an ordinary differential equation (ODE)
defining the normal probability density function (PDF).
-
normal01_multivariate_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected from an isotropic
standard normal distribution in M dimensions.
-
numgrid,
a Python code which
defines and numbers a subset of the nodes in a regular nxn grid
of the [-1,+1]x[-1,+1] unit square.
-
ode_euler,
a Python code which
applies the Euler method to estimate the solution
of an ordinary differential equation y'=f(x,y), over the
interval [a,b], with initial condition y(a)=ya, using n steps.
-
odefun_test,
a Python code which
uses odefun() from the multiple precision package mpmath()
to solve some simple ordinary differential equations (ODE).
-
oregonator_ode,
a Python code which
sets up the ordinary differential equations (ODE) for
the Oregonator, a model of the Belousov-Zhabotinsky
chemical reaction.
-
ornstein_uhlenbeck,
a Python code which
approximates solutions of the Ornstein-Uhlenbeck
stochastic differential equation (SDE)
using the Euler method, the Euler-Maruyama method,
and the Milstein method.
-
oscillator_ode,
a Python code which
sets up the highly oscillatory ordinary differential equation (ODE).
-
owen,
a Python code which
evaluates the Owen T function;
-
ozone_ode,
a Python code which
sets up a stiff system of four ordinary differential
equations (ODE) that simulate the daily variation in atmospheric
ozone concentration.
-
ozone2_ode,
a Python code which
sets up a stiff system of four ordinary differential
equations (ODE) that simulate the daily variation in atmospheric ozone
concentration. This version of the ozone ODE includes a nitrogen
oxide source term.
-
padua,
a Python code which
returns the coordinates of the 2D Padua points,
as well as interpolation weights or quadrature weights,
and images of the points graphics files.
-
pagerank,
a Python code which
illustrates the eigenvalue (power method) and surfer
(Markov Chain Monte Carlo MCMC)
approaches to ranking web pages.
-
pariomino,
a Python code which
considers pariominoes, which are polyominoes with a
checkerboard parity.
-
partition_brute,
a Python code which
uses a brute force algorithm to seek solutions of the partition problem,
splitting a set of integers into two subsets with equal sum.
-
partition_greedy,
a Python code which
uses a greedy algorithm to seek a solution of the partition problem,
in which a given set of integers is to be split into two groups whose
sums are as close as possible.
-
patterson_rule,
a Python code which
returns the points and weights of a 1D Gauss-Patterson quadrature
rule of order 1, 3, 7, 15, 31, 63, 127, 255 or 511.
-
pbma_io,
a Python code which
reads or writes ASCII Portable Bit Map (PBM) 2D graphics files;
-
pbmb_io,
a Python code which
reads or writes a binary Portable Bit Map (PBM) 2D graphics file;
-
pdflib,
a Python code which
evaluates Probability Density Functions (PDF)
and produces random samples from them,
including beta, binomial, chi, exponential, gamma, inverse chi,
inverse gamma, multinomial, normal, scaled inverse chi, and uniform.
-
pendulum_double_ode,
a Python code which
sets up the double pendulum ordinary differential equation (ODE).
-
pendulum_elastic_ode
a Python code which
sets up the ordinary differential equations (ODE) that represent
the behavior of a nonlinear elastic pendulum, with gravitational
force G, spring constant K, unstretched length L, and mass M.
-
pendulum_nonlinear_ode,
a Python code which
sets up the ordinary differential equations (ODE) that represent
a nonlinear model of the behavior
of a pendulum of length L under a gravitational force of strength G.
-
pendulum_ode,
a Python code which
sets up the ordinary differential equations (ODE) that represent
a linear model of the behavior
of a pendulum of length L under a gravitational force of strength G.
-
pentominoes,
a Python code which
forms or plots any of the 12 members of the pentomino family,
shapes formed from 5 adjacent squares.
-
perceptron,
a Python code which
demonstrates the calculation of a classifier of linearly separable data
using the perceptron algorithm.
-
percolation_simulation,
a Python code which
simulates a percolation system. A rectangular region is decomposed
into a grid of MxN squares. Each square may be porous or solid.
We are interested in a path of porous squares connecting the top and
bottom, or the left and right boundaries. The original code
was written by Ian Cooper.
-
permutation_distance,
a Python code which
estimates the expected value of the Ulam distance
between a pair of randomly selected permutations of the same order.
-
persistence,
a Python code which
demonstrates how to initialize, get, or set data stored
within a function, using static/persistent/saved/local memory.
-
pgma_io,
a Python code which
reads or writes ASCII Portable Gray Map (PGM) 2D graphics files;
-
pgmb_io,
a Python code which
reads or writes a binary Portable Gray Map (PGM) 2D graphics file;
-
pi_spigot,
a Python code which
produces any number of digits of the decimal expansion of pi.
-
pink_noise,
a Python code which
computes a pink noise signal obeying a 1/f power law.
-
pip3_test,
tests the Python installation program.
-
plasma_matrix,
a Python code which
sets up a matrix associated with a problem in plasma physics.
-
poisson_1d,
a Python code which
applies the finite difference method (FDM) to solve
a two point Poisson boundary value problem (BVP) in one
spatial dimension.
-
poisson_1d_multigrid,
a Python code which
applies the multigrid method to a discretized version of the
1D Poisson equation.
-
poisson_2d,
a Python code which
solves the Poisson equation in a rectangle,
using finite differences and Jacobi iteration.
-
poisson_simulation,
a Python code which
simulates a Poisson process in which events randomly occur with an
average waiting time of Lambda.
-
polar_ode,
a Python code which
sets up an ordinary differential equation (ODE)
whose variable is complex, and whose solution should be viewed
in a polar coordinate plot.
-
polpak,
a Python code which
evaluates a variety of mathematical functions, polynomials, and
sequences, including Bell, Benford, Bernoulli, Bernstein, Cardan,
Catalan, Charlier, Chebyshev, Collatz, Delannoy, Euler, Fibonacci,
Gegenbauer, Gudermannian, Harmonic, Hermite, Hofstadter,
Hypergeometric 2F1, Jacobi,
Krawtchouk, Laguerre, Lambert, Legendre, Lerch, Meixner, Mertens,
Moebius, Motzkin, Phi, Stirling Number, Tau, Tribonacci, Zernike.
-
polygon,
a Python code which
computes properties of an arbitrary polygon in the plane, defined
by a sequence of vertices, including interior angles, area, centroid,
containment of a point, convexity, counter clockwise ordering, diameter,
distance to a point, inradius, lattice area, nearest point in set,
outradius, uniform sampling, and triangulation.
-
polygon_average,
a Python code which
demonstrates a process of repeatedly averaging and normalizing the
vertices of a polygon, illustrating a property of the power method.
-
polygon_distance,
a Python code which
computes the expected value of the distance
between a pair of points randomly selected from the interior of
a polygon in 2D.
-
polygon_grid,
a Python code which
generates a grid of points
over the interior of a polygon in 2D.
-
polygon_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of a polygon in 2D.
-
polygon_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
over the interior of a polygon in 2D.
-
polygon_triangulate,
a Python code which
triangulates a possibly nonconvex polygon in 2D,
and which can use gnuplot() to display the external edges and
internal diagonals of the triangulation.
-
polynomial,
a Python code which
adds, multiplies, differentiates, evaluates and prints multivariate
polynomials in a space of M dimensions.
-
polynomial_conversion,
a Python code which
converts representations of a polynomial between monomial, Bernstein,
Chebyshev, Gegenbauer, Hermite, Laguerre and Legendre forms.
-
polynomial_multiply,
a Python code which
multiplies two polynomials p(x) and q(x).
-
polynomial_resultant,
a Python code which
computes the resultant R of univariate polynomials P and Q.
-
polynomial_resultant_symbolic,
a Python code which
uses the symbolic package sympy() to
compute the resultant R of univariate polynomials P and Q.
-
polynomial_root_bound,
a Python code which
computes the Cauchy bound on the magnitude of all roots
of a polynomial with complex coefficients.
-
polynomials,
a Python code which
defines multivariate polynomials over rectangular domains, for
which certain information is to be determined, such as the maximum
and minimum values.
-
polyomino_parity,
a Python code which
uses parity considerations to determine whether a given set of
polyominoes can tile a specified region.
-
polyominoes,
a Python code which
manipulates polyominoes and tilings.
-
porous_medium_exact,
a Python code which
returns an exact solution of the porous medium equation (PME),
dudt=Del^2(u^m), a partial differential equation (PDE) related
to the diffusion equation, based on the Barenblatt solution.
-
power_method,
a Python code which
carries out the power method for finding a dominant eigenvalue
and its eigenvector.
-
ppma_io,
a Python code which
reads or writes an ASCII Portable Pixel Map (PPM) 2D graphics file;
-
ppmb_io,
a Python code which
reads or writes a binary Portable Pixel Map (PPM) 2D graphics file;
-
praxis,
a Python code which
minimizes a scalar function of several variables, without
requiring derivative information,
by Richard Brent.
-
predator_prey_ode,
a Python code which
sets up the ordinary differential equations (ODE)
for a Lotka-Volterra predator prey system,
for which a limit cycle exists.
-
predator_prey_ode_period,
a Python code which
sets up the ordinary differential equations (ODE)
for a Lotka-Volterra predator prey system,
in order to estimate the period of the limit cycle.
-
prime,
a Python code which
counts the number of primes between 1 and N,
intended as a starting point for a parallel version.
-
prime_factors,
a Python code which
returns a list of the prime factors of an integer.
-
prime_fermat,
a Python code which
applies Fermat's primality test to an integer n, which always
correctly identifies primes, but sometimes also accepts nonprimes.
Nonetheless, the test is useful for weeding out most nonprimes.
The accuracy of the test can be improved by running it for several
bases.
-
prime_miller_rabin,
a Python code which
applies the Miller-Rabin primality test to an integer n, which always
correctly identifies primes, but sometimes also accepts nonprimes.
-
prime_pi,
a Python code which
evaluates Pi(n), the number of primes less than or equal
to an integer n.
-
prime_plot,
a Python code which
displays a box plot of the prime and composite numbers.
-
prism_jaskowiec_rule,
a Python code which
returns symmetric quadrature rules, with exactness up to total
degree 20, over the interior of a prism with triangular base,
by Jan Jaskowiec, Natarajan Sukumar.
-
prism_witherden_rule,
a Python code which
returns a symmetric Witherden quadrature rule for a prism with
triangular base, with exactness up to total degree 10.
-
prob,
a Python code which
evaluates, samples, inverts, and characterizes a number of
Probability Density Functions (PDF)
and Cumulative Density Functions (CDF), including anglit, arcsin,
benford, birthday, bernoulli, beta_binomial, beta, binomial, bradford,
burr, cardiod, cauchy, chi, chi squared, circular, cosine, deranged,
dipole, dirichlet mixture, discrete, empirical, english sentence and
word length, error, exponential, extreme values, f, fisk,
folded normal, frechet, gamma, generalized logistic, geometric,
gompertz, gumbel, half normal, hypergeometric, inverse gaussian,
laplace, levy, logistic, log normal, log series, log uniform,
lorentz, maxwell, multinomial, nakagami, negative binomial, normal,
pareto, planck, poisson, power, quasigeometric, rayleigh,
reciprocal, runs, sech, semicircular, student t, triangle, uniform,
von mises, weibull, zipf.
-
pwl_interp_1d,
a Python code which
interpolates a set of data using a piecewise linear function in 1D.
-
pwl_interp_2d,
a Python code which
interpolates a set of data using a piecewise linear function in 2D.
-
py_test,
a Python code which
illustrates various features of Python programming.
-
pyramid_exactness,
a Python code which
tests the exactness of a quadrature rule
over the interior of the unit pyramid in 3D.
-
pyramid_felippa_rule,
a Python code which
returns a Felippa quadrature rule for approximating integrals
over the interior of a pyramid in 3D.
-
pyramid_grid,
a Python code which
computes a grid of points
over the interior of the unit pyramid in 3D;
-
pyramid_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit pyramid in 3D.
-
pyramid_jaskowiec_rule,
a Python code which
returns quadrature rules, with exactness up to total degree 20,
over the interior of a pyramid in 3D,
by Jan Jaskowiec, Natarajan Sukumar.
-
pyramid_monte_carlo,
a Python code which
applies a Monte Carlo (MC) method to estimate integrals of a function
over the interior of the unit pyramid in 3D;
-
pyramid_rule,
a Python code which
computes a conical product quadrature rule
over the interior of the unit pyramid in 3D.
-
pyramid_witherden_rule,
a Python code which
returns a Witherden quadrature rule, with exactness up to total
degree 10, over the interior of a pyramid.
-
python_combinatorics,
a Python code which
considers a variety of problems in combinatorics involving
counting, combinations, permutations, and so on.
-
python_distance,
a Python code which
estimates the typical distance between a pair of points
randomly selected from the surface or interior of a
geometric object such as a circle, disk, sphere, cube.
-
python_exact,
a Python code which
evaluates exact solutions to a few selected examples of
ordinary differential equations (ODE) and partial differential
equations (PDE).
-
python_grid,
a Python code which
generates a regular grid of points inside a variety of regions
in one, two, three or many dimensions.
-
python_import,
a Python code which
demonstrates how a Python function can use the import function to
access functions from a library that is in a separate directory.
-
python_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the surface or interior of some geometric object,
including a line, quadrilateral, box, circle, disk, sphere,
ball and others.
-
python_intrinsics_test,
a Python code which
demonstrates some of the intrinsic functions in the Python language.
-
python_mistake,
a Python code which
illustrates mistakes caused by Python,
encouraged by Python, or made difficult to spot because of Python.
-
python_monte_carlo,
a Python code which
uses Monte Carlo sampling to estimate areas and integrals.
-
python_plots,
a Python code which
uses plotting to illustrate a mathematical structure, such as
an iterative map, a fractal, a curve or surface.
-
python_polynomial,
a Python code which
analyzes a variety of polynomial families, returning the polynomial
values, coefficients, derivatives, integrals, roots, or other
information.
-
python_random_test,
a Python code which
demonstrates random number generation.
-
python_rule,
a Python code which
computes a quadrature rule which
estimates the integral of a function f(x), which might be defined over
a one dimensional region (a line) or more complex shapes such as
a circle, a triangle, a quadrilateral, a polygon, or a higher
dimensional region, and which might include an associated weight
function w(x).
-
python_simulation,
a Python code which
uses simulation to study card games, contests, and other processes
which have a random element. Usually, the purpose is to try to
predict the average behavior of the system over many trials.
-
pytorch_test,
a Python code which
illustrates certain features of the pytorch() programming library,
which is used for applications in machine learning and
deep learning.
-
python_ode,
a Python code which
sets up various systems of ordinary differential equations (ODE).
-
python_ode_solver,
a Python code which
solves one or more differential equations (ODE) using a method of a
particular order, either explicit or implicit. Some methods require
a nonlinear equation solver. Some methods used a fixed stepsize,
while others adapt the stepsize based on an error estimate.
-
quad_mpi,
a Python code which
approximates an integral using a quadrature rule,
carried out in parallel using MPI and MPI4PY.
-
quad_rule,
a Python code which
implements rules for approximate integration, or quadrature,
in one dimension;
-
quad_serial,
a Python code which
applies a quadrature rule to estimate an integral,
intended as a starting point for parallelization exercises.
-
quad2d,
a Python code which
estimates an integral over a 2D rectangle using quadrature,
intended as the starting point for program optimization or parallelization.
-
quadex_ode
a Python code which
sets up a stiff ordinary differential equation (ODE), whose
exact solution is a parabola, but for which errors grow
exponentially.
-
quadrilateral,
a Python code which
carries out geometric calculations on quadrilaterals, including
angles, area, distances, nearest point, point containment, perimeter,
and random generation.
-
quadrilateral_witherden_rule,
a Python code which
returns a symmetric Witherden quadrature rule for the quadrilateral,
with exactness up to total degree 21.
-
quasiperiodic_ode,
a Python code which
sets up a system of
ordinary differential equations (ODE) for a problem with a
quasiperiodic solution.
-
quaternions,
a Python code which
carries out some simple arithmetic operations for quaternions.
-
r83,
a Python code which
contains linear algebra routines for r83 matrices,
in real, 64 bit, tridiagonal 3xN format.
-
r83_np,
a Python code which
contains linear algebra routines for r83_np matrices
(real, 64 bit, tridiagonal 3xN format, nonpivoting factorization).
-
r83p,
a Python code which
contains linear algebra routines for r83p matrices
(real, 64 bit, tridiagonal periodic format).
-
r83s,
a Python code which
contains linear algebra routines for r83s matrices
(real, 64 bit, tridiagonal scalar format).
-
r83t,
a Python code which
contains linear algebra routines for r83t matrices
(real, 64 bit, tridiagonal Mx3 format).
-
r83v,
a Python code which
contains linear algebra routines for r83v matrices
(real, 64 bit, tridiagonal three vector format).
-
r85,
a Python code which
contains linear algebra routines for r85 matrices
(real, 64 bit, pentadiagonal format).
-
r8bb,
a Python code which
contains linear algebra routines for r8bb matrices
(real, 64 bit, border banded format).
-
r8blt,
a Python code which
contains linear algebra routines for r8blt matrices
(real, 64 bit, band lower triangular format).
-
r8bto,
a Python code which
contains linear algebra routines for r8bto matrices
(real, 64 bit, block Toeplitz format).
-
r8but,
a Python code which
contains linear algebra routines for r8but matrices
(real, 64 bit, band upper triangular format).
-
r8cb,
a Python code which
contains linear algebra routines for r8cb matrices
(real, 64 bit, Compressed Band format).
-
r8cbb,
a Python code which
contains linear algebra routines for r8cbb matrices
(real, 64 bit, Compressed Border Banded format).
-
r8ccs,
a Python code which
contains linear algebra routines for r8ccs matrices:
real, 64 bit, Compressed Column Storage (CCS) format.
-
r8ci,
a Python code which
contains linear algebra routines for r8ci matrices
(real, 64 bit, circulant format).
-
r8col,
a Python code which
contains linear algebra routines for r8col matrices, that is,
a real MxN array, considered as N column vectors,
each of length M. The data may be thought of as a matrix of
multiple columns, and many operations will be carried out columnwise.
-
r8crs,
a Python code which
contains linear algebra routines for r8crs matrices:
real, 64 bit, Compressed Row Storage (CRS) format.
-
r8gb,
a Python code which
contains linear algebra routines for r8gb matrices
(real, 64 bit, General Banded format).
-
r8gd,
a Python code which
contains linear algebra routines for r8gd matrices
(real, 64 bit, general diagonal format).
-
r8ge,
a Python code which
contains linear algebra routines for r8ge matrices
in real, 64 bit, general format.
-
r8lib,
a Python code which
contains many utility routines, using 64 bit precision real (R8)
arithmetic.
-
r8lt,
a Python code which
contains linear algebra routines for r8lt matrices,
in real, 64 bit, Lower Triangular format.
-
r8ltt,
a Python code which
contains linear algebra routines for r8ltt matrices
(real, 64 bit, lower triangular Toeplitz format).
-
r8ncf,
a Python code which
contains linear algebra routines for r8ncf matrices
(real, 64 bit, nonsymmetric coordinate format).
-
r8pbl,
a Python code which
contains linear algebra routines for r8pbl matrices
(real, 64 bit, symmetric positive definite (SPD) band lower format).
-
r8pbu,
a Python code which
contains linear algebra routines for r8pbu matrices
(real, 64 bit, symmetric positive definite (SPD) band upper format).
-
r8po,
a Python code which
contains linear algebra routines for r8po matrices
(real, 64 bit, symmetric positive definite (SPD) format).
-
r8poly,
a Python code which
operates on real polynomials, including evaluation, differentiation,
integration, multiplication, synthetic division, shifting the
base, computing a power, taking the norm. It also defines
Chebyshev, Lagrange and Legendre polynomials.
-
r8pp,
a Python code which
contains linear algebra routines for r8pp matrices
(real, 64 bit, symmetric positive definite (SPD) packed format).
-
r8ri,
a Python code which
contains linear algebra routines for r8ri matrices
(real, 64 bit, row indexed format).
-
r8row,
a Python code which
contains linear algebra routines for r8row matrices, that is,
a real MxN array, considered as M row vectors,
each of length N. The data may be thought of as a matrix of
multiple rows, and many operations will be carried out rowwise.
-
r8sd,
a Python code which
contains linear algebra routines for r8sd matrices
(real, 64 bit, symmetric diagonal format).
-
r8sm,
a Python code which
contains linear algebra routines for r8sm matrices
(real, 64 bit, Sherman-Morrison A-u*v' format).
-
r8sr,
a Python code which
carries out linear algebra operations for r8sr matrices
(real, 64 bit, diagonal + compressed row offdiagonal format).
-
r8ss,
a Python code which
carries out linear algebra operations for r8ss matrices
(real, 64 bit, symmetric skyline format).
-
r8st,
a Python code which
contains linear algebra routines for r8st matrices,
in real, 64 bit, Sparse Triplet (ST) format.
-
r8sto,
a Python code which
contains linear algebra routines for r8sto matrices
(real, 64 bit, symmetric Toeplitz N format).
-
r8to,
a Python code which
contains linear algebra routines for r8to matrices
(real, 64 bit, Toeplitz 2*N-1 format).
-
r8ut,
a Python code which
contains linear algebra routines for r8ut matrices,
in real, 64 bit, Upper Triangular format.
-
r8utp,
a Python code which
carries out linear algebra operations on r8utp matrices,
real 64 bit, Upper Triangular Packed format.
-
r8utt,
a Python code which
contains linear algebra routines for r8utt matrices
(real, 64 bit, upper triangular Toeplitz format).
-
r8vm,
a Python code which
contains linear algebra routines for r8vm matrices
(real, 64 bit, vandermonde format).
-
randlc,
a Python code which
implements a random number generator (RNG)
used by the NAS Benchmark programs.
-
random_data,
a Python code which
uses a random number generator (RNG) to sample points for
various probability distributions, spatial dimensions, and
geometries, including the M-dimensional cube, ellipsoid,
simplex and sphere.
-
random_matrix_eigenvalues,
a Python code which
demonstrates how, for certain probability density functions (PDF),
a symmetric matrix with entries sampled from that PDF will have
eigenvalues distributed according to the Wigner semicircle
distribution.
-
random_sorted,
a Python code which
generates vectors of random values which are already sorted.
-
random_walk_1d_simulation,
a Python code which
simulates a random walk in a 1-dimensional region.
-
random_walk_2d_simulation,
a Python code which
simulates a random walk in a 2-dimensional region.
-
random_walk_2d_avoid_simulation,
a Python code which
simulates a self-avoiding random walk in a 2-dimensional region.
-
random_walk_3d_simulation,
a Python code which
simulates a random walk in a 3-dimensional region.
-
ranlib,
a Python code which
produces random samples from Probability Density Functions (PDF),
including Beta, Chi-square Exponential, F, Gamma, Multivariate normal,
Noncentral chi-square, Noncentral F, Univariate normal,
random permutations, Real uniform, Binomial, Negative Binomial,
Multinomial, Poisson and Integer uniform,
by Barry Brown and James Lovato.
-
rbf_interp_1d,
a Python code which
defines and evaluates
radial basis function (RBF) interpolants to 1D data.
-
rbf_interp_2d,
a Python code which
defines radial basis function (RBF) interpolants to 2D data.
-
reaction_ode,
a Python code which
sets up the ordinary differential equations (ODE) which
model a simple chemical reaction A+B --k--> C.
-
reaction_twoway_ode,
a Python code which
sets up the ordinary differential equations (ODE) which
model a two-way chemical reaction between species W1 and W2.
-
reaction_twoway_odefun,
a Python code which
uses the multiple-precision arithmetic package mpmath() to
approximate the solution of the ordinary differential equations (ODE)
which model a two-way chemical reaction between species W1 and W2.
-
reactor simulation,
a Python code which
is a simple Monte Carlo simulation of the shielding effect of a
slab of a certain thickness in front of a neutron source. This
program was provided as an example with the book "Numerical
Methods and Software."
-
rectangle_distance,
a Python code which
estimates the distribution and expected value of the distance between
two points picked uniformly at random within a rectangle.
-
rigid_body_ode,
a Python code which
sets up the ordinary differential equations (ODE)
representing the Euler equations for a rigid body with three
unequal moments of inertia, originally proposed by Fred Krogh.
-
ripple_ode,
a Python code which
sets up an ordinary differential equation (ODE)
whose family of solutions start as ripples and end as hyperbolas.
-
risk_matrix,
a Python code which
returns the transition and adjacency matrix for the game of RISK.
-
rk1,
a Python code which
solves one or more ordinary differential equations (ODE)
using an explicit Runge-Kutta method of order 1, usually known
as Euler's explicit method.
-
rk1_implicit,
a Python code which
solves one or more ordinary differential equations (ODE)
using the Runge-Kutta order 1 implicit method, with a version of
fsolve() handling the associated nonlinear equation,
and using a fixed time step. This method is often called the
backward Euler method.
-
rk12,
a Python code which
solves an ordinary differential equation (ODE) using a Runge-Kutta (RK)
method of order 2, estimating the local error with a Runge-Kutta method
of order 1.
-
rk2,
a Python code which
solves one or more ordinary differential equations (ODE)
using an explicit Runge-Kutta method of order 2,
also known as Heun's method, the modified Euler method,
or the explicit midpoint method.
-
rk2_implicit,
a Python code which
solves one or more ordinary differential equations (ODE)
using the Runge-Kutta order 2 implicit method, using fsolve()
to solve the implicit equation, and using a fixed time step.
rk2_implicit() is also known as the implicit midpoint method.
-
rk23,
a Python code which
applies Runge-Kutta (RK) solvers of order 2 and 3 to a system of
ordinary differential equations (ODE);
-
rk34,
a Python code which
applies Runge-Kutta (RK) solvers of order 3 and 4 to a system of
ordinary differential equations (ODE);
-
rk4,
a Python code which
applies the fourth order Runge-Kutta (RK) algorithm to estimate the
solution of an ordinary differential equation (ODE)
at the next time step.
-
rk45,
a Python code which
applies Runge-Kutta (RK) solvers of order 4 and 5 to a system of
ordinary differential equations (ODE);
-
rkf45,
a Python code which
implements the Runge-Kutta-Fehlberg (RKF) solver for the approximate
solution of an ordinary differential equation (ODE) system.
-
rng_cliff,
a Python code which
computes a sequence of values from the Cliff random number
generator (RNG).
-
rnglib,
a Python code which
implements a random number generator (RNG) with splitting facilities,
allowing multiple independent streams to be computed,
by L'Ecuyer and Cote.
-
robertson_ode,
a Python code which
sets up a system of three nonlinear stiff ordinary
differential equations (ODE) characterizing an autocatalytic
chemical reaction.
-
roessler_ode,
a Python code which
sets up the Roessler system of ordinary differential
equations (ODE).
-
root_rc,
a Python code which
seeks a solution of a scalar nonlinear equation f(x)=0,
using reverse communication (RC), by Gaston Gonnet.
-
roots_rc,
a Python code which
seeks solutions of a system of nonlinear equations,
using reverse communication (RC), by Gaston Gonnet.
-
rot13,
a Python code which
makes a copy of a file which has
been encoded using the ROT13 coding and a ROT5 coding for digits.
-
roulette_simulation,
a Python code which
simulates the spinning of a roulette wheel and the evaluation of
certain common roulette bets.
-
row_echelon_integer,
a Python code which
carries out the exact computation of the integer row echelon form
(IREF) and integer reduced row echelon form (IRREF) of an integer
matrix.
-
rubber_band_ode,
a Python code which
sets up a set of ordinary differential equations (ODE)
describing a mass suspended by a spring and rubber band, which
exhibit chaotic behavior.
-
rucklidge_ode,
a Python code which
sets up and solves the Rucklidge ordinary differential equation (ODE),
a model of double convection which embodies a transition to chaos.
-
sammon_data,
a Python code which
generates six examples of M dimensional datasets for cluster analysis.
-
satisfy_brute,
a Python code which
uses brute force to find all assignments of values to a set of
logical variables which make a complicated logical statement true.
-
sawtooth_ode,
a Python code which
sets up an ordinary differential equation (ODE) driven
by a right hand side which is a sawtooth function, periodic,
discontinuous, piecewise linear.
-
search_mpi,
a Python code which
searches integers between A and B for a solution J such that F(J)=C,
carried out in parallel using MPI and MPI4PY.
-
search_serial,
a Python code which
searches integers between A and B for a solution J such that F(J)=C,
intended as a starting point for parallelization exercises.
-
sensitive_ode,
a Python code which
sets up a second order ordinary differential equation (ODE)
which exhibits sensitive dependence on the initial condition.
-
set_theory,
a Python code which
implements set theory operations such as union, intersection,
complement, symmetric difference.
-
sftpack,
a Python code which
implements the slow Fourier transform (SFT), intended as a teaching
tool and comparison with the fast Fourier transform (FFT).
-
shallow_water_1d,
a Python code which
simulates the evolution of a 1D fluid governed by the
time-dependent shallow water equations.
-
shepard_interp_1d,
a Python code which
defines and evaluates Shepard interpolants to 1D data,
based on inverse distance weighting.
-
sigmoid_derivative,
a Python code which
evaluates derivatives of any order for the sigmoid function
s(x)=1/(1+exp(-x)).
-
simplex_coordinates,
a Python code which
computes the Cartesian coordinates of the vertices of
a regular simplex in M dimensions.
-
simplex_gm_rule,
a Python code which
defines Grundmann-Moeller quadrature rules
over the interior of a triangle in 2D, a tetrahedron in 3D, or
over the interior of the simplex in M dimensions.
-
simplex_grid,
a Python code which
generates a regular grid of points
over the interior of an arbitrary simplex in M dimensions.
-
simplex_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit simplex in M dimensions.
-
simplex_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate an integral
over the interior of the unit simplex in M dimensions.
-
sine_gordon_exact,
a Python code which
returns an exact solution of the Sine-Gordon equation,
a partial differential equation (PDE) of the form uxy=sin(u).
-
sine_transform,
a Python code which
demonstrates simple properties of the discrete sine transform (DST).
-
sir_ode,
a Python code which
sets up the ordinary differential equations (ODE) which
simulate the spread of a disease
using the Susceptible/Infected/Recovered (SIR) model.
-
sir_simulation,
a Python code which
simulates the spread of a disease through a hospital room
of M by N beds, using the Susceptible/Infected/Recovered
(SIR) model.
-
sling_ode,
an Octave code which
sets up a system of ordinary differential equations
(ODE) for which the exact circular solution can only be approximated
for a short interval before it decays to zero.
-
snakes_and_ladders,
a Python code which
provides some tools for studying the game of Snakes and Ladders.
-
snakes_and_ladders_simulation,
a Python code which
simulates a one-player game of Snakes and Ladders, to
produce histograms of the count, PDF and CDF estimates for the
length of a one-player game.
-
snakes_matrix,
a Python code which
returns the transition matrix for the game of
Snakes and Ladders.
-
sncndn,
a Python code which
evaluates the Jacobi elliptic functions sn(u,m), cn(u,m),
and dn(u,m).
-
sobol,
a Python code which
computes elements of a Sobol Quasi Monte Carlo (QMC) sequence.
-
solve,
a Python code which
demonstrates how Gauss elimination can be used to solve a
linear system A*x=b.
-
solve_bvp_test,
a Python code which
calls scipy.integrate.solve_bvp(), which
solves boundary value problems (BVP) in one spatial dimension.
-
sort_rc,
a Python code which
sorts a list of any kind of objects,
using reverse communication (RC).
-
sortrows,
a Python code which
lexically sorts the rows of an array,
in a similar fashion to the MATLAB sortrows() function.
-
sparse_test,
a Python code which
tests the scipy.sparse() functions for creating sparse matrices
and carrying out linear algebraic functions on them;
-
sphere_distance,
a Python code which
computes the expected value of the distance
between a pair of points randomly selected from the surface of
the unit sphere in 3D.
-
sphere_fibonacci_grid,
a Python code which
uses a Fibonacci spiral to create a grid of points
on the surface of the unit sphere in 3D.
-
sphere_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the surface of the unit sphere in 3D.
-
sphere_llq_grid,
a Python code which
uses longitudes and latitudes to create grids of points,
lines, and quadrilaterals
on the surface of the unit sphere in 3D.
-
sphere_llt_grid,
a Python code which
uses longitudes and latitudes to create grids of points,
lines, and triangles
on the surface of the unit sphere in 3D.
-
sphere_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
on the surface of the unit sphere in 3D.
-
sphere_positive_distance,
a Python code which
computes the expected value of the distance
between a pair of points randomly selected on the surface of the
unit positive sphere in 3D.
-
spiral_exact,
a Python code which
computes a 2D velocity vector field that is an exact solution
of the continuity equation.
-
spiral_pde,
a Python code which
solves a pair of reaction-diffusion partial differential equations
(PDE) over a rectangular domain with periodic boundary condition,
whose solution is known to evolve into a pair of spirals.
-
spring_ode,
a Python code which
sets up a system of ordinary differential equations (ODE)
for the motion of a spring with mass m, damping b, and stiffness k.
-
spring_double_ode,
a Python code which
sets up a system of ordinary differential equations (ODE) for
a system in which a mass is connected by a spring to a mass
connected by a spring to a fixed support.
-
spring_sweep_ode,
a Python code which
computes a grid of solutions to a parameterized system of
ordinary differential equations (ODE) that represent
the motion of a spring with mass m, damping b, and stiffness k.
-
square_distance,
a Python code which
considers the problem of describing the typical value of the distance
between a pair of points randomly selected inside the unit square.
-
square_grid,
a Python code which
computes a grid of points
over the interior of a square in 2D.
-
square_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit square or symmetric unit square in 2D.
-
square_minimal_rule,
a Python code which
returns "almost minimal" quadrature rules,
with exactness up to total degree 55,
over the interior of the symmetric square in 2D,
by Mattia Festa and Alvise Sommariva.
-
square_monte_carlo,
a Python code which
applies a Monte Carlo method to estimate the integral of a function
over the interior of the unit square in 2D.
-
square_surface_distance,
a Python code which
estimates the expected value of the distance
between a pair of points randomly selected
on the surface of the unit square.
-
square_symq_rule,
a Python code which
returns symmetric quadrature rules,
with exactness up to total degree 20,
over the interior of the square in 2D,
by Hong Xiao and Zydrunas Gimbutas.
-
squircle_ode,
a Python code which
sets up a system of
ordinary differential equations (ODE) for a pair of functions that
generalize the sine and cosine, and whose phase portrait is a
squircle, a sort of squared circle.
-
st_io
a Python code which
reads and writes sparse linear systems
stored in the Sparse Triplet (ST) format.
-
st_to_ccs,
a Python code which
converts sparse matrix data from Sparse Triplet (ST) format
to Compressed Column Storage (CCS) format;
-
stetter_ode,
a Python code which
sets up an ordinary differential equation (ODE) for
which a specific time step sequence causes the implicit
trapezoidal method to be unstable, while the implicit midpoint
method will be stable. Note that the right hand side function
f(t,y) is periodic, discontinuous, and piecewise linear.
-
stiff_ode,
a Python code which
sets up a stiff ordinary differential equation (ODE).
-
stochastic_diffusion,
a Python code which
implements several versions of a stochastic diffusivity coefficient.
-
stokes_2d_exact,
a Python code which
evaluates exact solutions to the incompressible steady
Stokes equations over the unit square in 2D.
-
subset,
a Python code which
enumerates, generates, randomizes, ranks and unranks combinatorial
objects including combinations, compositions, Gray plt., index sets,
partitions, permutations, polynomials, subsets, and Young tables.
Backtracking routines are included to solve some combinatorial
problems.
-
subset_distance,
a Python code which
estimates the expected value of the Hamming distance
between a pair of randomly selected subsets of an M set.
-
subset_sum,
a Python code which
seeks solutions of the subset sum problem, in which it is desired
to find a subset of integers which has a given sum.
-
subset_sum_backtrack,
a Python code which
uses backtracking to find solutions of the subset sum problem,
in which it is desired to find a subset of integers
which has a given sum.
-
subset_sum_brute,
a Python code which
uses brute force to find solutions of the subset sum problem,
in which it is desired to find a subset of integers which has a given sum.
-
subset_sum_swap,
a Python code which
uses swapping to try to improve an initial estimated solution
of the subset sum problem, which seeks a subset of a set of integers
which has a given sum. Even when an exact solution exists, this
approach often only finds an approximate solution.
-
svd_circle,
a Python code which
analyzes a linear map of the unit circle caused by an arbitrary
2x2 matrix A, using the singular value decomposition (SVD).
-
svd_lls,
a Python code which
uses the singular value decomposition (SVD) to construct and
plot the best affine and linear relationships in the sense of
least square, between two vectors of data.
-
svd_powers,
a Python code which
applies singular value decomposition (SVD) analysis to a set of
powers A(i,j) = x(i)^j.
-
svd_snowfall,
a Python code which
reads a file containing historical snowfall data and
analyzes the data with the Singular Value Decomposition (SVD),
displaying the results using gnuplot().
-
svd_sphere,
a Python code which
analyzes a linear map of the unit sphere caused by an arbitrary
3x3 matrix A, using the singular value decomposition (SVD).
-
svd_test,
a Python code which
demonstrates the calculation of
the singular value decomposition (SVD) and some of its properties;
-
svd_truncated_test,
a Python code which
calls the "economy" version of the
Singular Value Decomposition (SVD)
of an M by N rectangular matrix, in cases where M is less than N
or N is less than M.
-
sympy_test,
a Python code which
uses the sympy() library, which
is a symbolic mathematics package which, given a symbolic formula,
can evaluate it, differentiate it, integrate it, plot it, compute
Taylor series approximations, and many other operations.
-
table_io,
a Python code which
reads and writes files.
-
task_division,
a Python code which
implements a simple procedure for smoothly dividing T tasks among
P processors; such a method can be useful in MPI and other parallel
environments, particularly when T is not an exact multiple of P,
and when the processors can be indexed starting from 0 or from 1.
-
tennis_matrix,
a Python code which
computes the transition matrix for a game of tennis, which
has 17 distinct states.
-
test_eigen,
a Python code which
implements test matrices for eigenvalue analysis.
-
test_int,
a Python code which
implements test problems for
approximate integration (quadrature) in one dimension.
-
test_interp,
a Python code which
defines test problems for interpolation,
provided as a set of (x,y(x)) data.
-
test_interp_1d,
a Python code which
defines test problems for interpolation of data y(x),
which depends on a 1D argument.
-
test_interp_2d,
a Python code which
defines test problems for interpolation of data z(x,y),
which depends on a 2D argument.
-
test_lls,
a Python code which
implements linear least squares test problems of the form A*x=b.
-
test_matrix,
a Python code which
defines test matrices for which the condition number, determinant,
eigenvalues, eigenvectors, inverse, null vectors, P*L*U factorization
or linear system solution are known. Examples include the
Fibonacci, Hilbert, Redheffer, Vandermonde, Wathen and Wilkinson
matrices.
-
test_matrix_exponential,
a Python code which
defines a set of test cases for computing the matrix exponential.
-
test_min,
a Python code which
implements test problems for
minimization of a scalar function of a scalar variable.
-
test_nonlin,
a Python code which
implements test problems for the solution
of systems of nonlinear equations.
-
test_optimization,
a Python code which
implements test problems for optimization
of a scalar function of several variables,
as described by Molga and Smutnicki.
-
test_values,
a Python code which
supplies test values of various mathematical functions, including
Abramowitz, AGM, Airy, Bell, Bernoulli, Bessel, Beta, Binomial,
Bivariate Normal, Catalan, Cauchy, Chebyshev, Chi Square, Clausen,
Clebsch Gordan, Collatz, Cosine integral, Dawson, Debye, Dedekind,
dilogarithm, Dixon elliptic functions, Exponential integral, Elliptic,
Error, Euler, Exponential integral, F probability, Fresnel, Frobenius,
Gamma, Gegenbauer, Goodwin, Gudermannian, Harmonic, Hermite,
Hypergeometric 1F1, Hypergeometric 2F1, inverse trigonometic,
Jacobi Elliptic functions sn(), cn(), dn(), the Julian Ephemeris Date,
Kelvin, Laguerre, Lambert W, Laplace, Legendre, Lerch, Lobachevsky,
Lobatto, Logarithmic integral, Log normal, McNugget numbers,
Mersenne primes, Mertens, Mittag-Leffler, Moebius,
Multinomial, Negative binomial, Nine J, Normal, Omega, Owen, Partition,
Phi, Pi, Poisson, Polylogarithm, Polynomial Resultant, Polyomino, Prime,
Psi, Rayleigh, Hyperbolic Sine integral, Sigma, Sine Power integral,
Sine integral, Six J, Sphere area, Sphere volume, Spherical harmonic,
Stirling, Stromgen, Struve, Student, Subfactorial, Student probability,
Three J, Transport, Trigamma, Truncated normal, van der Corput, von Mises,
Weibull, Wright Omega, Zeta.
-
test_zero,
a Python code which
defines some functions f(x) suitable for testing
software that solves f(x)=0;
-
tester,
a BASH script which runs the test codes.
-
tetrahedron,
a Python code which
carries out geometric calculations involving a general tetrahedron,
including solid and facial angles, face areas,
point containment, distances to a point, circumsphere and insphere,
measures of shape quality, centroid, barycentric coordinates,
edges and edge lengths, random sampling, and volumes.
-
tetrahedron_arbq_rule,
a Python code which
returns quadrature rules,
with exactness up to total degree 15,
over the interior of a tetrahedron in 3D,
by Hong Xiao and Zydrunas Gimbutas.
-
tetrahedron_exactness,
a Python code which
tests the exactness of a quadrature rule
over the interior of a tetrahedron in 3D.
-
tetrahedron_felippa_rule,
a Python code which
returns a Felippa quadrature rule for approximating integrals
over the interior of a tetrahedron in 3D.
-
tetrahedron_grid,
a Python code which
computes a grid of points
over the interior of a tetrahedron in 3D.
-
tetrahedron_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit tetrahedron in 3D.
-
tetrahedron_jaskowiec_rule,
a Python code which
returns quadrature rules, with exactness up to total degree 20,
over the interior of a tetrahedron in 3D,
by Jan Jaskowiec, Natarajan Sukumar.
-
tetrahedron_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate an integral
over the interior of a tetrahedron in 3D.
-
tetrahedron_witherden_rule,
a Python code which
returns a symmetric Witherden quadrature rule for the tetrahedron,
with exactness up to total degree 10.
-
tetrahedron01_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate an integral
over the interior of the unit tetrahedron in 3D.
-
text_to_wordlist,
a Python code which
shows how to start with a text file, read its information into a
single long string, and divide that string into individual words.
This allows an investigator to analyze the text for patterns.
-
theta_method,
a Python code which
solves one or more ordinary differential equations (ODE)
using the theta method.
-
three_body_ode,
a Python code which
sets up ordinary differential equations (ODE) that
simulate the behavior of three planets, constrained to lie in a
plane, and moving under the influence of gravity,
by Walter Gander and Jiri Hrebicek.
-
tictoc,
a Python code which
provides versions of the tic() and toc() functions
for wallclock timing.
-
timer_test,
a Python code which
tests various timers.
-
timestamp,
a Python code which
prints the current YMDHMS date as a timestamp.
-
toeplitz_cholesky,
a Python code which
computes the Cholesky factorization of a symmetric positive definite
(SPD) Toeplitz matrix.
-
toeplitz_inverse,
a Python code which
computes the inverse of a Toeplitz matrix.
-
toms097,
a Python code which
computes the distance between all pairs of nodes in a directed graph
with weighted edges, using the Floyd algorithm.
This is a version of ACM TOMS algorithm 97.
-
toms112,
a Python code which
determines whether a point is contained in a polygon,
by Moshe Shimrat.
This is a version of ACM TOMS algorithm 112.
-
toms178,
a Python code which
seeks the minimizer of a function of several variables, using the
Hooke-Jeeves direct search method,
by Arthur Kaupe.
This is a version of ACM TOMS algorithm 178.
-
toms179,
a Python code which
calculates the incomplete Beta ratio,
by Oliver Ludwig.
This is a version of ACM TOMS algorithm 179.
-
toms243,
a Python code which
evaluates the logarithm of a complex value,
by David Collens.
This is a version of ACM TOMS algorithm 243.
-
toms443,
a Python code which
evaluates the Lambert W function,
by Fritsch, Shafer and Crowley.
This is a version of ACM TOMS algorithm 443.
-
toms515,
a Python code which
selects subsets of size K from a set of size N.
This is a version of ACM TOMS Algorithm 515,
by Bill Buckles, Matthew Lybanon.
-
toms577,
a Python code which
evaluates the Carlson elliptic integral functions RC, RD, RF and RJ.
This is a version of ACM TOMS algorithm 577.
-
toms655,
a Python code which
computes the weights for interpolatory quadrature rule;
this library is commonly called IQPACK,
by Sylvan Elhay and Jaroslav Kautsky.
This is a version of ACM TOMS algorithm 655.
Only a small portion of this library has been implemented
in Python so far!
-
toms743,
a Python code which
evaluates the Lambert W function.
This is a version of ACM TOMS algorithm 743,
by Barry, Barry and Culligan-Hensley.
-
toms923,
a Python code which
evaluates the Pfaffian for a dense or banded skew symmetric matrix,
by Michael Wimmer.
-
tough_ode,
a Python code which
sets up a system of four ordinary differential
equations (ODE) which is extremely difficult to solve accurately.
-
traffic_simulation,
a Python code which
simulates the cars waiting to get through a traffic light.
-
trapezoidal,
a Python code which
solves one or more ordinary differential equations (ODE)
using the implicit trapezoidal method, and using fsolve()
to handle the implicit system.
-
trapezoidal_explicit,
a Python code which
solves one or more ordinary differential equations (ODE)
using the (explicit) trapezoidal method.
-
trapezoidal_fixed,
a Python code which
solves one or more ordinary differential equations (ODE)
using the implicit trapezoidal method, and using a fixed point
method to handle the implicit system.
-
triangle,
a Python code which
computes properties, including angles, area, centroid, circumcircle,
edge lengths, incircle, orientation, orthocenter, and quality,
of a triangle in 2D.
-
triangle_distance,
a Python code which
estimates the typical value of the distance
between a pair of points randomly selected from the interior of a
triangle in 2D.
-
triangle_exactness,
a Python code which
tests the exactness of a quadrature rule
over the interior of a triangle in 2D.
-
triangle_grid,
a Python code which
computes a grid of points
over the interior of a triangle in 2D.
-
triangle_integrals,
a Python code which
returns the exact value of the integral of any polynomial
over the interior of a general triangle in 2D.
-
triangle_interpolate,
a Python code which
shows how vertex data can be interpolated at any point
in the interior of a triangle.
-
triangle_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate an integral
over the interior of a general triangle in 2D.
-
triangle_symq_rule,
a Python code which
returns symmetric quadrature rules, with precision up to 50,
over the interior of a triangle,
by Hong Xiao and Zydrunas Gimbutas.
-
triangle_twb_rule,
a Python code which
generates the points and weights of quadrature rules
over the interior of a triangle in 2D,
determined by Taylor, Wingate, and Bos.
-
triangle_witherden_rule,
a Python code which
returns a symmetric Witherden quadrature rule for the triangle,
with exactness up to total degree 20.
-
triangle01_integrals,
a Python code which
returns the integral of any monomial
over the interior of the unit triangle in 2D.
-
triangle01_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate the integral of any function
over the interior of the unit triangle in 2D.
-
tridiagonal_solver
a Python code which
solves a tridiagonal linear system.
-
truel_simulation,
a Python code which
simulates N repetitions of a duel between three players, each of
whom has a known firing accuracy.
-
truncated_normal,
a Python code which
works with the truncated normal distribution over [A,B], or
[A,+oo) or (-oo,B], returning the probability density function (PDF),
the cumulative density function (CDF), the inverse CDF, the mean,
the variance, and sample values.
-
truncated_normal_rule,
a Python code which
computes a quadrature rule for a
normal probability density function (PDF), sometimes called a
Gaussian distribution, that has been truncated to [A,+oo), (-oo,B]
or [A,B].
-
tsp_brute,
a Python code which
is given a table of city-to-city distances and solves a small
traveling salesperson problem (TSP), using brute force.
-
tsp_descent,
a Python code which
is given a table of city-to-city distances, chooses an initial tour
at random, and then tries some simple variations to quickly find
a tour of lower length, to solve the traveling salesperson problem (TSP).
-
tsp_greedy,
a Python code which
is given a table of city-to-city distances, and solves a small
traveling salesperson problem (TSP) using the greedy algorithm.
It picks a starting city at random, and then successively visits
the nearest unvisited city.
-
tsp_moler,
a Python code which
tries to optimize the traveling salesperson problem (TSP),
written by Cleve Moler.
-
tsp_random,
a Python code which
seeks a solution of the Traveling Salesperson Problem (TSP), by
accepting a table of city-to-city distances, and randomly generating
round trips that visit every city, returning the tour of
shortest length.
-
two_body_ode,
a Python code which
sets up ordinary differential equations (ODE) which
simulate the behavior of two bodies, constrained to lie in a plane,
moving under the influence of gravity, with one body much more massive
than the other.
-
ubvec,
a Python code which
demonstrates how nonnegative integers can be stored as
unsigned binary vectors, and arithmetic can be performed on them.
-
ulam_spiral,
a Python code which
displays the integers as a spiral of grid cells, with the primes
highlighted, so show that they tend to fall along diagonals,
as discovered by Stanislaw Ulam.
-
umlaut_remover,
a Python code which
replaces certain special characters in German text by English
equivalents, based on work by John Berroa.
-
unicycle,
a Python code which
considers permutations containing a single cycle,
sometimes called cyclic permutations.
-
uniform,
a Python code which
contains uniform random number generators (RNG) for several
arithmetic types.
-
unstable_ode,
a Python code which
sets up an unstable ordinary differential equation (ODE)
which the backward Euler method incorrectly drives to zero.
-
upc,
a Python code which
computes the check digit associated with a uniform product code
(UPC), or reports whether a 12-digit UPC is actually valid.
-
urn_simulation,
a Python code which
simulates the experiment of sampling K balls from an urn containing
N balls of various colors.
-
usa_box_plot,
a Python code which
creates simplified maps of the USA in which each state
appears as a box, and the placement of the boxes only
roughly corresponds to the relative locations of states on
an accurate map.
-
usa_matrix,
a Python code which
defines the adjacency matrix for US states,
using a variety of matrix formats.
-
van_der_corput,
a Python code which
computes elements of the van der Corput
1-dimensional Quasi Monte Carlo (QMC) sequence,
using a simple interface.
-
vandermonde_approx_1d,
a Python code which
finds a polynomial approximant to data y(x) of a 1D argument
by setting up and solving an overdetermined linear system
for the polynomial coefficients involving the Vandermonde matrix.
-
vandermonde_interp_1d,
a Python code which
finds a polynomial interpolant to data y(x) of a 1D argument
by setting up and solving a linear system for the
polynomial coefficients involving the Vandermonde matrix,
creating graphics with matplotlib().
-
vanderpol_ode,
a Python code which
sets up the ordinary differential equations (ODE)
for the van der Pol oscillator, for which a limit cycle exists.
-
vanderpol_ode_period,
a Python code which
sets up the ordinary differential equations (ODE)
for the van der Pol oscillator
in order to estimate the period of the limit cycle.
-
vector,
a Python code which
considers a problem involving vectors, which can be
considered to belong to equivalence classes,
for which an arbitrary collection of coefficients must be
gathered, averaged, and then scattered again.
-
velocity_verlet,
a Python code which
uses a version of the velocity Verlet method to solve
a second order ordinary differential equation (ODE)
of the form y''=f(t,y).
-
vin,
a Python code which
computes the check digit for a Vehicle Identification Number (VIN),
or verifies that a given VIN is legitimate.
-
voronoi_plot,
a Python code which
estimates the Voronoi neighborhoods of points using sampling,
and with a distance based on the L1, L2, LInfinity
or arbitrary LP norms;
-
voronoi_test,
a Python code which
demonstrates the use of the scipy.spatial function Voronoi(),
to compute a Voronoi diagram, and voronoi_plot_2d(), to display it.
-
walker_sample,
a Python code which
efficiently samples a discrete probability density function
(PDF) represented by a vector, using Walker sampling.
-
walsh_transform,
a Python code which
implements the Walsh data transform.
-
wathen_matrix,
a Python code which
compares storage schemes: full, banded, sparse triplet, sparse, and
solution strategies: A\x, Linpack, conjugate gradient, for linear
systems involving the Wathen matrix, which can arise when solving a
problem using the finite element method (FEM).
-
web_matrix,
a Python code which
stores sample matrices describing a web page network. These matrices
are typically very sparse, and the examples here are stored using the
sparse triplet (ST) format. They can be used to demonstrate
pagerank and other graph algorithms.
-
wedge_exactness,
a Python code which
tests the exactness of a quadrature rule
over the interior of the unit wedge in 3D.
-
wedge_felippa_rule,
a Python code which
returns a Felippa quadrature rule for approximating integrals
over the interior of the unit wedge in 3D.
-
wedge_grid,
a Python code which
computes a grid of points
over the interior of the unit wedge in 3D.
-
wedge_integrals,
a Python code which
returns the exact value of the integral of any monomial
over the interior of the unit wedge in 3D.
-
wedge_monte_carlo,
a Python code which
uses the Monte Carlo method to estimate an integral
over the interior of the unit wedge in 3D.
-
weekday,
a Python code which
determines the day of the week corresponding to a given date,
such as 14 October 1066, Julian calendar, ... which was a Saturday.
-
weekday_zeller,
a Python code which
uses the Zeller congruence to determine the day of the week
corresponding to a given date, such as 13 July 1989, Gregorian
calendar, ... which was a Thursday.
-
will_you_be_alive,
a Python code which
carries out the probability simulations
described in "Will You Be Alive 10 Years From Now?"
by Paul Nahin;
-
wishart_matrix,
a Python code which
produces sample matrices from the Wishart or Bartlett distributions,
useful for sampling random covariance matrices.
-
wtime,
a Python code which
shows how to return a reading of the wall clock time.
-
xml_to_fem,
a Python code which
reads an XML file created by dolfin() or fenics(), describing a mesh
in 1D, 2D, or 3D, and extracts two sets of information, namely,
the coordinates of nodes, and the indices of nodes that form each
element, which constitute a finite element method (FEM) mesh
of the geometry.
-
xyz_display,
a Python code which
displays a 3D plot from a file of (X,Y,Z) point coordinates.
-
zero_brent,
a Python code which
seeks a solution of a scalar nonlinear equation f(x)=0,
by Richard Brent.
-
zero_chandrupatla,
a Python code which
finds a zero of a scalar function of a scalar variable,
starting from a change of sign interval, using the
Chandrupatla method, which can converge faster than
bisection, regula falsi, or Brent's method,
by Tirupathi Chandrapatla.
-
zero_itp,
a Python code which
finds a zero of a scalar function of a scalar variable,
starting from a change of sign interval, using the
Interpolate/Truncate/Project (ITP) method, which has
faster convergence than the bisection method.
-
zero_laguerre,
a Python code which
uses Laguerre's method to find the zero of a function.
The method needs first and second derivative information.
The method almost always works when the function is a polynomial.
-
zero_muller,
a Python code which
seeks a root of a nonlinear equation using the Muller method,
with complex arithmetic.
-
zero_rc,
a Python code which
seeks a solution of a scalar nonlinear equation f(x)=0,
using reverse communication (RC),
by Richard Brent.
-
zombie_ode,
a Python code which
sets up a system of ordinary differential equations (ODE)
for a generalized Susceptible-Infected-Recovered (SIR) disease
model to simulate a zombie attack, developed by Philip Munz.
Last revised on 18 November 2024.