Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Problems with With/Block/Module functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64278] Re: Problems with With/Block/Module functions
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 9 Feb 2006 02:44:44 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <dsccna$pae$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Mukhtar Bekkali wrote:
> Hi:
> 
> I want to use local assignment done for a subscripted variable, where
> x1 is ought to be read as x subscript 1, and evaluate at local values
> function g[x1] and use the result later on. My code (not actual, just
> an example) is as follows:
> 
> x1=0;
> With[{x1=1},y=g[x1]] (* is some specific arbitrary function, say x1^2
> *)
> y
> 
> My error message is "Local variable specification {x1=0} contains x1=0
> which is an assignment to x1; only assignments to symbols are allowed"
> Where on earth does Mathematica see a function in x1. To me this is
> just a symbol. Please advise on a workaround. Thanks.
> 
Hi Mukhtar,

You must use the command Symbolize (from the palette) from the package 
Notation to transform x_1 in a symbol. See 
http://documents.wolfram.com/mathematica/Demos/Notations/Functions/NotationDefinitionSymbolize.html

In[1]:=
Needs["Utilities`Notation`"]

In[2]:=
Symbolize[NotationBoxTag[\(x\_1\)]]

In[3]:=
x\[UnderBracket]Subscript\[UnderBracket]1 = 0;
With[{x\[UnderBracket]Subscript\[UnderBracket]1 = 1}, y = 
g[x\[UnderBracket]Subscript\[UnderBracket]1]]

Out[4]=
g[1]

Best regards,
/J.M.


  • Prev by Date: Re: DSolve:: Bessel's differential equation
  • Next by Date: Re: DSolve:: Bessel's differential equation
  • Previous by thread: Re: Problems with With/Block/Module functions
  • Next by thread: DSolve:: Bessel's differential equation