The dilogarithm function
.
This is simply an alias for polylog(2, z).
EXAMPLES:
sage: dilog(1)
1/6*pi^2
sage: dilog(1/2)
1/12*pi^2 - 1/2*log(2)^2
sage: dilog(x^2+1)
dilog(x^2 + 1)
sage: float(dilog(1))
1.6449340668482262
sage: var('z')
z
sage: dilog(z).diff(z, 2)
log(-z + 1)/z^2 - 1/((z - 1)*z)
sage: dilog(z).series(z==1/2, 3)
(1/12*pi^2 - 1/2*log(2)^2) + (-2*log(1/2))*(z - 1/2) + (2*log(1/2) + 2)*(z - 1/2)^2 + Order(1/8*(2*z - 1)^3)
INPUT:
EXAMPLES:
sage: exp(pi*I/2)
I
sage: exp(pi*I)
-1
sage: exp(8*pi*I)
1
sage: exp(7*pi*I/2)
-I
The exponential function, .
EXAMPLES:
sage: exp(-1)
e^(-1)
sage: exp(2)
e^2
sage: exp(2,prec=100)
7.3890560989306502272304274606
sage: exp(x^2 + log(x))
e^(x^2 + log(x))
sage: exp(x^2 + log(x)).simplify()
x*e^(x^2)
sage: exp(2.5)
12.1824939607035
sage: exp(float(2.5))
12.182493960703473
sage: exp(RDF('2.5'))
12.1824939607
TEST:
sage: latex(exp(sqrt(x)))
e^{\sqrt{x}}
sage: latex(exp)
\exp
The log function.
EXAMPLES:
sage: log(e^2)
2
sage: log(1024, 2)
10
sage: log(10, 4)
log(10)/log(4)
sage: RDF(log(10,2))
3.32192809489
sage: RDF(log(8, 2))
3.0
sage: log(RDF(10))
2.30258509299
sage: log(2.718)
0.999896315728952
EXAMPLES:
sage: from sage.symbolic.function import function as nfunction
sage: foo = nfunction("foo", 2)
sage: x,y,z = var("x y z")
sage: foo(x,y)
foo(x, y)
sage: foo(y)
...
TypeError: Symbolic function foo takes exactly 2 arguments (1 given)
sage: bar = nfunction("bar")
sage: bar(x)
bar(x)
sage: bar(x,y)
bar(x, y)
TESTS:
# test coercion
sage: bar(ZZ)
Traceback (most recent call last):
...
TypeError: cannot coerce arguments: ...
The polylog function
.
INPUT:
EXAMPLES:
sage: polylog(1, x)
-log(-x + 1)
sage: polylog(2,1)
1/6*pi^2
sage: polylog(2,x^2+1)
polylog(2,x^2 + 1)
sage: polylog(4,0.5)
polylog(4,0.500000000000000)
sage: f = polylog(4, 1); f
1/90*pi^4
sage: f.n()
1.08232323371114
sage: polylog(4, 2).n()
2.42786280675470 - 0.174371300025453*I
sage: complex(polylog(4,2))
(2.4278628067547001-0.17437130002545301j)
sage: float(polylog(4,0.5))
0.51747906167389901
sage: z = var('z')
sage: polylog(2,z).series(z==0, 5)
1*z + 1/4*z^2 + 1/9*z^3 + 1/16*z^4 + Order(z^5)
sage: loads(dumps(polylog))
polylog
sage: latex(polylog(5, x))
\mbox{Li}_{5}(x)
EXAMPLES:
These are indirect doctests for this function.
sage: polylog(2, x)._maxima_init_() ‘li[2](x)’ sage: polylog(4, x)._maxima_init_() ‘polylog(4, x)’
The natural logarithm of x.
INPUT:
OUTPUT:
EXAMPLES:
sage: ln(e^2)
2
sage: ln(2)
log(2)
sage: ln(2.0)
0.693147180559945
Return the logarithm of x to the given base.
Calls the log method of the object x when computing the logarithm, thus allowing use of logarithm on any object containing a log method. In other words, log works on more than just real numbers.
TODO: Add p-adic log example.
EXAMPLES:
sage: log(e^2)
2
sage: log(1024, 2); RDF(log(1024, 2))
10
10.0
sage: log(10, 4); RDF(log(10, 4))
log(10)/log(4)
1.66096404744
sage: log(10, 2)
log(10)/log(2)
sage: n(log(10, 2))
3.32192809488736
sage: log(10, e)
log(10)
sage: n(log(10, e))
2.30258509299405
The log function also works in finite fields as long as the base is generator of the multiplicative group:
sage: F = GF(13); g = F.multiplicative_generator(); g
2
sage: a = F(8)
sage: log(a,g); g^log(a,g)
3
8
sage: log(a,3)
...
ValueError: base (=3) for discrete log must generate multiplicative group