I want to perform an integration of f[w,t,kx,ky]
over t
for several different functions f
. The f
depend on a time t
, is w
-periodic in it and also depends on two factors kx
and ky
. The function is very complicated. So I decided to integrate it for fixed kx
and ky
and then interpolate between those.
I have several w
for which I want to do this individually. In the end, I want a, kx
- and ky
-dependent function for each of these (depending on the inserted function f
).
The concept of my code is the following:
MyInterpolatedIntegration[f_, w_, kLimit_, kSteps_, kx_, ky_] :=
MyInterpolation[MyIntegration[f[#1, #2, #3?, #4?]&, w], kLimit, kSteps][kx, ky]
MyIntegration[function_, w_] :=
Integrate[Exp[(*something*)] function[w, t], {t, 0, 2 Pi/w}]
MyInterpolation[function_, kLimit_, kSteps_] :=
MyInterpolation[function, kLimit, kSteps] =
Interpolation[
Flatten[
Table[
{{κx, κy}, function[κx, κy]},
{κx, -kLimit, kLimit, 2 kLimit/kSteps},
{κy, -kLimit, kLimit, 2 kLimit/kSteps}],
1]]
(* -kLimit to +kLimit with kSteps intermediate steps for both kx and ky *)
I want to pass f[#1, #2, #3, #4]
into MyInterpolation
, which again should pass f[#1, #2, kx, ky]
(with fixed kx
and ky
) to MyIntegration
, which should then perform the integral of f[w, t, kx, ky]
over t
(for fixed kx, ky, w
).
My problem now is that I don't know how to control that #1
becomes w
, #2
becomes t
and #3
and #4
become kx
and ky
(therefore the ?-marks in my code). I can only manage to control the first insertion of arguments. How do you pass a function with free parameters after already inserting some?
(The actual problem is a little more involved and contains functions like Eigensystem
. For the sake of readability, I've tried to narrow the problem down to the smallest reasonable problem.)
Edit:
(I have also fixed an error in my definition of MyInterpolatedIntegration
)
According to request, let me provide an example of what my functions should do. At first let's say f
and MyIntegration
do the following`:
f[w_, t_, kx_, ky_]:= (1+Sin[w*t])*kx*ky
MyIntegration[function_, w_] :=
Integrate[Exp[I*w*t] function[w, t], {t, 0, 2 Pi/w}]
Then I can perform an integration the following way:
In[1]:= MyIntegration[f[#1, #2, 1, 1] &, 1]
Out[1]= I Pi
for w=1
and kx = ky = 1
.
Now I want a similar call for the MyInterpolationFunction
like
In[2]:= MyInterpolation[f[2Pi/3, 0, #1, #2]&, 4, 10]
Out[2]= InterpolatingFunction[(*something*)
Here I used the fixed w = 2Pi/3
, t = 0
and have an interpolation for kx
and ky
both running from -4 to 4 with 10 steps respectively, i.e. the interpolation function will have 100 points to interpolate.
What I'm looking for now, is a function MyInterpolatedIntegration
which does both the integration depending on w
and the interpolation for kx
and ky
. I want to call this function in a way similar to
In[3]:= MyInterpolatedIntegration[f[#1, #2, #3, #4]&, 4, 10, 2Pi/3, 1, 2]
Out[3]= 2 (* I think; maybe I made a mistake here *)]
i.e. I want a function that gives me interpolated value for the integral of f
evaluated at the corresponding entries (here w = 2Pi/3
, kx=1
, ky=2
where the interpolation goes from kx,ky = -4
to kx,ky = 4
with 10 respective intermediate steps).
My problem is that I can't simply call f[#1, #2, #3, #4]&
as an argument. Instead, I need to tell the function in a different manner when every respective parameter will be inserted.
MyIntegration
retuns a scalar for a symbol assigned a value,w = 4
or a function of one variable for an unassigned symbol,w
. You are passing the former so what are to expecting to interpolate from a single scalar variable? $\endgroup$MyIntegration
will be a scalar or a function of one variable. However,MyInterpolation
is expecting a function of two variables. So there are some issues in your concepts that need to be clarified. $\endgroup$f
which depends onw
,t
,kx
andky
overt
, such that the resulting scalar depends onw
,kx
andky
. I will do this for fixed values ofw
. Thus, the scalar corresponding for a specificw
will depend onkx
andky
, respectively. This dependence onkx
andky
I want to interpolate. (Please note that the integration is only a placeholder. What I actually want to do withf
is much more complicated.) The problem is that I want to do the integration with two parameters off
while I want to do the interpolation with the other two. $\endgroup$