So I have a function
A *Sech[A *(x - c t)]* Exp[i*[(c/2) *x + (A^2 - c^2/4)* t]]
And I want to plot it but I'm not sure how. How do I specify each variable and plot it?
Consider A = 2, C= 4 for this case. I'd like to plot it between -4,4
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communitySo, first of all there are a couple of mistakes in the way you have written down the function. The proper way is given below:
fncn[x_, t_] :=
A*Sech[A*(x - c t)]*Exp[I ((c/2)*x + (A^2 - c^2/4)*t)] // ExpToTrig //
FullSimplify
You can ignore the ExpToTrig
and FullSimplify
and just check the differences in the square brackets and the parentheses.
Then we set up the constants
A = 2;
c = 4;
This is showing you the Real and Imaginary part of your function
{ContourPlot[Re@fncn[x, t], {x, -4, 4}, {t, -4, 4}, PlotPoints -> 50],
ContourPlot[Im@fncn[x, t], {x, -4, 4}, {t, -4, 4},
PlotRange -> {-4, 4}]}
And the following is giving you the absolute value of the function
Plot3D[Abs[fncn[x, t]], {x, -4, 4}, {t, -4, 4}]
A = 2; c = 4; ContourPlot[ Re[A*Sech[A*(x - c *t)]*Exp[I*((c/2)*x + (A^2 - c^2/4)*t)]], {x, -4, 4}, {t, -4, 4}]
? $\endgroup$