Numbers Package

This package contains some functions connected to the Number Theory
Function Description
Cfe Cfe(x,eps)

Given the real number x and the optional error eps, computes the first n terms of the Simple Continued Fraction Expansion of x until the approximation error is less or equal to eps
(eps >= 1E-12)


Returns a n x 4 matrix containing {numer.|denom.|fract.val.|err}
Example: Cfe(pi,1E-6), Ans=
3 1 3 0.142
22 7 3.142857.. 0.00126
333 106 3.141509.. 8.3E-005
355 113 3.141592.. 2.67E-007
GCD GCD(a,b) or GCD(m)

Finds the Greatest Common Divisor.

a,b = numbers or vectors (must be of the same size)
or
m = matrix

Returns a number or a vector containing the GCDs
Examples :
GCD(56,98)=14
GCD({56|25},{98,40})={14|5}
GCD({56,98|25,40})={14|5}
LCM LCM(a,b) or LCM(m)

Finds the Least Common Multiple.

a,b = numbers or vectors (must be of the same size)
or
m = matrix

Returns a number or vector containing the LCMs
Examples :
LCM(56,98)=392
LCM({56|25},{98,40})={392|200}
LCM({56,98|25,40})={392|200}
XFactors XFactors(n)

Finds all the prime factors of a integer positive number.

In order to avoid errors in case n is computed, it indeed finds the factors of int(abs(n)+.5)
Retuns a two columns matrix whose 1st column contains the prime factors and the 2nd column the corresponding exponents.

Examples:
XFactors(648), ANS=
2 3
3 4

XFactors(2^3*3^4), ANS=
2 3
3 4
(it'd give a incorrect answer without the rounding)

Note: The main advantage of XFactors over the library script factors is that it isn't limited to the first 32000 primes, on the other hand it could take a long time to complete.

Reference:
The algorithm used is a modified version of the one published in 1978 by Texas Instruments with the MU-09 Program part of the Math/Utilities Solid State Software™ Module for their TI Programmable 58/59 Calculators

© 2007 Stefano Bertolucci