Hi Jose,

On Thu, Mar 19, 2009 at 7:49 AM, Jose Guzman <[email protected]> wrote:
>
> This is apparently a very easy question, but I am new to the mathematics
> computing environment and it will take me some time to become familiar
> with Sage. The question is the following; Are these two expressions
> similar?
>
> sage: a,b,c = var('a,b,c')
>
> sage: var('a,b,c')
>
> If not, when should I use one or another?

Both of the expressions above are more or less the same in that they
produce the same result, i.e. declaring three symbolic variables. But
note these points. If you do

[1]
sage: a,b,c = var("a,b,c")

then it results in what you expect: namely, declaring the three
specified symbolic variables. Now if you do

[2]
sage: var("a,b,c")
(a, b, c)

Sage does the same thing, but this time the three symbolic variables
are printed to your terminal. The last command actually returns a
tuple of three symbolic variables, so it makes sense to do as per [1].
In Python, command [1] technically unpacks the tuple elements and
store them in the variable names to the left of the equal sign. But if
you do as in [2], then the required symbolic variables would have been
declared even if you don't explicitly store the tuple elements: note
this

sage: var("a,b,c")
(a, b, c)
sage: type(a); type(b); type(c)
<class 'sage.calculus.calculus.SymbolicVariable'>
<class 'sage.calculus.calculus.SymbolicVariable'>
<class 'sage.calculus.calculus.SymbolicVariable'>

Also, if you like command [2] because it's less to type on the
keyboard, then by all means do it. And if you don't want to see the
returned tuple of symbolic variables, you can do this:

sage: var("a,b,c");

-- 
Regards
Minh Van Nguyen

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to