Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7653 > unrolled thread

Re: Can't use subscripted variables in function definition?

Started byBill Rowe <readnews@sbcglobal.net>
First post2012-01-08 09:26 +0000
Last post2012-01-14 07:55 +0000
Articles 7 — 5 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Can't use subscripted variables in function definition? Bill Rowe <readnews@sbcglobal.net> - 2012-01-08 09:26 +0000
    Re: Can't use subscripted variables in function definition? Armand Tamzarian <mike.honeychurch@gmail.com> - 2012-01-09 08:20 +0000
    Re: Can't use subscripted variables in function definition? Ralph Dratman <ralph.dratman@gmail.com> - 2012-01-10 10:56 +0000
      Re: Can't use subscripted variables in function definition? Chris Young <cy56@comcast.net> - 2012-01-13 09:54 +0000
      Re: Can't use subscripted variables in function definition? Armand Tamzarian <mike.honeychurch@gmail.com> - 2012-01-14 07:58 +0000
        Re: Can't use subscripted variables in function definition? Armand Tamzarian <mike.honeychurch@gmail.com> - 2012-01-15 09:50 +0000
    Re: Can't use subscripted variables in function DrMajorBob <btreat1@austin.rr.com> - 2012-01-14 07:55 +0000

#7653 — Re: Can't use subscripted variables in function definition?

FromBill Rowe <readnews@sbcglobal.net>
Date2012-01-08 09:26 +0000
SubjectRe: Can't use subscripted variables in function definition?
Message-ID<jebngu$1bb$1@smc.vnet.net>
On 1/7/12 at 5:25 AM, cy56@comcast.net (Chris Young) wrote:

>What is the status of subscripted variables in Mathematica now?

It has not changed in version 8.

>Can't they finally be used as regular variables?

Yes, but not by default. You can use subscripted variables like
ordinary variables using the Notation package. However, from my
perspective this is more effort than it is worth.

>Or is there some workaround so that they can be? This is time-honored,
>very intuitive mathematical notation that should be available, IMO.

Yes, it would be useful to have subscripted variables fully
integrated into Mathematica. And, that may well happen in some
future version. But for now, it seems to me this is simply one
of the limitations Mathematica has.

[toc] | [next] | [standalone]


#7681

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2012-01-09 08:20 +0000
Message-ID<jee805$cui$1@smc.vnet.net>
In reply to#7653
On Jan 8, 8:26 pm, Bill Rowe <readn...@sbcglobal.net> wrote:
> On 1/7/12 at 5:25 AM, c...@comcast.net (Chris Young) wrote:
>
> >What is the status of subscripted variables in Mathematica now?
>
> It has not changed in version 8.
>
> >Can't they finally be used as regular variables?
>
> Yes, but not by default. You can use subscripted variables like
> ordinary variables using the Notation package. However, from my
> perspective this is more effort than it is worth.
>
> >Or is there some workaround so that they can be? This is time-honored,
> >very intuitive mathematical notation that should be available, IMO.
>
> Yes, it would be useful to have subscripted variables fully
> integrated into Mathematica. And, that may well happen in some
> future version. But for now, it seems to me this is simply one
> of the limitations Mathematica has.


I recently ported 90 pages of code from a competitor product -- mainly
used by engineers -- to Mathematica for someone. The code was heavily
subscripted because subscripted variables in the competitor product
were pretty easy and essentially worked out of the box the way you
would expect without a learning curve or any other issues. The were
other reasons to justify the port to Mathematica but it was quite enlightening
to see code in which subscripted symbolic variables were so natural
and frankly made me wonder why Mathematica is behind the curve on this. Lets
hope V9 offers this.

Mike

[toc] | [prev] | [next] | [standalone]


#7698

FromRalph Dratman <ralph.dratman@gmail.com>
Date2012-01-10 10:56 +0000
Message-ID<jeh5h4$r2n$1@smc.vnet.net>
In reply to#7653
Is this just a discussion about how things look on the screen -- or is
there some deeper difference between Mathematica's "array" indices and
properly-implemented subscripts?

Ralph

On Mon, Jan 9, 2012 at 3:16 AM, Armand Tamzarian
<mike.honeychurch@gmail.com> wrote:
> On Jan 8, 8:26 pm, Bill Rowe <readn...@sbcglobal.net> wrote:
>> On 1/7/12 at 5:25 AM, c...@comcast.net (Chris Young) wrote:
>>
>> >What is the status of subscripted variables in Mathematica now?
>>
>> It has not changed in version 8.
>>
>> >Can't they finally be used as regular variables?
>>
>> Yes, but not by default. You can use subscripted variables like
>> ordinary variables using the Notation package. However, from my
>> perspective this is more effort than it is worth.
>>
>> >Or is there some workaround so that they can be? This is time-honored,
>> >very intuitive mathematical notation that should be available, IMO.
>>
>> Yes, it would be useful to have subscripted variables fully
>> integrated into Mathematica. And, that may well happen in some
>> future version. But for now, it seems to me this is simply one
>> of the limitations Mathematica has.
>
>
> I recently ported 90 pages of code from a competitor product -- mainly
> used by engineers -- to Mathematica for someone. The code was heavily
> subscripted because subscripted variables in the competitor product
> were pretty easy and essentially worked out of the box the way you
> would expect without a learning curve or any other issues. The were
> other reasons to justify the port to Mathematica but it was quite enlightening
> to see code in which subscripted symbolic variables were so natural
> and frankly made me wonder why Mathematica is behind the curve on this. Lets
> hope V9 offers this.
>
> Mike
>
>

[toc] | [prev] | [next] | [standalone]


#7778

FromChris Young <cy56@comcast.net>
Date2012-01-13 09:54 +0000
Message-ID<jeov14$g5i$1@smc.vnet.net>
In reply to#7698
On 2012-01-10 10:56:36 +0000, Ralph Dratman said:

> Is this just a discussion about how things look on the screen -- or is
> there some deeper difference between Mathematica's "array" indices and
> properly-implemented subscripts?

I was looking for subscripted variables to conveniently extend notation 
for things such as points determining a polynomial, and so on. Formulas 
to do this kind of thing appear in all the math refererences with 
subscripted variables, and I think it's the most natural notation. 
We're not really interested in an array of points, just the individual 
points, in this case. It's simply a more uncluttered notation.

Chris

[toc] | [prev] | [next] | [standalone]


#7798

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2012-01-14 07:58 +0000
Message-ID<jerck2$1cp$1@smc.vnet.net>
In reply to#7698
For me it is not about looks because I think Mathematica typesetting/
rendering is miles ahead of competitor products. It is about ease of
use. There is Symbolize in the Notations package which can get you
closer to something that works better but the best analogy i can think
of of how the other product works is if instead of Subscript you had a
function SubscriptVariable in which the subscript was a different
context e.g. SubscriptVariable[Global`x, NewContext`i] rendered as x
subscript i.

Mike

On Jan 10, 9:56 pm, Ralph Dratman <ralph.drat...@gmail.com> wrote:
> Is this just a discussion about how things look on the screen -- or is
> there some deeper difference between Mathematica's "array" indices and
> properly-implemented subscripts?
>
> Ralph
>
> On Mon, Jan 9, 2012 at 3:16 AM, Armand Tamzarian
>
>
>
>
>
>
>
> <mike.honeychu...@gmail.com> wrote:
> > On Jan 8, 8:26 pm, Bill Rowe <readn...@sbcglobal.net> wrote:
> >> On 1/7/12 at 5:25 AM, c...@comcast.net (Chris Young) wrote:
>
> >> >What is the status of subscripted variables in Mathematica now?
>
> >> It has not changed in version 8.
>
> >> >Can't they finally be used as regular variables?
>
> >> Yes, but not by default. You can use subscripted variables like
> >> ordinary variables using the Notation package. However, from my
> >> perspective this is more effort than it is worth.
>
> >> >Or is there some workaround so that they can be? This is time-honored=
,
> >> >very intuitive mathematical notation that should be available, IMO.
>
> >> Yes, it would be useful to have subscripted variables fully
> >> integrated into Mathematica. And, that may well happen in some
> >> future version. But for now, it seems to me this is simply one
> >> of the limitations Mathematica has.
>
> > I recently ported 90 pages of code from a competitor product -- mainly
> > used by engineers -- to Mathematica for someone. The code was heavily
> > subscripted because subscripted variables in the competitor product
> > were pretty easy and essentially worked out of the box the way you
> > would expect without a learning curve or any other issues. The were
> > other reasons to justify the port to Mathematica but it was quite enlig=
htening
> > to see code in which subscripted symbolic variables were so natural
> > and frankly made me wonder why Mathematica is behind the curve on this.=
 Lets
> > hope V9 offers this.
>
> > Mike

[toc] | [prev] | [next] | [standalone]


#7852

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2012-01-15 09:50 +0000
Message-ID<jeu7gh$j5u$1@smc.vnet.net>
In reply to#7798
I should clarify that a bit because it was written in haste. Firstly I
meant SubscriptVariable[NewContext`x, NewContext`i] but this isn't
really a proper solution but reason I mentioned it was because if you
have x_j and you want that to be a single symbol you run into problems
if x or j or both are set to some other global value. With x_j and
then x=2 you don't want 2_j you still want x_j returned. Symbolize
addresses this but the point of the original comment is that is it
nowhere near as straight forward as the other product to work with
subscripts.

Mike

On Jan 14, 6:58 pm, Armand Tamzarian <mike.honeychu...@gmail.com>
wrote:
> For me it is not about looks because I think Mathematica typesetting/
> rendering is miles ahead of competitor products. It is about ease of
> use. There is Symbolize in the Notations package which can get you
> closer to something that works better but the best analogy i can think
> of of how the other product works is if instead of Subscript you had a
> function SubscriptVariable in which the subscript was a different
> context e.g. SubscriptVariable[Global`x, NewContext`i] rendered as x
> subscript i.
>
> Mike
>
> On Jan 10, 9:56 pm, Ralph Dratman <ralph.drat...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Is this just a discussion about how things look on the screen -- or is
> > there some deeper difference between Mathematica's "array" indices and
> > properly-implemented subscripts?
>
> > Ralph
>
> > On Mon, Jan 9, 2012 at 3:16 AM, Armand Tamzarian
>
> > <mike.honeychu...@gmail.com> wrote:
> > > On Jan 8, 8:26 pm, Bill Rowe <readn...@sbcglobal.net> wrote:
> > >> On 1/7/12 at 5:25 AM, c...@comcast.net (Chris Young) wrote:
>
> > >> >What is the status of subscripted variables in Mathematica now?
>
> > >> It has not changed in version 8.
>
> > >> >Can't they finally be used as regular variables?
>
> > >> Yes, but not by default. You can use subscripted variables like
> > >> ordinary variables using the Notation package. However, from my
> > >> perspective this is more effort than it is worth.
>
> > >> >Or is there some workaround so that they can be? This is time-honor=
ed=
> ,
> > >> >very intuitive mathematical notation that should be available, IMO.
>
> > >> Yes, it would be useful to have subscripted variables fully
> > >> integrated into Mathematica. And, that may well happen in some
> > >> future version. But for now, it seems to me this is simply one
> > >> of the limitations Mathematica has.
>
> > > I recently ported 90 pages of code from a competitor product -- mainl=
y
> > > used by engineers -- to Mathematica for someone. The code was heavily
> > > subscripted because subscripted variables in the competitor product
> > > were pretty easy and essentially worked out of the box the way you
> > > would expect without a learning curve or any other issues. The were
> > > other reasons to justify the port to Mathematica but it was quite enl=
ig=
> htening
> > > to see code in which subscripted symbolic variables were so natural
> > > and frankly made me wonder why Mathematica is behind the curve on thi=
s.=
>  Lets
> > > hope V9 offers this.
>
> > > Mike

[toc] | [prev] | [next] | [standalone]


#7792 — Re: Can't use subscripted variables in function

FromDrMajorBob <btreat1@austin.rr.com>
Date2012-01-14 07:55 +0000
SubjectRe: Can't use subscripted variables in function
Message-ID<jerce9$19s$1@smc.vnet.net>
In reply to#7653
a[i] is less cluttered than Subscript[a,i], it works better as a variable,  
and it's easier to enter and access.

If you want a[i] to LOOK like Subscript[a,i] in displayed results, you can  
execute:

subFunction[
   a_Symbol] := (MakeExpression[SubscriptBox[ToString@a, i_], f_] :=
    MakeExpression[RowBox[{ToString@a, "[", i, "]"}]];
   MakeBoxes[a[i_], f_] :=
    SubscriptBox[MakeBoxes[a, f], MakeBoxes[i, f]])

subFunction[a]
Array[a, 10]

{Subscript[a, 1], Subscript[a, 2], Subscript[a, 3], Subscript[a, 4], \
Subscript[a, 5], Subscript[a, 6], Subscript[a, 7], Subscript[a, 8], \
Subscript[a, 9], Subscript[a, 10]}

You'll see subscripts only when a value is not defined, but that's true  
for subscripted variables, too. For instance:

a[2] = 3;
Subscript[a, 5] = 12;
Array[a, 10]

{Subscript[a, 1], 3, Subscript[a, 3], Subscript[a, 4], 12, \
Subscript[a, 6], Subscript[a, 7], Subscript[a, 8], Subscript[a, 9], \
Subscript[a, 10]}

and also

Table[Subscript[a, n], {n, 10}]

{Subscript[a, 1], 3, Subscript[a, 3], Subscript[a, 4], 12, \
Subscript[a, 6], Subscript[a, 7], Subscript[a, 8], Subscript[a, 9], \
Subscript[a, 10]}

Bobby

On Fri, 13 Jan 2012 03:52:54 -0600, Chris Young <cy56@comcast.net> wrote:

> On 2012-01-10 10:56:36 +0000, Ralph Dratman said:
>
>> Is this just a discussion about how things look on the screen -- or is
>> there some deeper difference between Mathematica's "array" indices and
>> properly-implemented subscripts?
>
> I was looking for subscripted variables to conveniently extend notation
> for things such as points determining a polynomial, and so on. Formulas
> to do this kind of thing appear in all the math refererences with
> subscripted variables, and I think it's the most natural notation.
> We're not really interested in an array of points, just the individual
> points, in this case. It's simply a more uncluttered notation.
>
> Chris
>
>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web