Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #14045 > unrolled thread
| Started by | juchheissassa@gmail.com |
|---|---|
| First post | 2013-04-04 02:51 +0000 |
| Last post | 2013-04-06 09:10 +0000 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Solve without vars juchheissassa@gmail.com - 2013-04-04 02:51 +0000
Re: Solve without vars debguy <johnandsara2@cox.net> - 2013-04-05 02:30 +0000
Re: Solve without vars "John D. Hendrickson and Sara Darnell" <johnandsara2@cox.net> - 2013-04-06 09:09 +0000
Re: Solve without vars "John D. Hendrickson and Sara Darnell" <johnandsara2@cox.net> - 2013-04-06 09:10 +0000
Re: Solve without vars Andrzej Kozlowski <akozlowski@gmail.com> - 2013-04-06 09:10 +0000
Re: Solve without vars Andrzej Kozlowski <akozlowski@gmail.com> - 2013-04-06 09:10 +0000
| From | juchheissassa@gmail.com |
|---|---|
| Date | 2013-04-04 02:51 +0000 |
| Subject | Solve without vars |
| Message-ID | <kjipr5$3kq$1@smc.vnet.net> |
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))}}
[toc] | [next] | [standalone]
| From | debguy <johnandsara2@cox.net> |
|---|---|
| Date | 2013-04-05 02:30 +0000 |
| Message-ID | <kjlcvu$b6r$1@smc.vnet.net> |
| In reply to | #14045 |
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]
[toc] | [prev] | [next] | [standalone]
| From | "John D. Hendrickson and Sara Darnell" <johnandsara2@cox.net> |
|---|---|
| Date | 2013-04-06 09:09 +0000 |
| Message-ID | <kjoop6$oio$1@smc.vnet.net> |
| In reply to | #14045 |
Thanks andrew that was an interesting read!
Yes about zeros! also one should always be mindful that div/(a-a)
appearing in symbolic solutions during manipulation are not checked,
it makes certain problems solvable in real time, but can miss sol'n.
I'm not sure the inductions hold for all eq'n under Solve. And how
mathematica solves given {}, that may change between versions.
I wouldn't use the inductions myself. I'd supply the options and
check the answer. (I've never needed to use Solve programatically
yet) I don't have the Solve source code and it's not my job to know
it really. Would be nice if I had such a collection and was paid to
tend it :)
I'm saving the mail and reading again later. Thanks - John
[toc] | [prev] | [next] | [standalone]
| From | "John D. Hendrickson and Sara Darnell" <johnandsara2@cox.net> |
|---|---|
| Date | 2013-04-06 09:10 +0000 |
| Message-ID | <kjoopb$oit$1@smc.vnet.net> |
| In reply to | #14045 |
oh i forgot. some methods used are given in the Mathematica Book Appendix "Implementation Notes". though I didn't see much there about polynomial eq'n and solve
[toc] | [prev] | [next] | [standalone]
| From | Andrzej Kozlowski <akozlowski@gmail.com> |
|---|---|
| Date | 2013-04-06 09:10 +0000 |
| Message-ID | <kjoopr$oj9$1@smc.vnet.net> |
| In reply to | #14045 |
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)}}
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))}}
>>
>
>>
>
[toc] | [prev] | [next] | [standalone]
| From | Andrzej Kozlowski <akozlowski@gmail.com> |
|---|---|
| Date | 2013-04-06 09:10 +0000 |
| Message-ID | <kjooq6$ojd$1@smc.vnet.net> |
| In reply to | #14045 |
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))}}
>>>
>>
>>>
>>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web