On Sep 13, 12:08 pm, Pong <wypo...@gmail.com> wrote:
> y,z=var('y,z'); solve(6*x + 10*y + 15*z ==1,x,y,z) gives
> ([{x: -5/3*y - 5/2*z + 1/6}], [1])
So wacky. Definitely a bug, needless to say.
> ([x == -y + 3], [1])
>
> My questions are:
> 1) Why the notation are different in the 2 and 3-variable case? One
> gives x: and the other x==
>
Well, you are asking for solutions to both x *and* y, but the solve is
really designed to solve one in terms of the other(s). I just think
no one has pointed out this weirdness before. So you are using it in
a way it wasn't intended. I'm not sure whether we should add the
use, or have a warning, or both, or neither, or documentation, or...
Maybe we should put in a check for the expression having more than one
variable before we send it to a.solve(), or maybe it just needs that
long-awaited rewrite... see http://trac.sagemath.org/sage_trac/wiki/symbolics
for some issues with solve.
> 3) In order to get the parameters appear in the solution, one need to
> add a redundant equation. Shall we improve on that?
> e.g.
> solve([x+y==3,2*x+2*y==6],x,y)
> [[x == -r1 + 3, y == r1]]
I think this is because when you do that, now the input is multiple,
and instead of doing Expression.solve(), it does the main solve()
routine, which deals with this.
Thoughts from others who care about "solve"? I'm not quite sure what
the best solution is. The easiest one is making really big letters in
the documentation that say "don't do this" and trying to catch these
cases.
The problem is that two different methods are used, depending on if you
give one equation or multiple equations. If you give one equation, then
having multiple variables is not handled correctly.
Personally, I'm in favor of deprecating the solve(eq, x,y) or solve(list
of equations, x,y,z) syntax, and would prefer that the variables be
specified as a list:
solve(eq, [x,y]) or
solve(list of equations, [x,y,z])
Note that currently, solve(list of equations, [x,y,z]) works, and
internally, solve(list of equations, x,y,z) is converted to solve(list
of equations, (x,y,z)) anyway.
Thanks,
Jason
P.S. I wish we had keyword-only arguments
(http://www.python.org/dev/peps/pep-3102/), so that we could clearly
distinguish between the variables and optional keyword parameters, but
alas, we have to wait until we migrate to python3 since
http://bugs.python.org/issue1745 didn't get into python 2.7.
the deprecation could go in now, though.
>
>> solve(eq, [x,y]) or
>> solve(list of equations, [x,y,z])
>
> Though I should point out, in fairness, that Maxima requires this -
> see http://maxima.sourceforge.net/docs/manual/en/maxima_20.html#IDX850
> - so maybe we were wrong.
So does mathematica: http://reference.wolfram.com/mathematica/ref/Solve.html
and maple: http://www.maplesoft.com/support/help/Maple/view.aspx?path=solve
Jason
On 9/13/11 12:48 PM, kcrisman wrote:
>> Personally, I'm in favor of deprecating the solve(eq, x,y) or solve(list
>> of equations, x,y,z) syntax, and would prefer that the variables be
>> specified as a list:
>
> Backwards-incompatible, hence fodder for the mythical Sage 5.0 ...the deprecation could go in now, though.
We could, just like we handle both now when we have multiple equations.
Again, my personal preference is to pass the variables as a list,
though. It's cleaner, in that it groups the variables together and
separates them from the other solve arguments.
Thanks,
Jason
(Aside, that has nothing to do with this particular solve issue.)
We deprecate after one year. I think deprecation should have nothing
to do with "sage 5.0". The policy, which we agreed on long ago is
deprecation after one year (minimum), except when there is a
compelling argument otherwise (e.g., combinat's pickles).
-- William
>
>> solve(eq, [x,y]) or
>> solve(list of equations, [x,y,z])
>
> Though I should point out, in fairness, that Maxima requires this -
> see http://maxima.sourceforge.net/docs/manual/en/maxima_20.html#IDX850
> - so maybe we were wrong.
>
>> P.S. I wish we had keyword-only arguments
>> (http://www.python.org/dev/peps/pep-3102/), so that we could clearly
>
> Huh, that is interesting.
>
> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>
--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org