Services & Resources / Wolfram Forums
MathGroup Archive
*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: Function argument

  • To: mathgroup at
  • Subject: [mg66992] Re: Function argument
  • From: Bill Rowe <readnewsciv at>
  • Date: Tue, 6 Jun 2006 06:28:07 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 6/5/06 at 3:47 AM, Banerjee at (Bonny) wrote:

>I would like to define a function g that evaluates another function
>f at a given value. That is,

>g[a, f[x]] := f[a]

>For example, I might want the function f[x]=ax^2+bx+c to be
>evaluated at x=1 and get the result a+b+c. That is,

>g[1, ax^2+bx+c] should evaluate to a+b+c.

Note in Mathematica ax is distinctly different from a x or a*x. So, unless g is written in an unusual way, g[1,ax^2+bx+c] will not evaluate to a+b+c

But it is quite easy to create a function that will return what you want given the arguments 1 and a*x^2+b*x+c. For example,

g[a_, f_] := f /. x -> a

g[1,a x^2+b x+c]


>Again, I might want the function f[x]=Sin[x] to be evaluated at x=pi
>and get the result 0. That is,

>g[pi, Sin[x]] should evaluate to 0.



Note, the definition I've used for g assumes x as the independent variable. Also, I wonder why you want such a function since it as easy (if not easier) to write

a x^2 + b x + c /. x -> 1


instead of g[1,a x^2+b x+c]
To reply via email subtract one hundred and four

  • Prev by Date: Re: Re: Colored Tick Labels?
  • Next by Date: RE: Animate
  • Previous by thread: Re: Function argument
  • Next by thread: RE: Function argument