This method is the most stable method for solving the catenary problem that I have seen and the most simple method by far. A guess value of 1 for "a" was successful using the Newton–Raphson method and the formula holds true regardless of which value of y is higher. A simple implementation is given in the matlab code below and the figure is attached (My apologies for not commenting the code, I was a little pressed for time). I have tried this method for multiple cases and am happy with the results.

Once again thank you Opalg for sharing your method. Full credit must go to you.

Regards Elbarto

Code:

function plot_catenary
[f fstr] = CatFun2([0 10],[20 15],20.7)
x = 0:20;
y = f(x);
figure(1)
plot(x,y,[0 20],[10 15],'r:')
title(fstr)
xlabel x
ylabel y
axis equal
end
function [f fstr] = CatFun2(P1,P2,L,MAXERR,MAXIT)
if nargin < 4; MAXERR = 1e-6;end
if nargin < 5; MAXIT = 100;end
d = P2(1)-P1(1);
h = P2(2)-P1(2);
g = @(a)2*a*sinh(d/(2*a))-sqrt(L^2-h^2);
dg = @(a) 2*sinh(d/(2*a))- d*cosh(d/(2*a))/a;
[a eflag iter err] = jrbNR(g,dg,1,MAXERR,MAXIT);
x1 = 1/2*(a*log((L+h)/(L-h))-d);
x2 = 1/2*(a*log((L+h)/(L-h))+d);
k = x1-P1(1);
m = P1(2)-a*cosh(x1/a);
f = @(x)a*cosh((x+k)/a)+m;
fstr = sprintf('%0.3f*cosh((x%+0.3f)/%0.3f)%+0.3f',a,k,a,m);
end
function [x eflag iter err] = jrbNR(f,df,x0,MAXERR,MAXIT)
if nargin < 4; MAXERR = 1e-6;end
if nargin < 5; MAXIT = 100;end
eflag = 0;
x = x0-f(x0)/df(x0);
x_prev = x0;
iter = 1;
while abs(x-x_prev) > MAXERR && iter < MAXIT
x_prev = x;
x = x-f(x)/df(x);
iter = iter + 1;
end
err = abs(x-x_prev);
if iter < MAXIT; eflag = 1;end
end