A few minor points: Maybe your cost function needs a call ratdisrep; try cost(rat(x)). Also, you might consider re-naming cost to something less likely to conflict with a name a user might choose. Finally, radcan transforms (x^a)^b --> x^(a * b). Of course, this isn't an identity for all real x,a,b. Maybe this matters to you, maybe it doesn't. Barton