MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Novice question regarding variable naming and subscripts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28143] RE: [mg28136] Novice question regarding variable naming and subscripts
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 1 Apr 2001 00:08:04 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

William,

There is a simple answer to your question. Use Evaluate in the Plot
statement.

Subscript[F, i][F_] := F + a/2
Plot[Evaluate[Subscript[F, i][F] /. a -> 1],
   {F, 0, 10}];

If my main concern was to get calculations done, and not delve into all the
intricacies of Mathematica, I would try not to get too fancy in my notation.
The subscript, i, doesn't carry any information, so why have it? Also, if a
function has parameters, it is convenient to put them in the definition of
the function. So I might do it this way:

Clear[F];
F[a_][x_] := x + a/2
Plot[F[1][f], {f, 0, 10}];

If you mean to have different functions for different values of i, you could
write:

Clear[F];
F[1][a_][x_] := x + a/2
Plot[F[1][1][f], {f, 0, 10}];

It is possible to obtain fancier notation, for example with the Notations
utility, but then you are probably going to have to spend some time
mastering the in and outs of it.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


> -----Original Message-----
> From: William McHargue [mailto:William at McHargue.Com]
To: mathgroup at smc.vnet.net
> Sent: Saturday, March 31, 2001 2:59 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg28143] [mg28136] Novice question regarding variable naming and
> subscripts
>
>
> Hello to The Math Group,
>
> I am new to this group and have a burning question about Mathematica
> use. (I hope to give back to the group when I have something to
> contribute, but presently I'm still somewhat of a novice.)
>
> In some ways you could call me a "casual" user of Mathematica. I pick it
> up when a project demands, but often never get REALLY good at it.
> Typically I like to use it to both document and define a simulation or
> model. I would like to use the full 2D-input to define the various
> equations involved, but there seems to be a problem when I define, say,
> a function:
>
> F_i[F_]:=F+(a/2);
>
> (where "F_i" implies "F" subscript "i")
>
> Then I wish to, say, plot this function using a variable "F" (no
> subscript) using this:
>
> Plot[ F_i[F]/.a->1, {F, 0, 10}]
>
> When this is evaluated it says:
>
> Plot::"plnr" :  F_i[F]/.a->1 is not a machine-size real number at...
>
> (over and over again, and at valid values)
>
> Yet, it works fine if I pick a different independent variable. I realize
> I could use just "x" instead of "F", but by keeping the actual Input
> Form reading like the common equations in particular applications the
> whole thing is much easier to follow and debug.
>
> I wouldn't be surprised if I do not fully understand the way Mathematica
> manages its name space, but I would like subscripted names to be
> completely independent from their non-subscripted brothers--the way we
> humans might write equations and variables on paper.
>
> Any ideas, or perhaps chapters in the documenation I should dive into
> more deeply?
>
> Thanks in advance for any info in this regard,
>
>
> Bill.
>
> --
> William B. McHargue - Physicist
> <mailto:William at McHargue.Com>
> Yahoo/Jabber IM: William_McHargue
>



  • Prev by Date: Re: C, MathLink or Java, J/Link
  • Previous by thread: Novice question regarding variable naming and subscripts
  • Next by thread: 2D Fourier and Plot3D???