MathGroup Archive 2006

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

Search the Archive

RE: Function argument

  • To: mathgroup at
  • Subject: [mg66977] RE: [mg66953] Function argument
  • From: "Ingolf Dahl" <ingolf.dahl at>
  • Date: Tue, 6 Jun 2006 06:27:04 -0400 (EDT)
  • Reply-to: <ingolf.dahl at>
  • Sender: owner-wri-mathgroup at

Hi Bonny,
Maybe I am missing your point, but it not a good idea to have f[x] as the
second argument of g[a,f[x]]. Since we have not told which part of the
expression f[x] which is the function, and which part is the argument, we
will get into trouble if we substitute f1[f2[x]] as second argument to g.
Should it evaluate to f1[a], or to f1[f2[a]]? We also will get into trouble
in other cases. For instance, should the expression a x^2 + b x + c be seen
as a function of x, or of a, b or c?

You could define

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

if you are not satisfied with the usual notation f[a] or f@a. (What is wrong
with these notations?)
Then g[Pi, Sin] evaluates to 0. If you have set

f[x_] := a x^2 + b x + c

then g[1, f] will evaluate to a + b + c .

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

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

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


x=1; a x^2 + b x + c

will give this result, and there are surely a number of additional ways.

Best regards

Ingolf Dahl

-----Original Message-----
From: Bonny [mailto:Banerjee at] 
To: mathgroup at
Subject: [mg66977] [mg66953] Function argument

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: Animate
  • Next by Date: .NET/Link and two-dimensional strings
  • Previous by thread: Re: Function argument
  • Next by thread: Re: How to make results from Integrate and NIntegrate agree