4
$\begingroup$

I have an orthogonal function in the integral. My job is to evaluate it and use the result for next step.
To give you an idea, let me have an example,

ω := 100; (* =(2*π)/T *)
J1[j1_, t_] := j1 Cos[ω t]^2; 
J2[j2_, t_] := j2 Cos[ω t];;
int[j1_,j2_] = 
            (1/T)Integrate[
              Exp[-I*m*ω*t]*Sqrt[J1[j1, t]^2 + J2[j1, t]^2 + 
                 2 J1[j1, t] J2[j1, t] Cos[ka]]*Exp[I*n*ω*t], 
                                                  {t, 0, T}]

Usually Mathematica doesn't give results in that format, but I am not pasting the result as the format contains Subscript and other words and a huge expressions (which looked good in Mathematica but not when copied into Mathematica.SE). Anyway,here is the result of Mathematica(for the above code) enter image description here

To make my query more clear, I am expecting the result as(an example)

intexpect[j1_, n_, m_] := (1/T)Integrate[
                      Exp[-I*m*ω*t]*J1[j1, t]*Exp[I*n*ω*t], 
                                                {t, 0, T}];
intexpect[j1_, n_, m_] := (j1/4)*δ(n,m+2)+(j1/4)*δ(n,m-2)

where δ is Kronecker Delta.

Is there a way in Mathematica to evaluate it in the Kronecker Delta (even for some fixed $n$ and $m$ in the above code) format. By making use of the orthogonality property of exponentials (by properly defining the integral in Mathematica, to give such results)? Or am I missing some essential point?

$$ (e_n, e_m) = \frac{1}{T}\int_0^T e^{2\pi int}e^{-2\pi imt}dt = \delta_{n,m}$$

Otherwise, I have to calculate the integral by hand and then write the results of the surviving terms in Mathematica. This is cumbersome because I need to carry it out for many different cases and then write a new Mathematica file for each case.

After I tried it from my side(but for fix value of $n$ and $m$)

ClearAll;
T := 1;
\[Omega] := 2 \[Pi]/T;
J1[j1_, t_] := j1 Cos[\[Omega] t]^2;
J2[j2_, t_] := j2;
intexp[j1_, n_, m_] := 
  Module[{n1 = n, m1 = m}, 
   (1/T)Integrate[
    Exp[-I*m1*\[Omega]*t]*J1[j1, t]*Exp[I*n1*\[Omega]*t], {t, 0, 
     T}]];
intexp[j1, 1, 1]
Out[99]= j1/2

I can see from the functions in integrand and using Fourier transform (is that is the only way to solve and get the surviving terms?)

As I am still new to Mathematica, please forgive me for any obvious or unrelated questions.

Addendum:
(i) When I am using NIntegrate in my just above code(where I tried from side, it is giving error). For later purpose, I need Numerical evaluation of the integral.
There are bunch of errors(three of them):

NIntegrate::izero :  Integral and error estimates are 0 on all integration subregions. Try increasing the value of the MinRecursion option. If value of integral may be 0, specify a finite value for the AccuracyGoal option.
NIntegrate::inumr :  The integrand E^(6 I \[Pi] t) (-E^(I k) j2-j1 Cos[\[Pi] t]^2) has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,2}}.
NIntegrate::inumr :  The integrand E^(4 I \[Pi] t) (-E^(-I k) j2-j1 Cos[\[Pi] t]^2) has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,2}}.    

(ii) When I writing $n=1, m=3$, unexpected result is coming.

\begin{array}{cc}
 0 & -0.195312  \text{j1} \\
 -0.195312  \text{j1} & 0 \\
\end{array}

Instead of j1/4 on either side

$\endgroup$
  • $\begingroup$ Could you clarify the question? Its very difficult to understand what you want to achieve. Integrate is symbolic integration. Do you need a symbolic solution? In part "Mathematica don't give result...", you mention some expression. What did you mean by that? If some error is thrown, add it to the question. Do not worry about Subscript, because we can paste the expression in Mathematica for proper formatting. $\endgroup$ – ercegovac Feb 4 '17 at 20:38
  • $\begingroup$ @ercegovac Please see the edit $\endgroup$ – Shamina Feb 5 '17 at 15:07
  • $\begingroup$ You might be able to use FourierSeries for this particular class of example. $\endgroup$ – Daniel Lichtblau Feb 6 '17 at 15:35
  • $\begingroup$ @DanielLichtblau Can you enlighten a little bit? $\endgroup$ – Shamina Feb 6 '17 at 18:20
  • $\begingroup$ With difficulty. The question is carelessly worded. I doubt an omega belongs, the J1 might or might not correspond to BesselJ, the T probably needs to be a multiple of 2*Pi, etc. What I had in mind can be seen from the two results below. In[1662]:= intexpect1[j1_, n_Integer, m_Integer] := 1/(2*Pi) Integrate[Exp[-I*(m - n)*t]*BesselJ[j1, t], {t, -Pi, Pi}] intexpect1[3, 4, 3] FourierCoefficient[BesselJ[3, t], t, -1] Out[1663]= (I (\[Pi] BesselJ[0, \[Pi]] + 4 BesselJ[1, \[Pi]]))/\[Pi] Out[1664]= (I (\[Pi] BesselJ[0, \[Pi]] + 4 BesselJ[1, \[Pi]]))/\[Pi] $\endgroup$ – Daniel Lichtblau Feb 6 '17 at 20:07
4
$\begingroup$

Finally, I come up with my answer, mainly help from MMSE and self. It works sufficiently fast and it avoids such nasty integrals. These integrals become pain in the neck, to show I used J1[j2_, t_] := j1 Cos[ω t]; if the function grows like this J1[j2_, t_] := j1 Cos[ω t]^8;. This approach starts to cry and take a long time.
But using Fourier Transform in Mathematica, one can avoid such nasty integrations, This is what was my problem

J1[j2_, t_] := j1 Cos[ω t];

intexp[j1_, n_, m_] := 
  Module[{n1 = n, m1 = m}, 
   (1/T)Integrate[
    Exp[-I*m1*ω*t]*J1[j1, t]*Exp[I*n1*ω*t], {t, 0, 
     T}]];

Changing to FourierTransform: Only difference is Cos without ω in this case.

ForInt[j1_, n_Integer, m_Integer] = 
  FourierTransform[M1[j1, t], t, n, 
    FourierParameters -> {-1, 1}] /. 
   DiracDelta[x_] :> KroneckerDelta[x, m];

To test the efficiency:

In[1]:= 
T = 1/10; (*Time Period of the external driving field*)
ω = (2*\
\[Pi])/T;
M1[j1_, t_] := j1 Cos[ t]^4
J1[j1_, t_] := j1 Cos[ ω t]^4
ForInt[n_Integer, m_Integer, k_] = 
  FourierTransform[M1[j1, t], t, n, FourierParameters -> {-1, 1}] /. 
   DiracDelta[x_] :> KroneckerDelta[x, m];
First@AbsoluteTiming[ForInt[1, 3, k]]
intexp[j1_, n_, m_] := 
  Module[{n1 = n, 
    m1 = m}, (1/T) Integrate[
     Exp[-I*m1*ω*t]*J1[j1, t]*Exp[I*n1*ω*t], {t, 0, T}]];
First@AbsoluteTiming[intexp[1, 3, k]]

Out[6]= 0.000012

Out[8]= 3.21761

Which is around $5$ orders of difference.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.