-1
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ Is it correct to assume that x and t are the variables and the rest are parameters? Is i a constant or the imaginary unit? Can you give the numerical values you want to assign to the various parameters? $\endgroup$ May 20, 2021 at 12:24
  • $\begingroup$ x,t are indeed variables. Consider A = 2, C= 4 for this case. I'd like to plot it between -4,4 $\endgroup$ May 20, 2021 at 12:25
  • 1
    $\begingroup$ Ok, thanks. Can you please add these details to the OP so other users can read the proper description of the problem? $\endgroup$ May 20, 2021 at 12:26
  • 1
    $\begingroup$ How about 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$
    – user64494
    May 20, 2021 at 12:33

1 Answer 1

3
$\begingroup$

So, 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}]
$\endgroup$
2
  • 1
    $\begingroup$ That's great, exactly what I was after :) $\endgroup$ May 20, 2021 at 13:53
  • $\begingroup$ Glad I was able to help! $\endgroup$ May 20, 2021 at 13:57

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