3
$\begingroup$

Mathematica returns FourierTrigSeries[Cos[Sin[t]]^2, t, 2] unevaluated. This can easily be done by hand with the Jacobi–Anger expansion (or Jacobi–Anger identity). Previously, I tried unsuccessfully to write code to do this expansion programmatically. When I asked about it here, the solution was simply to use the built in FourierTrigSeries. This solved my problem, albeit with long runtimes (on the order of minutes), which shouldn't happen if it were done through the Jacobi–Anger expansion.

Finally, I ran into an expression which would simply not evaluate. I stripped it down to a minimal example that would give the same issue. Even adding assumptions to it doesn't fix the problem:

Assuming[t ∈ Reals, FourierTrigSeries[Cos[Sin[t]]^2, t, 2]]

Is there a way to make FourierTrigSeries evaluate this?

Is there a better way to do this?

$\endgroup$
9
  • $\begingroup$ most likely it can't integrate it. Integrate[Cos[Sin[t]]^2*Exp[-I*2*t],{t,-Pi,Pi}] is not evaluating` for example. $\endgroup$
    – Nasser
    Commented May 10 at 0:43
  • $\begingroup$ A work around: FourierSeries[Sin[x]^2, x, 3] // ExpToTrig $\endgroup$ Commented May 10 at 7:18
  • $\begingroup$ "if it were done through the Jacobi Anger Identities" Mathematica simply cannot handle transformations related to Jacobi Anger identities well for the moment according to my tests, though Wolfram|Alpha is clearly aware of this identity: wolframalpha.com/input?i=jacobi+anger+identity . (Yeah I happened to encounter related issue before and I've played with it for quite a while. ) I sincerely hope I'm wrong. $\endgroup$
    – xzczd
    Commented May 10 at 8:44
  • $\begingroup$ You can just do the TrigReduce as per @Domen, e.g. The relevant series are FourierCosSeries[Cos[2 Sin[t]]/2, t, 2] + FourierCosSeries[1/2, t, 2] or FourierTrigSeries[Cos[2 Sin[t]]/2, t, 2] + FourierTrigSeries[1/2, t, 2] $\endgroup$
    – ubpdqn
    Commented May 10 at 9:10
  • $\begingroup$ Someone mentioned that you could just add together the FourierCosSeries + FourierSinSeries, but I can no longer find that comment. Just adding that method here for completeness. $\endgroup$
    – ions me
    Commented May 11 at 7:23

2 Answers 2

4
$\begingroup$

I can't answer the question why it doesn't work, but I can give you a simple trick to help Mathematica solve it. Use TrigReduce first:

FourierTrigSeries[TrigReduce[Cos[Sin[t]]^2], t, 2]
(* 1/2 (1 + BesselJ[0, 2]) + BesselJ[2, 2] Cos[2 t] *)
$\endgroup$
3
$\begingroup$

Ok, so this solution works, but is mildly ugly. First I do the Jacobi anger code that I tried previously:

jacobiAnger[
   order_] = {Cos[z_*Sin[\[Theta]_]] -> 
    BesselJ[0, z] + 
     2 Sum[BesselJ[n, z] Cos[n \[Theta]], {n, 2, order, 2}],
   Sin[z_*Sin[\[Theta]_]] -> 
    2 Sum[BesselJ[n, z] Sin[n \[Theta]], {n, 1, order, 2}] 
   };

In general, mathematica will not group the terms correctly for this. However, applying this expansion is enough that the FourierTrigSeries will work afterwards. Putting it together, we use it like so:

Cos[a Sin[t]]^2;
% /. jacobiAnger[2] // Expand;
FourierTrigSeries[%, t, 2] /. a -> 1

Which gives the desired result:

BesselJ[0, 1]^2 + 2 BesselJ[2, 1]^2 + 
 4 BesselJ[0, 1] BesselJ[2, 1] Cos[2 t]
$\endgroup$
2
  • $\begingroup$ Are you sure this approach is correct, since you are doing a Fourier series on a truncated expansion of your initial function? $\endgroup$
    – Domen
    Commented May 10 at 8:41
  • $\begingroup$ @Domen it's correct because both are to the same order. $\endgroup$
    – ions me
    Commented May 11 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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