## Maxima – 170 – Teoria dei numeri – 2

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

`cfdisrep (list)`
Constructs and returns an ordinary arithmetic expression of the form `a + 1/(b + 1/(c + ...))` from the `list` representation of a continued fraction `[a, b, c, ...]`.

``````(%i1) cf ([1, 2, -3] + [1, -2, 1]);
(%o1)                            [1, 1, 1, 2]
(%i2) cfdisrep (%);
1
(%o2)                            1 + ---------
1
1 + -----
1
1 + -
2``````

`cfexpand (x)`
Returns a matrix of the numerators and denominators of the last (column 1) and next-to-last (column 2) convergents of the continued fraction `x`.

``````(%i3) cf (rat (ev (%pi, numer)));

rat: replaced 3.141592653589793 by 80143857/25510582 = 3.141592653589792
(%o3)             [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14]
(%i4) cfexpand (%);
[ 80143857  5419351 ]
(%o4)                        [                   ]
[ 25510582  1725033 ]
(%i5) %[1,1]/%[2,1], numer;
(%o5)                          3.141592653589792``````

`cflength`
Default value: `1`.

`cflength` controls the number of terms of the continued fraction the function `cf` will give, as the value `cflength` times the period. Thus the default is to give one period.

``````(%i6) cflength: 1\$

(%i7) cf ((1 + sqrt(5))/2);
(%o7)                           [1, 1, 1, 1, 2]
(%i8) cflength: 2\$

(%i9) cf ((1 + sqrt(5))/2);
(%o9)                      [1, 1, 1, 1, 1, 1, 1, 2]
(%i10) cflength: 3\$

(%i11) cf ((1 + sqrt(5))/2);
(%o11)                 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]``````

`divsum (n, k)`
`divsum (n)`
`divsum (n, k)` returns the sum of the divisors of `n` raised to the `k`’th power.

`divsum (n)` returns the sum of the divisors of `n`.

``````(%i12) divsum (12);
(%o12)                                28
(%i13) 1 + 2 + 3 + 4 + 6 + 12;
(%o13)                                28
(%i14) divsum (12, 2);
(%o14)                                210
(%i15) 1^2 + 2^2 + 3^2 + 4^2 + 6^2 + 12^2;
(%o15)                                210``````

`euler (n)`
Returns the `n`’th Euler number for nonnegative integer `n`. Euler numbers equal to zero are suppressed if `zerobern` is `false`.

For the Euler-Mascheroni constant, see `%gamma`.

``````(%i16) zerobern: true\$

(%i17) map (euler, [0, 1, 2, 3, 4, 5, 6]);
(%o17)                    [1, 0, - 1, 0, 5, 0, - 61]
(%i18) zerobern: false\$

(%i19) map (euler, [0, 1, 2, 3, 4, 5, 6]);
(%o19)             [1, - 1, 5, - 61, 1385, - 50521, 2702765]``````

`factors_only`
Default value: `false`.

Controls the value returned by `ifactors`. The default `false` causes ifactors to provide information about multiplicities of the computed prime factors. If `factors_only` is set to `true`, `ifactors` returns nothing more than a list of prime factors.

`fib (n)`
Returns the `n`’th Fibonacci number. `fib(0)` is equal to `0` and `fib(1)` equal to `1`, and `fib (-n)` equal to `(-1)^(n + 1) * fib(n)`.

After calling `fib`, `prevfib` is equal to `fib(n - 1)`, the Fibonacci number preceding the last one computed.

``````(%i20) map (fib, [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]);
(%o20)           [- 3, 2, - 1, 1, 0, 1, 1, 2, 3, 5, 8, 13, 21]``````

`fibtophi (expr)`
Expresses Fibonacci numbers in `expr` in terms of the constant `%phi`, which is `(1 + sqrt(5))/2`, approximately `1.61803399`.

``````(%i21) fibtophi (fib (n));
n             n
%phi  - (1 - %phi)
(%o21)                        -------------------
2 %phi - 1
(%i22) fib (n-1) + fib (n) - fib (n+1);
(%o22)               (- fib(n + 1)) + fib(n) + fib(n - 1)
(%i23) fibtophi (%);
n + 1             n + 1        n             n
%phi      - (1 - %phi)         %phi  - (1 - %phi)
(%o23) (- ---------------------------) + -------------------
2 %phi - 1                 2 %phi - 1
n - 1             n - 1
%phi      - (1 - %phi)
+ ---------------------------
2 %phi - 1
(%i24) ratsimp (%);
(%o24)                                 0``````

`ifactors (n)`
For a positive integer `n` returns the factorization of `n`. If `n=p1^e1..pk^nk` is the decomposition of `n` into prime factors, `ifactors` returns `[[p1, e1], ... , [pk, ek]]`.

Factorization methods used are trial divisions by primes up to `9973`, Pollard’s `rho` and `p-1` method and elliptic curves.

If the variable `ifactor_verbose` is set to `true` `ifactor` produces detailed output about what it is doing including immediate feedback as soon as a factor has been found.

The value returned by `ifactors` is controlled by the option variable `factors_only`. The default `false` causes `ifactors` to provide information about the multiplicities of the computed prime factors. If `factors_only` is set to `true`, ifactors simply returns the list of prime factors.

``````(%i25) ifactors(51575319651600);
(%o25)         [[2, 4], [3, 2], [5, 2], [1583, 1], [9050207, 1]]
(%i26) apply("*", map(lambda([u], u[1]^u[2]), %));
(%o26)                          51575319651600
(%i27) ifactors(51575319651600), factors_only : true;
(%o27)                     [2, 3, 5, 1583, 9050207]``````

Posta un commento o usa questo indirizzo per il trackback.