MathGroup Archive 2001

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

Search the Archive

RE: Functions with Variables with Indices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29414] RE: [mg29394] Functions with Variables with Indices
  • From: "David Park" <djmp at earthlink.net>
  • Date: Mon, 18 Jun 2001 03:39:13 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Benjamin,

In my Mathematica Version 4.1 the following statements all work without any
problem.

Subscript[f, 1][x_] := Sin[x]
Plot[Subscript[f, 1][x], {x, 0, 2*Pi}];
Plot[Subscript[f, 1][Subscript[x, 1]],
   {Subscript[x, 1], 0, 2*Pi}];
Plot[Subscript[f, 1][Subscript[x, u]],
   {Subscript[x, u], 0, 2*Pi}];

Still, if you are new at Mathematica, I would recommend staying away from
subscripted variables at first, even though they look nice. Alternatives are
x1 or x[1]. The Notation package allows you do symbolize subscripted
variables and is a safer approach. Carl Woll had a technique of unprotecting
Subscript and then giving it the attribute HoldFirst, (and then protecting
again) which makes subscripted variables safer.

The _ character should only be used on the left hand side of definitions or
rules. It shouldn't ordinarily be used as a variable in an expression. A
space between two characters does indicate multiplication. There must be no
space for a named pattern such as x_.

If you are new at Mathematica it would probably be worthwhile reading
"Suggestion about Learning Mathematica" at the front of the Book, and
working through as much of Part I as seems relevant to you.

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


> From: Benjamin Müller [mailto:Benjamin.M at gmx.de]
To: mathgroup at smc.vnet.net
>
> I recently began programming Mathematica and wonder if it is possible to
> plot functions with variables that have indices. There's always the error:
> f[variable with index] is not a machine-size real number at ... .
> Variables
> without index and following blank (i.e. f[x_]) work fine. However, the
> kernel doesn't understand the blank_ after a variable with index and
> interprets this as "Times". Is there an easy solution, without programming
> several lines to make the kernel understand the subscript in the
> right way?
>
> Thanks a lot,
>
> Benjamin
>
> e-mail response appreciated: Benjamin.M at gmx.de
>
>
>



  • Prev by Date: Re: R: Local iterator
  • Next by Date: RE: R: Local iterator
  • Previous by thread: Re: Functions with Variables with Indices
  • Next by thread: R: Local iterator