MathGroup Archive 2006

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

Search the Archive

Re: new function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67305] Re: new function
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Sat, 17 Jun 2006 04:36:28 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 6/16/06 at 12:27 AM, gianfred at le.infn.it wrote:

>I'm writing a package and I want to define a function of the
>form: Function[a_,{list_}], where "a" is a generic expression of
>more variables and "list" is a list of those variable that must go
>to zero. So in this way, Function automatically eliminate the
>variables that I specify after the comma. How can I create this
>function?

If it is acceptable to literally substitute zero for each of the variables this is quite simple. For example, the following will do the trick

zeroVars[a_, varList_]:=a/.Thread[varList->0]

For an arbitrary polynomial

poly = 10*z^3 + 14*z^2 + 2*z + 19*x^2 + y + 11;

In[19]:=
zeroVars[poly,{x,z}]

Out[19]=
y+11

or

In[20]:=
zeroVars[poly,{y,z}]

Out[20]=
19 x^2 + 11

But note in general simply substituting 0 for the variables will not give useful results. For example, if the expression contained Sin[x]/x and x were the variable to be "zeroed" you would get an indeterminate result from this simple substitution
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: vertical or perpendicular offets?
  • Next by Date: Re: vertical or perpendicular offets?
  • Previous by thread: new function
  • Next by thread: Re: new function