MathGroup Archive 2010

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

Search the Archive

Re: defining a function of functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110485] Re: defining a function of functions
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 20 Jun 2010 03:47:04 -0400 (EDT)

innerprod[f_, g_] :=
 Sum[
  f[k] Conjugate[g[k]] Part[mylist, k],
  {k, 1, L}]

mylist = Array[c, 5];

L = 3;

innerprod[f, g]

c[1]*f[1]*Conjugate[g[1]] + c[2]*f[2]*Conjugate[g[2]] + 
   c[3]*f[3]*Conjugate[g[3]]

innerprod[f[2, #] &, g]

c[1]*f[2, 1]*Conjugate[g[1]] + c[2]*f[2, 2]*Conjugate[g[2]] + 
   c[3]*f[2, 3]*Conjugate[g[3]]


Bob Hanlon

---- J Davis <texasautiger at gmail.com> wrote: 

=============
I want to define an inner product function such as

(here mylist is a specified list and L is a specified constant)

innerprod[f_, g_] = Sum[f[k]Conjugate[g[k]]Part[mylist,k],{k,1,L}]

This works fine but now I need to apply it in a situation where f is a
function of 2 variables while g is a function of only one variable,
i.e. I want to compute something like the inner product of f[2,n] and
g[n].

Of course, I want the ability to freely vary the first input of f.

I have accomplish this before rather easily but I'm presently drawing
a blank.

Thanks for your help.

Best,
JD




  • Prev by Date: Named patterns forbidden in Except?
  • Next by Date: Re: NotebookDirectory for package (.m) files?
  • Previous by thread: Re: defining a function of functions
  • Next by thread: Re: defining a function of functions