```! Catenary curve calculation for a hanging chain with 2*N links. A catenary curve is the curve formed by a cable hanging between two points. The Gateway Arch in St. Louis is an inverted catenary curve. For an electric power line between two poles, one may be interested in the amount of sag at the midpoint between two poles. Below we do the calculations for discrete links. If we assume the line is continuous, there is a closed form solution involving the hyperbolic cosine function; ! Keywords: Catenary Curve, Engineering Design, Sag; SETS: LINK: THETA, TNSN, X, Y; ENDSETSDATA: LINK = 1..10; W = 10; L = 1; ENDDATA ! Parameters: W = horizontal distance between the two supports, at equal height, for the two ends of the chain, L = length of each link, N = number of links in each half of chain, assumed to have an equal number of links. Each node has weight 1. Equivalently, each link has weight 1. Variables: Theta(i) = angle that link i makes with vertical, link 1 is at the top support, link N is at the bottom of the hanging chain. TNSN(i) = tension in link i, HT = horizontal tension in the chain, ; N = @SIZE( LINK); @FOR( LINK(i): ! Vertical component of the tension in link i. Each link must support the links below it; TNSN(i)*@COS( Theta(i)) = .5 + N - i; ! Horizontal component of the tension in link i; TNSN(i)*@SIN( Theta(i)) = HT; ); ! Horizontal distances of half the links must sum to half the distance between the supports; L*@SUM( LINK(i): @SIN(Theta(i))) = W/2; ! Optionally, compute the x,y coordinates lower right of each link. The leftmost link is anchored at 0,0; X(1) = L*@SIN(Theta(1)); Y(1) = L*@COS(Theta(1)); @FOR( LINK(i) | i #GT# 1: X(i) = X(i-1) + L*@SIN(Theta(i)); Y(i) = Y(i-1) + L*@COS(Theta(i)); ); ```