# HG changeset patch
# User Robert Marik <marik@mendelu.cz>
# Date 1267912228 -3600
# Node ID 7c9b25fe33e2d193e52a6246b81ea7d273543237
# Parent e11f5bf2d2c2ad28584a0d5cc967c6c0c89ce67e
#8459 / polylog function
diff -r e11f5bf2d2c2 -r 7c9b25fe33e2 sage/calculus/calculus.py
a
|
b
|
|
1425 | 1425 | |
1426 | 1426 | ####################################################### |
1427 | 1427 | |
1428 | | symtable = {'%pi':'pi', '%e': 'e', '%i':'I', '%gamma':'euler_gamma', |
1429 | | 'li[2]':'polylog2', 'li[3]':'polylog3'} |
| 1428 | symtable = {'%pi':'pi', '%e': 'e', '%i':'I', '%gamma':'euler_gamma'} |
1430 | 1429 | |
1431 | 1430 | from sage.symbolic.pynac import register_symbol |
1432 | 1431 | from sage.rings.infinity import infinity, minus_infinity |
… |
… |
|
1475 | 1474 | x#0 |
1476 | 1475 | sage: a.sage() |
1477 | 1476 | x != 0 |
| 1477 | |
| 1478 | TESTS: |
| 1479 | |
| 1480 | Trac #8459 fixed:: |
| 1481 | |
| 1482 | sage: maxima('3*li[2](u)+8*li[33](exp(u))').sage() |
| 1483 | 3*polylog(2, u) + 8*polylog(33, e^u) |
| 1484 | |
1478 | 1485 | """ |
1479 | 1486 | syms = dict(_syms) |
1480 | 1487 | |
… |
… |
|
1505 | 1512 | syms[X[2:]] = function_factory(X[2:]) |
1506 | 1513 | s = s.replace("?%","") |
1507 | 1514 | |
| 1515 | regex=re.compile('li\[([0-9]+?)\]\(') |
| 1516 | s = regex.sub('polylog(\\1,',s) |
1508 | 1517 | s = multiple_replace(symtable, s) |
1509 | 1518 | s = s.replace("%","") |
1510 | 1519 | |
diff -r e11f5bf2d2c2 -r 7c9b25fe33e2 sage/calculus/tests.py
a
|
b
|
|
105 | 105 | sage: expand(integrate(log(1-x^2), x)) |
106 | 106 | x*log(-x^2 + 1) - 2*x - log(x - 1) + log(x + 1) |
107 | 107 | sage: integrate(log(1-x^2)/x, x) |
108 | | log(-x^2 + 1)*log(x) + 1/2*polylog2(-x^2 + 1) |
| 108 | log(-x^2 + 1)*log(x) + 1/2*polylog(2, -x^2 + 1) |
109 | 109 | sage: integrate(exp(1-x^2),x) |
110 | 110 | 1/2*sqrt(pi)*e*erf(x) |
111 | 111 | sage: integrate(sin(x^2),x) |