function root = calcsqrt(s)

% calcsqrt uses an iterative method to calculate the square root of an input number

    assert(s>0.);

    % set tolerance

    tol = 1.e-15;

    % calculate initial guess (average of 1 and the number)

    root = 0.5*(s+1.);

    % iteratively update guess until method converges

    while abs(s-root^2) > tol
        root = 0.5*(root+s/root);
    end

end