2 Copyright 2009 by Barton Willis
4 This is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License,
6 http://www.gnu.org/copyleft/gpl.html.
8 This software has NO WARRANTY, not even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 /* Gauss hypergeometric transformations */
14 hypergeometric_order(p,q) := [length(p), length(q)];
16 nonpositive_integer_p(x) := (x : rationalize(x), integerp(x) and (x < 1));
18 not_one_p(x) := (x # 1) and (x # 1.0) and (x # 1.0b0);
20 abramowitz_id(e, [l]) := block([sublis_apply_lambda : true, x, str],
22 x : function_identity[str],
23 if x # false then e : sublis([x], e)),
26 function_identity[otherwise]:= false;
28 /* See, for example, https://personal.math.ubc.ca/~cbm/aands/page_559.htm */
30 function_identity["15.3.3"] : 'hypergeometric = lambda([p,q,x], block([a,b,c,f,success],
31 f : funmake('hypergeometric, [p,q,x]),
33 if hypergeometric_order(p,q) = [2,1] then (
37 if not_one_p(x) or maybe(c-a-b > 0) = true then (
38 f :(1-x)^(c-a-b) * hypergeometric([c-a, c-b],[c],x),
40 multiple_values(f, success)));
42 function_identity["15.3.4"] : 'hypergeometric = lambda([p,q,x], block([a,b,c,f,success],
43 f : funmake('hypergeometric, [p,q,x]),
45 if hypergeometric_order(p,q) = [2,1] then (
49 if not_one_p(x) or maybe(a < 0) = true then (
50 f : hypergeometric([a,c-b],[c],rectform(x/(x-1))) / (1-x)^a,
52 multiple_values(f, success)));
54 function_identity["15.3.5"] : 'hypergeometric = lambda([p,q,x], block([a,b,c,f,success],
55 f : funmake('hypergeometric, [p,q,x]),
57 if hypergeometric_order(p,q) = [2,1] then (
61 if not_one_p(x) or maybe(b < 0) = true then (
62 hypergeometric([b,c-a],[c], x /(x-1))/(1-x)^b,
64 multiple_values(f, success)));
66 function_identity["15.3.6"] : 'hypergeometric = lambda([p,q,x], block([a,b,c,f,success],
67 f : funmake('hypergeometric, [p,q,x]),
69 if hypergeometric_order(p,q) = [2,1] then (
73 if some('nonpositive_integer_p, [c,c-a-b,c-a,c-b,a+b-c+1,a+b-c,a,b,c-a-b+1])=true then (
76 f : gamma(c) * gamma(c-a-b)/ (gamma(c-a) * gamma(c-b))
77 * hypergeometric([a,b],[a+b-c+1],1-x)
78 + (gamma(c) * gamma(a + b - c) /(gamma(a) * gamma(b))) * (1-x)^(c-a-b)
79 * hypergeometric([c-a,c-b],[c-a-b+1],1-x),
81 multiple_values(f, success)));
83 function_identity["15.3.7"] : 'hypergeometric = lambda([p,q,x], block([a,b,c,f,success],
84 f : funmake('hypergeometric, [p,q,x]),
86 if hypergeometric_order(p,q) = [2,1] then (
90 if b < a then [a,b] : sublis([a = b, b = a], [a,b]),
91 if some('nonpositive_integer_p, [c, b-a, a-b, b, c-a, c-b,1-c+a,1-c+b]) = true then (
94 f : gamma(c) * gamma(b-a) / (gamma(b) * gamma(c-a))
95 * (-x)^(-a) * hypergeometric([a,1-c+a],[1-b+a],1/x)
96 + (gamma(c) * gamma(a-b) /(gamma(a) * gamma(c-b)))
97 * (-x)^(-b) * hypergeometric([b,1-c+b],[1-a+b],1/x),
99 multiple_values(f, success)));
101 function_identity["15.3.8"] : 'hypergeometric = lambda([p,q,x], block([a,b,c,f,success],
102 f : funmake('hypergeometric, [p,q,x]),
104 if hypergeometric_order(p,q) = [2,1] then (
108 if some('nonpositive_integer_p, [c,b-a,b,c-a,a-b,a,c-b,b-a+1]) = true then (
111 f : (gamma(c) * gamma(b-a)/(gamma(b) * gamma(c-a)))
112 * (1-x)^(-a) * hypergeometric([a,c-b],[a-b+1], 1/(1-x))
113 + (gamma(c) * gamma(a-b) /(gamma(a) * gamma(c-b)))
114 * (1-x)^(-b) * hypergeometric([b,c-a],[b-a+1],1/(1-x)),
116 multiple_values(f, success)));
118 function_identity["15.3.9"] : 'hypergeometric = lambda([p,q,x], block([a,b,c,f : [], success],
119 f : funmake('hypergeometric, [p,q,x]),
121 if hypergeometric_order(p,q) = [2,1] then (
125 if some('nonpositive_integer_p, [c,c-a-b,c-a,c-b,a+b-c+1,a+b-c,a,b,c-a-b+1])=true then (
128 f : (gamma(c) * gamma(c-a-b)/(gamma(c-a) * gamma(c-b)))
129 * (x)^(-a) * hypergeometric([a,a-c+1],[a+b-c+1], 1 - 1/x)
130 + (gamma(c) * gamma(a + b - c) /(gamma(a) * gamma(b)))
131 * (1-x)^(c-a-b) * x^(a-c) * hypergeometric([c-a,1-a],[c-a-b+1],1 - 1/x),
133 multiple_values(f, success)));
135 function_identity["a&s13.1.3-->"] : 'hypergeometric_u = lambda([a,b,x], block([f, success],
136 f : funmake('hypergeometric_u, [a,b,x]),
138 if some('nonpositive_integer_p, [b,1+a-b,2-b]) then (
141 f : (%pi / sin(%pi * b)) * (hypergeometric([a],[b],x) / (gamma(1+a-b) * gamma(b)) -
142 (x)^(1-b) * hypergeometric([1+a-b],[2-b],x)/ (gamma(a) * gamma(2-b))),
144 multiple_values(f,success)));
146 function_identity["a&s17.3.9-->"] : nounify('elliptic_kc) = lambda([x], hypergeometric([1/2,1/2],[1],x) * %pi/2);
148 function_identity["a&s17.3.9<--"] : 'hypergeometric = lambda([p,q,x],
149 if is(equal(p , [1/2,1/2])) and is(equal(q, [1])) then (2/%pi) * elliptic_kc(x) else funmake('hypergeometric, [p,q,x]));
151 function_identity["a&s17.3.10-->"] : nounify('elliptic_ec) = lambda([x], hypergeometric([-1/2,1/2],[1],x) * %pi/2);
153 function_identity["a&s17.3.10<--"] : 'hypergeometric = lambda([p,q,x],
154 if (p = [-1/2,1/2]) and (q = [1]) then (2/%pi) * elliptic_ec(x) else funmake('hypergeometric, [p,q,x]));