# FourierCosTransform bug?

Bug introduced in 13.0 or earlier and persisting through 13.2.0 or later.

FourierCosTransform[Cos[(k + p) z], z, q]


gives correct result

Sqrt[\[Pi]/2] DiracDelta[k + p - q] +
Sqrt[\[Pi]/2] DiracDelta[k + p + q]


The same but with expanded argument

FourierCosTransform[Cos[k z + p z], z, q]


gives 0. Bad surprise. Indeed, the situation is worse, because the difference remains even if we explicitly state that k, p, q are real numbers

In[]:= FourierCosTransform[Cos[(k + p) z], z, q, Assumptions -> {k, p, q} \[Element] Reals]

Out[]:=Sqrt[\[Pi]/2] DiracDelta[k + p - q] + Sqrt[\[Pi]/2] DiracDelta[k + p + q]

In[]:=FourierCosTransform[Cos[z k + p z], z, q, Assumptions -> {k, p, q} \[Element] Reals]

Out[]:=0

• I can reproduce on \$Version == "13.0.0 for Mac OS X x86 (64-bit) (December 3, 2021)" May 26, 2022 at 12:46
• Strange, but these two commands TrigExpand[Cos[k z + p z]] and TrigExpand[Cos[(k + p) z]] also give different results. May 26, 2022 at 13:15
• @Rodion: As to your comment, Mathematica's TrigExpand will only re-write the expression if the argument of the sinusoidal functions are in already expanded form. This is, I imagine, a design choice, but I don't know the reason for it. May 26, 2022 at 15:41
• If you use FourierTransform instead of FourierCosTransform (which should yield the same result in this case, since the function is even), then both results are identical and equal to the result which is the sum of two delta functions. May 26, 2022 at 15:44
• I find the result of FourierCosTransform[Cos[(k + p) z], z, q] i.e. Sqrt[\[Pi]/2] DiracDelta[k + p - q] + Sqrt[\[Pi]/2] DiracDelta[k + p + q] to be a bug, since k,p, and q are complex by default. May 26, 2022 at 15:52

Let us go into deep. The function Cos[(k + p) z] depends on k and p and z which are assumed complex by default. Claiming the correct result of FourirCosTansform to be Sqrt[\[Pi]/2] DiracDelta[k + p - q] + Sqrt[\[Pi]/2] DiracDelta[k + p + q], you silently assume that k + p - q \[Element]] Reals and k + p + q \[Element]] Reals. In other case this is meaningless. If we deal with parameters, then the Assumptions and GenerateConditions->True options are useful. In fact, usual assumptions are {k,p,q}\[Element]Reals. Let us try it.

FourierCosTransform[Cos[(k + p) z], z, q,
Assumptions -> {k, p, q} \[Element] Reals, GenerateConditions -> True]


Sqrt[\[Pi]/2] DiracDelta[k + p - q] + Sqrt[\[Pi]/2] DiracDelta[k + p + q]

FourierCosTransform[Cos[k z + p z], z, q,
Assumptions -> {k, p, q} \[Element] Reals,
GenerateConditions -> True]


returns the input. Of course, this is a weakness, but not a bug. Next,

FourierCosTransform[Cos[(k + p) z], z, q, GenerateConditions -> True]


ConditionalExpression[0, Im[k + p] < 0]

If Im[k + p] < 0, then (If I am not mistaken) the usual FourierCosTransform does not exist. Therefore, the above answer is of such kind "If $$2+2=5$$, then $$2+3=6$$".

• Thank you but I donэt agree. This is a bug and it could be very drastic. First of all expression k z+ k p and (k + p) z are mathematically identical in all sense and assumptions. I understand that the result of the integration depends on the properties of the parameters, but this is totally wrong if result of FourierCosTransform[Cos[z k + p z], z, q, Assumptions -> {k, p, q} \[Element] Reals] is not the same FourierCosTransform[Cos[(k + p) z], z, q, Assumptions -> {k, p, q} \[Element] Reals]. Otherwise it's a mess. May 26, 2022 at 14:45
• @RodionStepanov: The statement "but this is totally wrong if result of FourierCosTransform[Cos[z k + p z], z, q, Assumptions -> {k, p, q} \[Element] Reals] is not the same FourierCosTransform[Cos[(k + p) z], z, q, Assumptions -> {k, p, q} \[Element] Reals]" is your personal opinion. The returned input is a weakness, not a bug. May 26, 2022 at 14:56
• I find the result of FourierCosTransform[Cos[(k + p) z], z, q] i.e. Sqrt[\[Pi]/2] DiracDelta[k + p - q] + Sqrt[\[Pi]/2] DiracDelta[k + p + q] to be a bug. May 26, 2022 at 15:51
• What about FourierCosTransform[Cos[z k + p z], z, q, Assumptions -> {k, p, q} [Element] Reals] results in Sqrt[\[Pi]/2] DiracDelta[k + p - q] + Sqrt[\[Pi]/2] DiracDelta[k + p + q]` is it a bug for you? May 26, 2022 at 17:28