Skip to main content
added 1136 characters in body
Source Link
Roman
  • 49.8k
  • 2
  • 57
  • 131

For your original example, TrigToExp does what you need:

4 (Cos[θ] - Cos[φ])^2 + (Sin[θ] - Sin[φ])^2 // TrigToExp

(*    5 + 3/4 E^(-2 I θ) + 3/4 E^(2 I θ) - 3/2 E^(-I θ - I φ) -
      5/2 E^(I θ - I φ) - 5/2 E^(-I θ + I φ) - 3/2 E^(I θ + I φ) +
      3/4 E^(-2 I φ) + 3/4 E^(2 I φ)                                  *)

For more complicated functions without an explicit exponential structure, you can evaluate the Fourier integrals explicitly:

f[θ_, φ_] = Log[4 (Cos[θ] - Cos[φ])^2 + (Sin[θ] - Sin[φ])^2 + 1];

F[a_?NumericQ, b_?NumericQ] := 1/(2 π)^2 * NIntegrate[
    f[θ, φ] * E^(-I*{a, b}.{θ, φ}), {θ, 0, 2 π}, {φ, 0, 2 π}]

For example, sum up all Fourier components up to order 2:

g[θ_, φ_] = Sum[F[a, b]*E^(I*{a, b}.{θ, φ}), {a, -2, 2}, {b, -2, 2}] // Chop

(*    1.48242 +
      0.0545782 E^(-2 I θ) +
      0.0545782 E^(2 I θ) - 
      0.0291498 E^(I (-2 θ - 2 φ)) - 
      0.136866 E^(I (2 θ - 2 φ)) - 
      0.224188 E^(I (-θ - φ)) - 
      0.517258 E^(I  - φ)) +
      0.0545782 E^(-2 I φ) +  
      0.0545782 E^(2 I φ) -
      0.517258 E^(I (-θ + φ)) - 
      0.224188 E^(I (θ + φ)) - 
      0.136866 E^(I (-2 θ + 2 φ)) - 
      0.0291498 E^(I (2 θ + 2 φ))    *) 

Plot3D[{f[θ, φ], Re[g[θ, φ]]}, {θ, 0, 2 π}, {φ, 0, 2 π}]

enter image description here

TrigToExp does what you need:

4 (Cos[θ] - Cos[φ])^2 + (Sin[θ] - Sin[φ])^2 // TrigToExp

(*    5 + 3/4 E^(-2 I θ) + 3/4 E^(2 I θ) - 3/2 E^(-I θ - I φ) -
      5/2 E^(I θ - I φ) - 5/2 E^(-I θ + I φ) - 3/2 E^(I θ + I φ) +
      3/4 E^(-2 I φ) + 3/4 E^(2 I φ)                                  *)

For your original example, TrigToExp does what you need:

4 (Cos[θ] - Cos[φ])^2 + (Sin[θ] - Sin[φ])^2 // TrigToExp

(*    5 + 3/4 E^(-2 I θ) + 3/4 E^(2 I θ) - 3/2 E^(-I θ - I φ) -
      5/2 E^(I θ - I φ) - 5/2 E^(-I θ + I φ) - 3/2 E^(I θ + I φ) +
      3/4 E^(-2 I φ) + 3/4 E^(2 I φ)                                  *)

For more complicated functions without an explicit exponential structure, you can evaluate the Fourier integrals explicitly:

f[θ_, φ_] = Log[4 (Cos[θ] - Cos[φ])^2 + (Sin[θ] - Sin[φ])^2 + 1];

F[a_?NumericQ, b_?NumericQ] := 1/(2 π)^2 * NIntegrate[
    f[θ, φ] * E^(-I*{a, b}.{θ, φ}), {θ, 0, 2 π}, {φ, 0, 2 π}]

For example, sum up all Fourier components up to order 2:

g[θ_, φ_] = Sum[F[a, b]*E^(I*{a, b}.{θ, φ}), {a, -2, 2}, {b, -2, 2}] // Chop

(*    1.48242 +
      0.0545782 E^(-2 I θ) +
      0.0545782 E^(2 I θ) - 
      0.0291498 E^(I (-2 θ - 2 φ)) - 
      0.136866 E^(I (2 θ - 2 φ)) - 
      0.224188 E^(I (-θ - φ)) - 
      0.517258 E^(I  - φ)) +
      0.0545782 E^(-2 I φ) +  
      0.0545782 E^(2 I φ) -
      0.517258 E^(I (-θ + φ)) - 
      0.224188 E^(I (θ + φ)) - 
      0.136866 E^(I (-2 θ + 2 φ)) - 
      0.0291498 E^(I (2 θ + 2 φ))    *) 

Plot3D[{f[θ, φ], Re[g[θ, φ]]}, {θ, 0, 2 π}, {φ, 0, 2 π}]

enter image description here

Source Link
Roman
  • 49.8k
  • 2
  • 57
  • 131

TrigToExp does what you need:

4 (Cos[θ] - Cos[φ])^2 + (Sin[θ] - Sin[φ])^2 // TrigToExp

(*    5 + 3/4 E^(-2 I θ) + 3/4 E^(2 I θ) - 3/2 E^(-I θ - I φ) -
      5/2 E^(I θ - I φ) - 5/2 E^(-I θ + I φ) - 3/2 E^(I θ + I φ) +
      3/4 E^(-2 I φ) + 3/4 E^(2 I φ)                                  *)