0
$\begingroup$

I want to compute the Fourier transform in the form of trigonometric functions from a list of functions. Suppose I have F1 like below:

F1 = 
  Table[
    Sum[(jj - m) y^(2 (jj - 2 - i) + 4) x^(2 m + 2 i + 4), {i, 1,jj - 3}] + 
    Sum[ y^(2 (i) + 4) x^(2 m + 2 (jj - 2 - i) + 2) + (m*jj) x^(2 m) y^(2 (jj - 1) + 6), {i, jj - 3, jj - 2}], 
    {m,50}, {jj, 4, 50}]

I get the Laplacian from this list of functions:

F2 = Laplacian[F1, {x, y}]

Then I get the Fourier transform from F2:

a = 1
ParallelTable[
  1/a Integrate[Cos[(n π y)/a]*F2[[m, jj]] /. {x -> 4} , {y, -a, a}], 
  {n, 30}, {m, 50}, {jj, 4, 50}]

Please help me with doing this computation as fast as possible? I need 10 precision accuracy.

$\endgroup$

closed as off-topic by Jens, MarcoB, LCarvalho, Öskå, Young Jul 8 '17 at 17:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Jens, MarcoB, LCarvalho, Öskå, Young
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Use FourierCosCoefficient $\endgroup$ – Jens Jun 30 '17 at 21:34
  • $\begingroup$ but it's domain differs from my domain $\endgroup$ – Farid Jun 30 '17 at 22:50
  • $\begingroup$ I think the index jj in your ParallelTable should be {jj, 47} -- jj is an index here, rather than a variable, and F2 only has 47 columns. $\endgroup$ – aardvark2012 Jul 1 '17 at 3:00
  • $\begingroup$ I want to get list of function with dimensions at least 47*50 and it's answer some equations that requires jj start from 4 to end for 1 to 3 we have different answer which shape of function differ from the form I presented. what's important here for me making the third row of code as fast as possible and desired accuracy $\endgroup$ – Farid Jul 1 '17 at 3:07
3
$\begingroup$

To speed it up, regard your F2 terms, They are all polynoms of y

F2[[3, 3]] /. x -> 4

(*   386547056640 y^4 + 238370684928 y^6 + 13784580096 y^8 + 
     429785088 y^10 + 229376 y^12 + 35389440 y^14 + 276480 y^16     *)

Therfore you can get a general epression for the fourier integral

int = Integrate[1/a*Cos[(n \[Pi] y)/a]*y^k, {y, -a, a}, 
        Assumptions -> 
            k > 1 && k \[Element] Integers && n \[Element] Integers && n > 0 &&
 a > 0]

(*     (1/(1 + k))((-a)^k + a^k) HypergeometricPFQ[{1/2 + k/2}, {1/2, 
          3/2 + k/2}, -(1/4) n^2 \[Pi]^2]     *)

Insert this instead of the integral.

(a = 1;
 partab2 = 
    ParallelTable[
     F2[[m, jj]] /. {x -> 4, y^k_ -> int} // N, {n, 30}, {m, 1, 
       3}, {jj, 1, 3}];) // AbsoluteTiming

(*     {3.6250272, Null}     *)

Compare the calculation times with "Integrate" and "NIntegrate" for a small parameter set.

(a = 1;
  partab = 
    ParallelTable[
       1/a Integrate[
        Cos[(n \[Pi] y)/a]*F2[[m, jj]] /. {x -> 4}, {y, -a, a}] // 
        N, {n, 30}, {m, 1, 3}, {jj, 1, 3}];) // AbsoluteTiming

(*     {103.0479747, Null}     *)

(a = 1;
  partabn = 
    ParallelTable[
     1/a NIntegrate[
      Cos[(n \[Pi] y)/a]*F2[[m, jj]] /. {x -> 4}, {y, -a, a}], {n, 
      30}, {m, 1, 3}, {jj, 1, 3}];) // AbsoluteTiming

(*     {6.6719206, Null}     *)
$\endgroup$
  • $\begingroup$ You are right. I correct it just now. Doesn't change much. $\endgroup$ – Akku14 Jul 1 '17 at 19:05

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