3
$\begingroup$

I want to demonstrate FourierTransform in a lecture. However if you give FourierTransform a differential equation it does not know about linearity and just returns the answer.

e = x''[t] + 2 z w0 x'[t] + w0^2 x[t] == g[t];
FourierTransform[e, t, w]

enter image description here

Which is not much help. Fortunately, @xzczd has developed this shell to provide standard rules. This is implemented by

ClearAll[FT];
FT[(h : List | Plus | Equal)[a__], t_, w_] := FT[#, t, w] & /@ h[a]
FT[a_ b_, t_, w_] /; FreeQ[b, Alternatives @@ t] := b FT[a, t, w]
FT[a_, t_, w_] := FourierTransform[a, t, w]

This now works on the differential equation thus

FT[e, t, w]

enter image description here

However I would like to take this one step further by using the convention that lower case letters in the time domain give rise to capital letters in the frequency domain. I can do this for specific cases using replacement rules as follows.

ClearAll[FT];
FT[(h : List | Plus | Equal)[a__], t_, w_] := FT[#, t, w] & /@ h[a]
FT[a_ b_, t_, w_] /; FreeQ[b, Alternatives @@ t] := b FT[a, t, w]
FT[a_, t_, w_] := 
 FourierTransform[a, t, w] /. {FourierTransform[x[t], t, w] -> X[w], 
   FourierTransform[g[t], t, w] -> G[w]}

This gives the form I want

sol = FT[e, t, w]

(* -w^2 X[w] + w0^2 X[w] - 2 I w w0 z X[w] == G[w] *)

One can now do further operations such as

Solve[sol, X[w]]


(* {{X[w] -> -(G[w]/(w^2 - w0^2 + 2 I w w0 z))}}*)

However, it is specific to the symbols of x[t] and g[t] I have implimented. Can this be done so that any lower case letter, e.g. a in the form FourierTransform[a[t], t, w] goes to A[w]?

$\endgroup$
5
  • $\begingroup$ Would something like this work? FourierTransform[op_[t_], t_, w_] :> Symbol@*Capitalize@*ToString@*op@w, in place of {FourierTransform[x[t], t, w] -> X[w], FourierTransform[g[t], t, w] -> G[w]}? If so, I'll write an answer. $\endgroup$
    – march
    Commented Nov 28, 2023 at 16:36
  • $\begingroup$ @march I Can' get it to work. I get a RuleDelayed error if I apply it as a rule. Would a Format statement work? $\endgroup$
    – Hugh
    Commented Nov 28, 2023 at 17:01
  • $\begingroup$ @march If I write it as {FourierTransform[op_[t_], t_, w_] :> Symbol[Capitalize[ToString[op]]][w]} then it gives a warning but works. Please post your answer. $\endgroup$
    – Hugh
    Commented Nov 28, 2023 at 17:17
  • $\begingroup$ Just to compare. e = x''[t] + 2 z w0 x'[t] + w0^2 x[t] == g[t]; LaplaceTransform[e, t, w] results in w^2 LaplaceTransform[x[t], t, w] + w0^2 LaplaceTransform[x[t], t, w] + 2 w0 z (w LaplaceTransform[x[t], t, w] - x[0]) - w x[0] - Derivative[1][x][0] == LaplaceTransform[g[t], t, w]. As far as I know it, LaplaceTransfom is more often used for solving linear ODEs. $\endgroup$
    – user64494
    Commented Nov 28, 2023 at 18:11
  • $\begingroup$ @user64494 I agree the Laplace transform is much better for symbolic work with ODEs. However, I am starting with the Fourier transform and moving towards numerical Laplace transforms. So there is a logic to my needs. $\endgroup$
    – Hugh
    Commented Nov 28, 2023 at 18:27

1 Answer 1

4
$\begingroup$

To create a replacement rule that works in general, we use the String function Capitalize, like so:

FourierTransform[op_[t_], t_, w_] :> (Symbol@Capitalize@ToString@op)@w
$\endgroup$

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.