Nothing fancy here. Just the recurrence relations and double loops. It seems to be the most efficient solution for this problem.
Computes the volume/area of the basic alpha shape for a 3D/2D point set. The code uses delaunayn for Delaunay triangulation. Can also produce a simple plot.
PI2STR calculates pi decimals with Machin's formula.
S = PI2STR(M) gives pi truncated to M decimals for M < 2^(53/2). Machin's formula, pi/4 = 4*acot(5) - acot(239), and a number system with base 10^14 is used.
The...
ICHOOSE(N,K) gives all combinations of choosing K indices from the set 1:N without order and without repetitions.
EXAMPLE: ind = ichoose(4,2); v = 'ABCD'; v(ind) % ['AB';'AC';'AD';'BC';'BD';'CD']
ICHOOSE...
Heuristic method for the Traveling Salesman Problem (TSP) A number of nearest neighbour tours are generated from randomly selected starting points. Each tour is improved by 2-opt heuristics (pairwise exchange of edges) and the best result is...
Dragon Curve Gosper Flowsnake Curve Hexagon Molecule Curve Hilbert Curve Koch Snowflake Curve Sierpinski Arrowhead Curve Sierpinski Cross Curve Sierpinski Triangle Curve
Pretty fast code for zeros of Bessel functions of 1st and 2nd kind and for zeros of the derivatives. The Newton-Raphson method is used with the initial guess predicted from previously computed zeros.
Estimates the sum of an alternating series. Three linear methods for convergence acceleration are implemented.
EXAMPLES:
% log(2) = 1 - 1/2 + 1/3 - 1/4 + ... altsum(1./(1:20)) ans = 0.693147180559945
[FMAX,X] = KP01(W,P,C) solves the combinatorial optimization problem
maximize F = SUM(P.*X), subject to SUM(W.*X) <= C,
where the solution X is a binary vector of 0s and 1s. W and P are vectors of weights and...
Evaluation of double integrals by iterated integration. This is a simple extension of DBLQUAD to non-rectangular regions of the types
D1 = {(x,y): a < x < b, c(x) < y < d(x)},
D2 = {(x,y): a(y) < x <... |