1 /* bilinear.mac -- define a new opproperty, bilinear
2 * copyright 2018 by Robert Dodier
3 * I release this work under terms of the GNU General Public License
6 define_opproperty (bilinear, expand_bilinear);
7 /* Note that defining the simplification with a Maxima function makes
8 * this operator property susceptible to kill(functions) or kill(all) ...
10 expand_bilinear (e) := apply1 (e, rule_bilinear_1a, rule_bilinear_1b,
11 rule_bilinear_2a, rule_bilinear_2b,
12 rule_bilinear_3a, rule_bilinear_3b,
13 rule_bilinear_4a, rule_bilinear_4b);
15 matchdeclare (bb, lambda ([e], featurep (e, bilinear)));
16 matchdeclare (aa, all, xx, lambda ([e], not atom(e) and op(e) = "+"));
17 defrule (rule_bilinear_1a, bb(xx, aa), map (lambda ([x], bb(x, aa)), xx));
18 defrule (rule_bilinear_1b, bb(aa, xx), map (lambda ([x], bb(aa, x)), xx));
20 matchdeclare ([aa1, aa2], all, ss, lambda ([e], scalarp(e) and e#1));
22 defrule (rule_bilinear_2a, bb(-aa1, aa2), -bb(aa1, aa2));
23 defrule (rule_bilinear_2b, bb(aa1, -aa2), -bb(aa1, aa2));
26 defrule (rule_bilinear_3a, bb(ss*aa1, aa2), ss*bb(aa1, aa2));
27 defrule (rule_bilinear_3b, bb(aa1, ss*aa2), ss*bb(aa1, aa2));
30 defrule (rule_bilinear_4a, bb(aa1/ss, aa2), bb(aa1, aa2)/ss);
31 defrule (rule_bilinear_4b, bb(aa1, aa2)/ss, bb(aa1, aa2)/ss);