1 /* -*- Mode: macsyma -*- */
3 /*************************************************************************************
4 Demo of enhanced Poisson package.
6 With the default settings, this package should behave exactly as the original Pois2
7 package, with 2 exceptions:
8 1) the guard bit (see below) reduces the field size for the multiplier for each angle.
9 Eg. 30 bits for 6 variables gives a range of +/- 7 instead of +/- 15.
10 [in fact, this makes one of the demo examples fail]
11 2) The algorithm for the `5 argument poissubst' has been changed to resemble a taylor
14 The following demonstrates the new or changed capabilities.
15 *************************************************************************************/
17 /* Default settings */
18 (poisvars:[u,v,w,x,y,z],poislim:30)$
20 /* An option POIS_ENCODE_LIBERALIZE, if True, tells the poisson system to accept trig
21 arguments that are not linear in the poisvars; the remainder is taken into the coefficients.
22 Compare these results:
24 errcatch(intopois(cos(u+q)));
25 block([pois_encode_liberalize:true], intopois(cos(u+q)));
27 /* A Guard bit (per angular variable) has been allocated to the encoded multiples to
28 detect overlows during multiplication. Previously, the overflow went undetected with the
31 intopois(2*cos(4*u)^2); ->
32 /P/ cos(8 z + 8 y + 8 x + 8 w + 8 v) + 1
35 errcatch(intopois(2*cos(4*u)^2));
37 /* There is more flexibility in setting the parameters for encoding the trig arguments.
38 For example, if you need more range for one multiplier than another, consider this:
40 expr:cos(5*u)*cos(2*v);
41 errcatch(intopois(expr^2));
42 pois_setup(u,15,v,7,w,7,x,7,y,7,z,7);
46 /* Trigonometric arguments can also be represented by lists of multipliers in
47 general representation. This is less efficient than packing integers multipliers, but
48 still more efficient than many alternatives.
49 To use this feature, you set POISLIM:FALSE, as if "No Poisson limit". */
50 errcatch(intopois(cos(u+x*v)^2));
52 intopois(cos(u+x*v)^2);
56 /* The following gives the same result as before */
57 poissubst(v,u,sin(u),w,3);
58 /* But this result is different: */
59 poissubst(v,u,sin(2*u),w,3);
60 /* Previously you would get:
61 2 cos(2 v) (w - w^3/6) + 2 sin(2 v) (1 - w^2/2)
62 Does that make sense? (consider w->0) */
64 /* Minor extensions: POISPLUS & POISTIMES take any number of arguments.
65 There is now also a POISMINUS. */
66 poisplus(sin(u),cos(u),cos(u)^2+sin(u));
67 poisminus(sin(u),cos(u),cos(u)^2+sin(u));
68 poistimes(sin(u),cos(u),cos(u)^2+sin(u));
71 (remvalue(expr,expr1,expr2),remfunction(cosfun,sinfun,poistrim),
72 reset(poisvars,poislim,poistrim))$