MathGroup Archive 2006

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

Search the Archive

RE: Function argument

  • To: mathgroup at
  • Subject: [mg67000] RE: [mg66953] Function argument
  • From: "David Park" <djmp at>
  • Date: Tue, 6 Jun 2006 06:28:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


First, write your definition with patterns and with a SetDelayed.

g[a_, f_] := f[a]

Then you can just supply function names...

g[Pi, Sin]

g[a, f]

or you can supply pure functions (Look up Function in Help), which act as
function names.

g[1, a#^2 + b# + c &]
a + b + c

David Park
djmp at

From: Bonny [mailto:Banerjee at]
To: mathgroup at

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.

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.

Is there a way to accomplish this in Mathematica? Any help would be


  • Prev by Date: Re: Division by Zero (Error Handling)
  • Next by Date: Re: Function argument
  • Previous by thread: Re: Function argument
  • Next by thread: Re: Function argument