-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathproduct.m
More file actions
32 lines (17 loc) · 718 Bytes
/
product.m
File metadata and controls
32 lines (17 loc) · 718 Bytes
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
(* Copyright E.M.Clarke and Xudong Zhao, Jan 22, 1991 *)
SimplifyProduct[f_] := f //. ProductRules;
product[f_, {v_, n1_, n2_}] := Product[f, {v, n1, n2}] /; IntegerQ[n2-n1];
ProductRules := {
(* Rules for simplifying products. *)
product[f_, {v_, n1_, (n2_ + n3_) n_Integer}] :>
product[f, {v, n1, n2 n + n3 n}],
product[f_, {v_, n1_, n2_+n_Integer?Positive}] :>
Product[f, {v, n2 + 1, n2 + n}] product[f, {v, n1, n2}],
product[v_, {v_, n1_, n2_}] :> n2! / n1! /; integer[n1] && integer[n2],
(* Rules for simplifying factorials. *)
(n0_+n_Integer?Positive)! :>
(n0+n-1)! (n0+n),
(n0_+n_Integer?Negative)! :>
(n0+n+1)! / (n0+n+1),
n_! :> infinity /; WeakSimplify[n<0]
};