Go to the first, previous, next, last section, table of contents.
zerobern
is false
.
See also burn
.
(%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 5 691 7 3617 43867 (%o4) [1, - -, -, - --, --, - ----, -, - ----, -----] 2 6 30 66 2730 6 510 798
load ("bffac")
loads this function.
The Hurwitz zeta function is defined as
sum ((k+h)^-s, k, 0, inf)
load ("bffac")
loads this function.
(x + y)!/(x! y!)
.
If x and y are integers, then the numerical value of the binomial
coefficient is computed.
If y, or x - y, is an integer,
the binomial coefficient is expressed as a polynomial.
burn
may be more efficient than bern
for large, isolated n
(perhaps n greater than 105 or so),
as bern
computes all the Bernoulli numbers up to index n before returning.
burn
exploits the observation that (rational) Bernoulli numbers can be
approximated by (transcendental) zetas with tolerable efficiency.
load ("bffac")
loads this function.
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
.
Examples:
(%i1) cf ([5, 3, 1]*[11, 9, 7] + [3, 7]/[4, 3, 2]); (%o1) [59, 17, 2, 1, 1, 1, 27] (%i2) cf ((3/17)*[1, -2, 5]/sqrt(11) + (8/13)); (%o2) [0, 1, 1, 1, 3, 2, 1, 4, 1, 9, 1, 9, 2]
cflength
controls how many periods of the continued fraction
are computed for algebraic, irrational numbers.
(%i1) cflength: 1$ (%i2) cf ((1 + sqrt(5))/2); (%o2) [1, 1, 1, 1, 2] (%i3) cflength: 2$ (%i4) cf ((1 + sqrt(5))/2); (%o4) [1, 1, 1, 1, 1, 1, 1, 2] (%i5) cflength: 3$ (%i6) cf ((1 + sqrt(5))/2); (%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
cfdisrep
.
(%i1) cflength: 3$ (%i2) cfdisrep (cf (sqrt (3)))$ (%i3) ev (%, numer); (%o3) 1.731707317073171
cf
.
(%i1) cf ([1,1,1,1,1,2] * 3); (%o1) [4, 1, 5, 2] (%i2) cf ([1,1,1,1,1,2]) * 3; (%o2) [3, 3, 3, 3, 3, 6]
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
(%i1) cf (rat (ev (%pi, numer))); `rat' replaced 3.141592653589793 by 103993//33102 = 3.141592653011902 (%o1) [3, 7, 15, 1, 292] (%i2) cfexpand (%); [ 103993 355 ] (%o2) [ ] [ 33102 113 ] (%i3) %[1,1]/%[2,1], numer; (%o3) 3.141592653011902
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.
(%i1) cflength: 1$ (%i2) cf ((1 + sqrt(5))/2); (%o2) [1, 1, 1, 1, 2] (%i3) cflength: 2$ (%i4) cf ((1 + sqrt(5))/2); (%o4) [1, 1, 1, 1, 1, 1, 1, 2] (%i5) cflength: 3$ (%i6) cf ((1 + sqrt(5))/2); (%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
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.
(%i1) divsum (12); (%o1) 28 (%i2) 1 + 2 + 3 + 4 + 6 + 12; (%o2) 28 (%i3) divsum (12, 2); (%o3) 210 (%i4) 1^2 + 2^2 + 3^2 + 4^2 + 6^2 + 12^2; (%o4) 210
For the Euler-Mascheroni constant, see %gamma
.
(%i1) map (euler, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); (%o1) [1, 0, - 1, 0, 5, 0, - 61, 0, 1385, 0, - 50521]
factorial (x)
the same as x!
.
See !
.
fib(0)
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 (x - 1)
,
the Fibonacci number preceding the last one computed.
(%i1) map (fib, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); (%o1) [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
%phi
,
which is (1 + sqrt(5))/2
, approximately 1.61803399.
By default, Maxima does not know about %phi
.
After executing tellrat (%phi^2 - %phi - 1)
and algebraic: true
,
ratsimp
can simplify some expressions containing %phi
.
(%i1) fibtophi (fib (n)); n n %phi - (1 - %phi) (%o1) ------------------- 2 %phi - 1 (%i2) fib (n-1) + fib (n) - fib (n+1); (%o2) - fib(n + 1) + fib(n) + fib(n - 1) (%i3) ratsimp (fibtophi (%)); (%o3) 0
(%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$ (%i2) map (lambda ([a], inrt (10^a, 3)), l); (%o2) [2, 4, 10, 21, 46, 100, 215, 464, 1000, 2154, 4641, 10000]
(%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$ (%i2) map (lambda ([a], jacobi (a, 9)), l); (%o2) [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]
load ("functs")
loads this function.
minfactorial
then turns one into a polynomial times the other.
(%i1) n!/(n+2)!; n! (%o1) -------- (n + 2)! (%i2) minfactorial (%); 1 (%o2) --------------- (n + 1) (n + 2)
partfrac
does a complete
partial fraction decomposition. The algorithm employed is based on
the fact that the denominators of the partial fraction expansion (the
factors of the original denominator) are relatively prime. The
numerators can be written as linear combinations of denominators, and
the expansion falls out.
(%i1) 1/(1+x)^2 - 2/(1+x) + 2/(2+x); 2 2 1 (%o1) ----- - ----- + -------- x + 2 x + 1 2 (x + 1) (%i2) ratsimp (%); x (%o2) - ------------------- 3 2 x + 4 x + 5 x + 2 (%i3) partfrac (%, x); 2 2 1 (%o3) ----- - ----- + -------- x + 2 x + 1 2 (x + 1)
true
if n
is a prime, false
if not.
sqrt (n)
where n is an integer,
i.e., the element whose norm is unity.
This amounts to solving Pell's equation a^2 - n b^2 = 1
.
(%i1) qunit (17); (%o1) sqrt(17) + 4 (%i2) expand (% * (sqrt(17) - 4)); (%o2) 1
true
When zerobern
is false
,
bern
excludes the Bernoulli numbers which are equal to zero.
See bern
.
zeta (n)
for all other arguments,
including rational noninteger, floating point, and complex arguments.
See also bfzeta
and zeta%pi
.
(%i1) map (zeta, [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]); 2 4 1 1 1 %pi %pi (%o1) [0, ---, 0, - --, - -, inf, ----, zeta(3), ----, zeta(5)] 120 12 2 6 90
true
When zeta%pi
is true
, zeta
returns an expression
proportional to %pi^n
for even integer n
.
Otherwise, zeta
returns a noun form zeta (n)
for even integer n
.
(%i1) zeta%pi: true$ (%i2) zeta (4); 4 %pi (%o2) ---- 90 (%i3) zeta%pi: false$ (%i4) zeta (4); (%o4) zeta(4)
Go to the first, previous, next, last section, table of contents.