TransWikia.com

How to find expansion coefficients in Fourier-Legendre

Mathematica Asked on November 30, 2020

I am trying to find the coefficients for the Fourier-Legendre expansion of a potential. My goal was to obtain the coefficients as expressions in terms of x and y. I followed the example given on the website. However, when I ask mathematica to compute the integral, mathematica does not seem to be able to actually calculate the integral and just outputs this. It doesn’t give me the coefficients, but just lists the various Legendre functions. What am I doing wrong? Thank you.

Potential Expansion
V[[Gamma]_] := 
 1/Sqrt[x^2/4 + y^2 + x y [Gamma]] - (3/4) Sqrt[
    x^2/4 + y^2 + x y [Gamma]]
$Assumptions = x [Element] Reals
x [Element] Reals
$Assumptions = y [Element] Reals
y [Element] Reals
$Assumptions = [Gamma] [Element] Reals
[Gamma] [Element] Reals
$Assumptions = -1 <= [Gamma] <= 1
-1 <= [Gamma] <= 1
$Assumptions = x^2/4 + y^2 > x y [Gamma]
x^2/4 + y^2 > x y [Gamma]
FourierLegC[V_, [Gamma]_, n_] := (1/(2*Pi))*Integrate[LegendreP[n, [Gamma]]*V[[Gamma]], {[Gamma], -1, 1}]
FourierLegC[V[[Gamma]], [Gamma], n]
!(
*SubsuperscriptBox[([Integral]), (-1), (1)]((LegendreP[
    n, [Gamma]] ((
*FractionBox[(1), 
SqrtBox[(
*FractionBox[
SuperscriptBox[(x), (2)], (4)] + 
*SuperscriptBox[(y), (2)] + x y [Gamma])]] - 
*FractionBox[(3), (4)] 
*SqrtBox[(
*FractionBox[
SuperscriptBox[(x), (2)], (4)] + 
*SuperscriptBox[(y), (2)] + 
         x y [Gamma])]))[[Gamma]]) 
[DifferentialD][Gamma]))/(2 [Pi])
Factor[Table[FourierLegC[V[[Gamma]], [Gamma], n], {n, 0, 4}]]

FourierLegC

One Answer

Your assumptions are all split up and you should bring them together one assignment to $Assumptions. The γ assumptions are not really needed. You don't need to pass in V to your function FourierLegC either:

$Assumptions = 
  x ∈ Reals && 
  y ∈ Reals &&
  γ ∈ Reals &&
  -1 <= γ <= 1 &&
  x^2/4 + y^2 > x y γ;

V[γ_] := 1/Sqrt[x^2/4 + y^2 + x y γ] - (3/4) Sqrt[x^2/4 + y^2 + x y γ]
FourierLegC[n_] := (1/(2*Pi)) * Integrate[LegendreP[n, γ]*V[γ], {γ, -1, 1}]

Factor[Table[FourierLegC[n], {n, 0, 4}]]

This gives me the following results:

{(1/(32 [Pi] x y))(-16 Abs[x - 2 y] + x^2 Abs[x - 2 y] - 
  4 x y Abs[x - 2 y] + 4 y^2 Abs[x - 2 y] + 16 Abs[x + 2 y] - 
  x^2 Abs[x + 2 y] - 4 x y Abs[x + 2 y] - 4 y^2 Abs[x + 2 y]),

(-80 x^3 Sign[x - 2 y] + 3 x^5 Sign[x - 2 y] - 
   60 x^3 y^2 Sign[x - 2 y] - 640 y^3 Sign[x - 2 y] - 
   120 x^2 y^3 Sign[x - 2 y] + 96 y^5 Sign[x - 2 y] + 
   80 x^3 Sign[x + 2 y] - 3 x^5 Sign[x + 2 y] + 
   60 x^3 y^2 Sign[x + 2 y] - 640 y^3 Sign[x + 2 y] - 
   120 x^2 y^3 Sign[x + 2 y] + 
   96 y^5 Sign[x + 2 y])/(960 [Pi] x^2 y^2 Sign[x - 2 y] Sign[
    x + 2 y]),

-((-112 x^5 Sign[x - 2 y] + 3 x^7 Sign[x - 2 y] - 
     28 x^5 y^2 Sign[x - 2 y] - 3584 y^5 Sign[x - 2 y] - 
     224 x^2 y^5 Sign[x - 2 y] + 384 y^7 Sign[x - 2 y] + 
     112 x^5 Sign[x + 2 y] - 3 x^7 Sign[x + 2 y] + 
     28 x^5 y^2 Sign[x + 2 y] - 3584 y^5 Sign[x + 2 y] - 
     224 x^2 y^5 Sign[x + 2 y] + 
     384 y^7 Sign[x + 2 y])/(4480 [Pi] x^3 y^3 Sign[x - 2 y] Sign[
      x + 2 y])),

(-240 x^7 Sign[x - 2 y] + 5 x^9 Sign[x - 2 y] - 
   36 x^7 y^2 Sign[x - 2 y] - 30720 y^7 Sign[x - 2 y] - 
   1152 x^2 y^7 Sign[x - 2 y] + 2560 y^9 Sign[x - 2 y] + 
   240 x^7 Sign[x + 2 y] - 5 x^9 Sign[x + 2 y] + 
   36 x^7 y^2 Sign[x + 2 y] - 30720 y^7 Sign[x + 2 y] - 
   1152 x^2 y^7 Sign[x + 2 y] + 
   2560 y^9 Sign[x + 2 y])/(26880 [Pi] x^4 y^4 Sign[x - 2 y] Sign[
    x + 2 y])}

Correct answer by flinty on November 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP