Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Solve without vars
Replies: 4   Last Post: Apr 6, 2013 5:10 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Andrzej Kozlowski

Posts: 226
Registered: 1/29/05
Re: Solve without vars
Posted: Apr 6, 2013 5:10 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


On 5 Apr 2013, at 22:33, Andrzej Kozlowski <akoz@mimuw.edu.pl> wrote:

> Yes, giving an empty list of variables is the same as giving no
variables at all, and no, Solve does not assume that all symbols are
variables. It assumes that y and b are variables and a and x parameters.
The reason why it makes these choices seems a little subtle.
>
>
> The clearest indication that Solve is not assuming that all symbols

are variables is the fact that it does not produce the message that it
produces here:
>
> Solve[{b*x + y == 7 && a*x - y == 1}, {x, y, a, b}]
> Solve::svars:Equations may not give solutions for all "solve"

variables. >>
> {{y -> -1 + a*x, b -> (8 - a*x)/x}}
>
> In fact, what Solve seems to do is something like the following.
>
> First y is expressed in terms of x and b as y = 7 - b x. The reason

why Solve choses to treat y in this way (as a "variable" rather than a
"parameter") by doing so it does not have to make any assumptions at all
about the other symbols. If it chose x as a "variable" (meaning, that it
would have tried to express x in terms of y and a) it would have to make
the assumption that a is non-zero and it wants to make as few
assumptions as possible. Similarly, if it chose a as a variable, it
would have to assume that x is non-zero. The choice of you is the only
one that allows it to make no assumptions at this stage.
>
> However, as a result of this choice, Solve is now "forced" to treat a

and x as "parameters" (since they were used in the solution for y).
> Now, by substituting for y into the second equation, Solve gets an
equation involving a, b, and x. However, since a and x are now being
treated as "parameters", b has to became a "variable" and the solution
obtained turns out to be exactly the same as given by:
>
> Solve[{x + b*y == 7 && a*x - y == 1}, {y, b}]
>
> {{y -> -1 + a*x, b -> (7 - x)/(-1 + a*x)}}



I pasted the wrong code here. It should have been (of course):

Solve[{b*x + y == 7 && a*x - y == 1}, {y, b}]
{{y -> -1 + a*x, b -> -((-8 + a*x)/x)}}

This is exactly equivalent to what happens when you call Solve without
specifying variables:

Solve[{b*x + y == 7 && a*x - y == 1}]
{{y -> 7 - b*x, a -> (8 - b*x)/x}}


>
> You can easily check that this behaviour is not dependent on the

symbols used for the variables - only on their role in the equations.
>
> Next, something that seems to me more interesting. If you change these

equations somewhat you will see behaviour that may appear even more
surprising.
>
> Solve[{x + b*y == 7 && a*x - y == 1}]
>
> {{a -> (1 + y)/x, b -> (7 - x)/y}, {a -> 1/7, y -> 0, x -> 7}, {b -> -7, y -> -1, x -> 0}}
>
> Here Solve returned a list of solutions rather than one solution. The

first is the same one it returns when called with variable specification
{a,b}:
>
> Solve[{x + b*y == 7 && a*x - y == 1}, {a, b}]
>
> {{a -> (1 + y)/x, b -> (7 - x)/y}}
>
> This solution of course requires assumptions on the "parameters" x,y

i.e. x!=0 and y!=0. In general, when called with specific variables,
Solve by default does not return solutions that involve assumptions on
parameters. However the assumption that a parameter is non-zero is
normally not excluded, in other words, it is not really considered "an
assumption". But when called without specified variables Solve actually
does something that it normally does not do : it actually considers the
special cases x==0 and y==0 separately and returns two
additional solutions.
>
> Note how similar the result of Solve is to the one given by Reduce:
>
> Solve[{x + b*y == 7 && a*x - y == 1}]
>
> {{a -> (1 + y)/x, b -> (7 - x)/y}, {a -> 1/7, y -> 0, x -> 7}, {b -> -7, y -> -1, x -> 0}}
>
> Reduce[{x + b*y == 7 && a*x - y == 1}]
> (y == -1 && x == 0 && b == -7) || (y == 0 && x == 7 && a == 1/7) ||
> (y != 0 && b == (7 - x)/y && x != 0 && a == (1 + y)/x)
>
> All this is completely undocumented and in fact even appears to contradict the documentation, since Solve does appear to be actually returning solutions that require parameters to have special values. Of course only stated that this is not done when variables are explicitly specified. Since we do not specify variables we are in undocumented territory and Solve is not obliged to follow the behavior documented for the case of specified variables.
>
> Andrzej Kozlowski
>
>
>
>
>
> On 5 Apr 2013, at 11:33, debguy <johnandsara2@cox.net> wrote:
>

>> test if these are the same (all Symbols assumed variables, i think):
>>
>> Solve[a x + y == 7 && b x - y == 1, {}]
>>
>> Solve[a x + y == 7 && b x - y == 1]

>
>> On 4 Apr 2013, at 11:53, juchheissassa@gmail.com wrote:
>>

>>> I happened to hit on the following curious thing:
>>>
>>> If I use Solve with {} instead of vars, I actually get a solution.
>>>
>>> Is this documented anywhere? What are the rules?
>>>
>>> e.g.:
>>>
>>> Solve[a x + y == 7 && b x - y == 1, {}] yields {{y -> 7 - a x, b -> (8 - a x)/x}}
>>>
>>> while
>>>
>>> Solve[a x + y == 7 && b x - y == 1, {x,y}] yields {{x -> 8/(a + b), y -> -((a - 7 b)/(a + b))}}
>>>

>>
>>>
>>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.