I'd like to define a function of three variables which produces a new, named function of a single variable, where this final variable is not a member of the first three. So I'd like something where I have
f0[x_ , y_ , z_] := << complicated function >>
which gives f1[p_]
. Furthermore, I'd like to have the functions be defined in such a way that when I write
IN:= f0[x0,y0,z0]
I get
OUT:= fx0y0z0[p_]
so that I can easily identify which inputs produced the function. So, basically, I'd like to wind up with a function produced via Interpolation and I'd like that function to have a specific name defined by my inputs.
For instance, let's say I'm creating a numerical function by writing down a table in two variables (say, p
and q
) that requires x
, y
, and z
as inputs. Then I'd like to integrate over q
and interpolate over p
so that my final function is just a function over q
only.
So, let's say that my first function is
g[x_,y_,z_,p_,q_] := (x + y + z) p / q
Now I'd like to tabulate this over p
and q
for given values of x
, y
, and z
. Then I'd like to integrate over p
and have a function of q
only. I can for instance do the following
f1[x_,y_,z_] := NIntegrate[
Interpolation[
Flatten[Table[{q, p,
g[x,y,z,p,q]}, {p,p0,p1}, {q,q0,q1}],1]][#,
p], {p, p0, p1}] &
and then this is a well-behaved function of q
which I can make tables of, which I can then plot, integrate, etc. just by writing f1[x0,y0,x0][q]
. But this is not very convenient for me since it requires me to write out a new function name every time I want to examine the behavior as a function of different values of x
, y
, and z
, and I will ultimately need many values of x
, y
, and z
. Is there any way to write a meta-function that is capable of producing a brand new interpolating function of q only, with the name including the input values of x
, y
, and z
?