Maxima – 169 – Teoria dei numeri – 1

ftc0

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.513.

Funzioni e variabili

bern (n)
Returns the n’th Bernoulli number for integer n. Bernoulli numbers equal to zero are
suppressed if zerobern is false.

(%i1) zerobern: true$

(%i2) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
                           1  1       1      1        1
(%o2)                [1, - -, -, 0, - --, 0, --, 0, - --]
                           2  6       30     42       30
(%i3) zerobern: false$

(%i4) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
                        1  1    1   1     1   5     691   7
(%o4)             [1, - -, -, - --, --, - --, --, - ----, -]
                        2  6    30  42    30  66    2730  6

bernpoly (x, n)
Returns the n’th Bernoulli polynomial in the variable x.

bfzeta (s, n)
Returns the Riemann zeta function for the argument s. The return value is a big float (bfloat); n is the number of digits in the return value.

bfhzeta (s, h, n)
Returns the Hurwitz zeta function for the arguments s and h. The return value is a big float (bfloat); n is the number of digits in the return value.

The Hurwitz zeta function is defined as

169-0

load ("bffac") loads this function.

burn (n)
Returns a rational number, which is an approximation of the n’th Bernoulli number for integer n. burn exploits the observation that (rational) Bernoulli numbers can be approximated by (transcendental) zetas with tolerable efficiency:

                   n - 1  1 - 2 n
              (- 1)      2        zeta(2 n) (2 n)!
     B(2 n) = ------------------------------------
                                2 n
                             %pi

burn may be more efficient than bern for large, isolated n as bern computes all the Bernoulli numbers up to index n before returning. burn invokes the approximation for even integers n > 255. For odd integers and n <= 255 the function bern is called.

load ("bffac") loads this function. See also bern.

chinese ([r_1, ..., r_n], [m_1, ..., m_n])
Chinese remainder theorem.

Solves the system of congruences x = r_1 mod m_1, ..., x = r_n mod m_n. The remainders r_n may be arbitrary integers while the moduli m_n have to be positive and pairwise coprime integers.

(%i5) mods : [1000, 1001, 1003, 1007];
(%o5)                      [1000, 1001, 1003, 1007]
(%i6) lreduce('gcd, mods);
(%o6)                                  1
(%i7) x : random(apply("*", mods));
(%o7)                            685124877004
(%i8) rems : map(lambda([z], mod(x, z)), mods);
(%o8)                          [4, 568, 54, 624]
(%i9) chinese(rems, mods);
(%o9)                            685124877004
(%i10) chinese([1, 2], [3, n]);
(%o10)                      chinese([1, 2], [3, n])
(%i11) %, n = 4;
(%o11)                                10

cf (expr)
Computes a continued fraction approximation. expr is an expression comprising continued fractions, square roots of integers, and literal real numbers (integers, rational numbers, ordinary floats, and bigfloats). cf computes exact expansions for rational numbers, but expansions are truncated at ratepsilon for ordinary floats and 10^(-fpprec) for bigfloats.

Operands in the expression may be combined with arithmetic operators. Maxima does not know about operations on continued fractions outside of cf.

cf evaluates its arguments after binding listarith to false. cf returns a continued fraction, represented as a list.

A continued fraction a + 1/(b + 1/(c + ...)) is represented by the list [a, b, c, ...]. The list elements a, b, c, ... must evaluate to integers. expr may also contain sqrt (n) where n is an integer. In this case cf will give as many terms of the continued fraction as the value of the variable cflength times the period.

A continued fraction can be evaluated to a number by evaluating the arithmetic representation returned by cfdisrep. See also cfexpand for another way to evaluate a continued fraction.

See also cfdisrep, cfexpand, and cflength.

Nota: non riesco a riprodurre gli esempi della Reference, ottengo errori sulle radici p.es: “cf: argument of sqrt must be an integer; found [0, 11] — an error. To debug this try: debugmode(true);“. Modifico gli esempi, semplicandoli.

expr is an expression comprising continued fractions.

(%i1) cf ([5, 3, 1]*[11, 9, 7]);
(%o1)                          [58, 3, 11, 1, 6]
(%i2) cf ((3/17)*[1, -2, 5] + (8/13));
(%o2)                      [0, 1, 2, 3, 1, 3, 6, 2]

cflength controls how many periods of the continued fraction are computed for algebraic, irrational numbers.

(%i3) cflength: 1$

(%i4) cf ((1 + sqrt(5))/2);
(%o4)                           [1, 1, 1, 1, 2]
(%i5) cflength: 2$

(%i6) cf ((1 + sqrt(5))/2);
(%o6)                      [1, 1, 1, 1, 1, 1, 1, 2]
(%i7) cflength: 3$

(%i8) cf ((1 + sqrt(5))/2);
(%o8)                  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]

A continued fraction can be evaluated by evaluating the arithmetic representation returned by cfdisrep.

(%i9) cflength: 3$

(%i10) cfdisrep (cf (sqrt (3)))$

(%i11) ev (%, numer);
(%o11)                         1.73170731707317

Maxima does not know about operations on continued fractions outside of cf.

(%i12) cf ([1,1,1,1,1,2] * 3);
(%o12)                           [4, 1, 5, 2]
(%i13) cf ([1,1,1,1,1,2]) * 3;
(%o13)                        [3, 3, 3, 3, 3, 6]

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d blogger hanno fatto clic su Mi Piace per questo: