I would like to plot this function:

FullSimplify[(t Cos[(m^2 Pi^2)/9 + (n^2 Pi^2)/9] + t Sin[(m^2 Pi^2)/9 + (n^2 Pi^2)/9]) Sin[(n Pi x)/3] Sin[(m Pi y)/3]]

but since it contains n- and m-terms, and it has a time-dimension, it is certainly not straight forward. How do I plot this in Mathematica for various time steps with discrete values for m and n?



2 Answers 2


One way is to make a function. Change n and m to pick the mode of vibration using the slider. Move the time slider to change the time. The x,y are hardcoded ranges. The plot range is fixed in order to better capture the motion scale.

Change as needed.

enter image description here


ClearAll[n, m, x, y, t, f];
f[n_, m_, t_, x_, y_] = 
 FullSimplify[(t Cos[(m^2 Pi^2)/9 + (n^2 Pi^2)/9] + 
     t Sin[(m^2 Pi^2)/9 + (n^2 Pi^2)/9]) Sin[(n Pi x)/3] Sin[(m Pi y)/
 Module[{x, y},
  Plot3D[f[n, m, t, x, y], {x, 0, 3}, {y, 0, 3},
   PerformanceGoal -> "Quality",
   PlotRange -> {Automatic, Automatic, {-5, 5}},
   PlotLabel -> Row[{"time ", t}]
 {{t, 0, "time"}, 0, 10, .1, Appearance -> "Labeled"},
 {{n, 2, "n"}, 1, 10, 1, Appearance -> "Labeled"},
 {{m, 3, "m"}, 1, 10, 1, Appearance -> "Labeled"},
 TrackedSymbols :> {t, n, m}
  • $\begingroup$ Thanks, I see clearly that this is a solution to the wave equation in two dimensions . $\endgroup$
    – Vangsnes
    Aug 29, 2022 at 14:00

There are three main reasons to visualize anything:

  • Discover
  • Confirm
  • Explain

Which of these are you trying to accomplish?

Fiddling with your equation a bit to restructure it...

TrigFactor[(t Cos[π^2/9 + (n^2 π^2)/9] + t Sin[π^2/9 + (n^2 π^2)/9]) Sin[(n π x)/3] Sin[(π y)/3]]

TrigFactor works with it in a way that makes clear various effects.

t (Sqrt[2] Sin[π/4 + (m^2 π^2)/9 + (n^2 π^2)/9]) Sin[(n π x)/3] Sin[(m π y)/3]

By examination you can see a lot of what is going on. The expression is linear in t, has a constant term (Sqrt[2] Sin[π/4 + (m^2 π^2)/9 + (n^2 π^2)/9]) that is determined by n and m, and has the oscillating terms in x and y with frequencies set by n and m respectively.

@Nasser's approach is a great way to explore the equation and get some intuition.


Your Answer

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

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