On Tue, May 13, 2003 at 11:42:49AM +0100, Chris Meudec wrote: > Hi all, > I am looking for an arithmetic expressions simplifier. I have been using > tidy.pl by O'Keefe distributed with eclipse but it is quite limited in that it > only simplies ground terms. > > I need something that simplifies say, A+A+A+1+3*A+2+3-B-B into 6*A > + 6-2*B. Basically the output should be in a human readable form. > > Any pointer as to where I might find such a thing? It's not quite what you want, but you may find the linearize library useful (see the reference manual for details). E.g. [eclipse 1]: lib(linearize). linearize.eco loaded traceable 0 bytes in 0.08 seconds Yes (0.08s cpu) [eclipse 2]: linearize(A+A+A+1+3*A+2+3-B-B, Linear, Nonlinear). A = A B = B Linear = [6 * 1, 6 * A, -2 * B] Nonlinear = [] Yes (0.00s cpu) [eclipse 3]: linearize(A+A+A+1+3*A+2+3-B-B, Linear, Nonlinear), delinearize(Linear, Expr). A = A B = B Nonlinear = [] Linear = [6 * 1, 6 * A, -2 * B] Expr = 6 + 6 * A - 2 * B Yes (0.00s cpu) [eclipse 4]: If you have nonlinear bits in your expressions, you need to do some more work... Cheers, WarwickReceived on Tue May 13 12:13:22 2003
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:24 PM GMT GMT