function [ phii, phiix ] = phi ( alpha, beta, i, np, x ) %% PHI evaluates the I-th basis function at the point X. % % Modified: % % 03 November 2006 % % Author: % % Max Gunzburger % Teresa Hodge % % MATLAB translation by John Burkardt % % Parameters: % % Input, real ALPHA(NP). % ALPHA(I) contains one of the coefficients of a recurrence % relationship that defines the basis functions. % % Input, real BETA(NP). % BETA(I) contains one of the coefficients of a recurrence % relationship that defines the basis functions. % % Input, integer I, the index of the basis function. % % Input, integer NP. % The highest degree polynomial to use. % % Input, real X, the evaluation point. % % Output, real PHII, PHIIX, the value of the basis % function and its derivative. % qm1 = 0.0; q = 1.0; qm1x = 0.0; qx = 0.0; for j = 1 : i qm2 = qm1; qm1 = q; qm2x = qm1x; qm1x = qx; t = x - alpha(j); q = t * qm1 - beta(j) * qm2; qx = qm1 + t * qm1x - beta(j) * qm2x; end t = 1.0 - x * x; phii = t * q; phiix = t * qx - 2.0 * x * q;