Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7792
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!216.196.98.146.MISMATCH!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail |
|---|---|
| From | DrMajorBob <btreat1@austin.rr.com> |
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Can't use subscripted variables in function |
| Date | Sat, 14 Jan 2012 07:55:53 +0000 (UTC) |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Sender | steve@smc.vnet.net |
| Approved | Steven M. Christensen <steve@smc.vnet.net>, Moderator |
| Message-ID | <jerce9$19s$1@smc.vnet.net> (permalink) |
| References | <je96qv$j85$1@smc.vnet.net> <jebngu$1bb$1@smc.vnet.net> |
| Reply-To | drmajorbob@yahoo.com |
| Lines | 63 |
| NNTP-Posting-Date | 14 Jan 2012 07:56:14 GMT |
| NNTP-Posting-Host | 83a3e27b.news.twtelecom.net |
| X-Trace | DXC=N^oUJgQ:VBZ5n;YhJL>R>[C_A=>8kQj6]hHXa^^g6TZTJYk9AMAdoASEFiONJ7[GoVZ6O90AQ2SK] |
| X-Complaints-To | abuse@twtelecom.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:7792 |
Show key headers only | View raw
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
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
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
csiph-web