No BSD License
-
Fibonacci(n)
Fibonacci.m by David Terr, Raytheon, 5-11-04
-
GeneralizedFibonacci(n,a,b)
GeneralizedFibonacci.m by David Terr, Raytheon, 10-20-04
-
GeneralizedLucas(n,a,b)
GeneralizedLucas.m by David Terr, Raytheon, 10-20-04
-
JacobiSymbol(a,b)
Compute the Jacobi symbol (a/b), where a and b are integers with b odd and positive.
-
Lucas(n)
Fibonacci.m by David Terr, Raytheon, 5-11-04
-
MinkowskiQM(x)
Given x from 0 to 1, compute the Minkowski question mark function of x.
-
Pell(d,s,n)
-
QCF(d,u,v,quiet)
-
RoundQCF(d,u,v,quiet)
-
binomial(n,m)
binomial.m by David Terr, Raytheon, 5-11-04
-
cfrac(x,n)
-
factor2( n )
-
fromcfrac( a )
Return the number whose continued fraction coefficieints are given as a row or column vector.
-
harmonic(z)
harmonic.m by David Terr, Raytheon, 9-10-04
-
partitiontable(n)
PartitionTable.m by David Terr, Raytheon, 6-7-04
-
qftimes(f1,f2)
qftimes.m by David Terr, Raytheon, 11-17-04
-
roundcfrac(x,n)
-
rqf(f)
-
sigma(k,n)
-
tau(n)
-
partitionplot.m
-
View all files
from
numerical.zip
by David Terr
Archive containing numerical function files.
|
| cfrac(x,n)
|
% cfrac.m by David Terr, Raytheon Inc., 5-20-04
% Modified on 7-29-04 to include rational convergents.
% cfrac(x,n) returns a 3x3 matrix whose first column consists of the first n continued fraction coefficients of a given
% nonnegative real number x and whose second and third columns consist of
% the numerators and denominators of the first n rational convergents of x
% respectively.
% Warning: If n is set too large, fewer coefficients may be returned and
% the last coefficient may be incorrect, due to rounding errors.
function c = cfrac(x,n)
c = zeros(n,3);
t = x;
k = 1;
p1 = 1;
p2 = 0;
q1 = 0;
q2 = 1;
done = 0;
while k<=n && ~done
a = floor(t);
c(k,1) = a;
r = t - a;
c(k,2) = r;
p = a*p1 + p2;
q = a*q1 + q2;
c(k,2) = p;
c(k,3) = q;
if r==0 || x == p/q;
done = true;
else
t = 1/r;
k = k + 1;
p2 = p1;
q2 = q1;
p1 = p;
q1 = q;
end
end
c = c(1:min(k,n),1:3);
|
|
Contact us at files@mathworks.com