File: test_special_functions.mac

package info (click to toggle)
maxima 5.47.0-9
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 193,104 kB
  • sloc: lisp: 434,678; fortran: 14,665; tcl: 10,990; sh: 4,577; makefile: 2,763; ansic: 447; java: 328; python: 262; perl: 201; xml: 60; awk: 28; sed: 15; javascript: 2
file content (88 lines) | stat: -rw-r--r-- 3,544 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Original version of this file copyright 1999 by Michael Wester,
 * and retrieved from http://www.math.unm.edu/~wester/demos/SpecialFunctions/problems.macsyma
 * circa 2006-10-23.
 *
 * Released under the terms of the GNU General Public License, version 2,
 * per message dated 2007-06-03 from Michael Wester to Robert Dodier
 * (contained in the file wester-gpl-permission-message.txt).
 *
 * See: "A Critique of the Mathematical Abilities of CA Systems"
 * by Michael Wester, pp 25--60 in
 * "Computer Algebra Systems: A Practical Guide", edited by Michael J. Wester
 * and published by John Wiley and Sons, Chichester, United Kingdom, 1999.
 */
/* ----------[ M a c s y m a ]---------- */
/* ---------- Initialization ---------- */
showtime: all$
prederror: false$
/* ---------- Special Functions ---------- */
/* Bernoulli numbers: B_16 => -3617/510   [Gradshteyn and Ryzhik 9.71] */
bern(16);
/* d/dk E(phi, k) => [E(phi, k) - F(phi, k)]/k  where  F(phi, k) and E(phi, k)
   are elliptic integrals of the 1st and 2nd kind, respectively
   [Gradshteyn and Ryzhik 8.123(3)] */
diff(elliptic_e(phi, k^2), k);
multthru(%);
/* Jacobian elliptic functions: d/du dn u => -k^2 sn u cn u
   [Gradshteyn and Ryzhik 8.158(3)] */
diff(jacobi_dn(u, k^2), u);
/* => -2 sqrt(pi)   [Gradshteyn and Ryzhik 8.338(3)] */
gamma(-1/2);
/* psi(1/3) => - Euler's_constant - pi/2 sqrt(1/3) - 3/2 log 3  where  psi(x)
   is the psi function [= d/dx log Gamma(x)]   [Gradshteyn and Ryzhik 8.366(6)]
   */
psi[0](1/3);
/* Bessel function of the first kind of order 2 => 0.04158 + 0.24740 i */
sfloat(bessel_j[2](1 + %i));
/* => 12/pi^2   [Gradshteyn and Ryzhik 8.464(6)] */
bessel_j[-5/2](%pi/2);
/* => sqrt(2/(pi z)) (sin z/z - cos z)   [Gradshteyn and Ryzhik 8.464(3)] */
bessel_j[3/2](z);
/* d/dz J_0(z) => - J_1(z)   [Gradshteyn and Ryzhik 8.473(4)] */
diff(bessel_j[0](z), z);
/* Associated Legendre (spherical) function of the 1st kind: P^mu_nu(0)
   => 2^mu sqrt(pi) / [Gamma([nu - mu]/2 + 1) Gamma([- nu - mu + 1]/2)]
      [Gradshteyn and Ryzhik 8.756(1)] */
declare(nu, integer, mu, integer)$
assume(nu > mu)$
alegendre_p(nu, mu, 0);
forget(nu > mu)$
remove(nu, integer, mu, integer)$
/* P^1_3(x) => -3/2 sqrt(1 - x^2) (5 x^2 - 1)
               [Gradshteyn and Ryzhik 8.813(4)] */
alegendre_p(3, 1, x);
/* nth Chebyshev polynomial of the 1st kind: T_n(x) => 0
   [Gradshteyn and Ryzhik 8.941(1)] */
ratsimp(chebyshev_t(1008, x) - 2*x*chebyshev_t(1007, x) + chebyshev_t(1006, x));
/* T_n(-1) => (-1)^n   [Gradshteyn and Ryzhik 8.944(2)] */
declare(n, integer)$
assume(n > 0)$
chebyshev_t(n, -1);
forget(n > 0)$
assume(equal(n, 0))$
chebyshev_t(n, -1);
forget(equal(n, 0))$
assume(n < 0)$
chebyshev_t(n, -1);
forget(n < 0)$
remove(n, integer)$
/* => arcsin z/z   [Gradshteyn and Ryzhik 9.121(26)] */
hgfred([1/2, 1/2], [3/2], z^2);
/* => sin(n z)/(n sin z cos z)   [Gradshteyn and Ryzhik 9.121(17)] */
q: hgfred([(n + 2)/2, -(n - 2)/2], [3/2], sin(z)^2);
assume(cos(z) > 0)$
ev(trigreduce(trigsimp(q)), triginverses:all);
forget(cos(z) > 0)$
remvalue(q)$
/* zeta'(0) => - 1/2 log(2 pi)   [Gradshteyn and Ryzhik 9.542(4)] */
subst(x = 0, diff(zeta(x), x));
logcontract(%);
/* Dirac delta distribution => 3 f(4/5) + g'(1) */
integrate(f((x + 2)/5)*delta((x - 2)/3) - g(x)*diff(delta(x - 1), x), x, 0, 3);
delint(f((x + 2)/5)*delta((x - 2)/3) - g(x)*diff(delta(x - 1), x), x, 0, 3);
deltasimp(%, x);
/* Define an antisymmetric function f */
declare(f, antisymmetric)$
/* Test it out => [-f(a, b, c), 0] */
[f(c, b, a), f(c, b, c)];
remove(f, antisymmetric)$