Oups, obviously I answered too quickly.
Indeed the Robert's method does not function as well as one could hope for it.
I had not seen that. Too much focused on my problem.
Thank you Stavros for yours alternative solution.
Laurent.
-----Message d'origine-----
De : Stavros Macrakis [mailto:macrakis at gmail.com]
Envoy? : lundi 9 octobre 2006 19:03
? : Robert Dodier
Cc : laurent couraud; maxima at math.utexas.edu
Objet : Re: [Maxima] probleme with rule
On 10/8/06, Robert Dodier <robert.dodier at gmail.com> wrote:
On 10/8/06, Stavros Macrakis <macrakis at gmail.com> wrote:
> I'm not sure that pattern matching is the right way to approach this. Why
> not adjoin the equation x=x^2 (which of course implies x=x^a for all
> positive integers a) to your system for each binary variable?
"More than one way to do it" is OK by me so long as every method
works as advertised.
It's fine by me, too. But I want to be sure we're recommending robust, reliable methods.
The original problem statement was: "solve a system of equations including binary variables and
non binary variables". Using tellsimp(after) to simplify x^a simplify to x for all integer a
does not guarantee that Maxima will only use values of x in {0,1}. Try
solve([x*a+y*b=1],[x,y,a,b])
where a and b are declared Binary (with the relevant tellsimpafters). You get the useless
answer
[[a = -(%r2*%r4-1)/%r3, b = %r2, x = %r3, y = %r4]],
which has not taken into account that a and b are Binary. On the other hand,
solve([a*x+b*y=1,a^2=a,b^2=b],[a,b,x,y])
nicely gets you
[[a = 1, b = 0, x = 1, y = %r5],
[a = 0, b = 1, x = %r6, y = 1],
[a = 1, b = 1, x = %r7, y = 1-%r7]]
What is problematic in Maxima is that often
enough the obvious method fails and instead one must try some kind
of obscure workaround; that is the unhelpful kind of MTOWTDI.
Agreed entirely, if indeed the obvious method is a correct method. Just because it works on
some cases doesn't mean it will (or should) work in all cases.
tellsimpafter seems to have resolved the problem to Laurent's satisfaction,
so I guess we should be happy for that.
I am always uncomfortable when I don't understand why a method has worked. In this case, I do
not understand why Maxima has any hope of using tellsimp information to solve an equation
correctly. For example, suppose I tellsimp(f(g(x))=x). Then solve(f(g(x))=3,x) will give the
correct answer, but solve(g(x),x) has no hope.
Do you know if tellrat would be useful in this context?
I tried it in the above simple case, and it doesn't work. Remember, both tellsimp and tellrat
only operate in one direction: they tell Maxima that if there is an expression of a certain
form, it can be simplified to a certain other form. They do *not* impart any other
mathematical information to Maxima; certainly Maxima never uses them in the reverse directly.
tellrat(a^2-a) is *not* the same thing as adjoining a^2-a to every algebraic system.
-s