I'm trying to expedite some quantum mechanical calculations (expectation values etc.) by running them through Mathematica. When I say, for example,
u[x_] := Sqrt[2/L] * Sin[Pi * n * x / L]
and then take the complex conjugate, I get
Sqrt[2] Conjugate[Sqrt[1/L]] Sin[(π Conjugate[n x])/Conjugate[L]]
But I want to tell Mathematica that some of the parameters are real (i.e. $L$) and some are integer valued and real (i.e. $n$). Is there a way to do that? I've tried adapting some syntax that I've seen in other context (but do not strictly know what it means or does) but it hasn't worked. For example,
Conjugate[u[x], Im[n] = 0]
Sin[n*Pi] /. n = Integer
Don't work the way I want them to. Chugging through this, however, when it comes time to compute values (like, in this example, $\langle p^2\rangle$, I get the following:
Integrate[u[x]*(-h^2)*u''[x], {x, 0, L}]
(* => (h^2 n π (n π - 1/2 Sin[2 n π]))/L^2 *)
where the second term there is clearly zero for all integer values of $n$ (but Mathematica doesn't know that).
But I want to tell Mathematica that some of the parameters are real (ie L) and some are integer valued
you can us eComplexExpand
it saysexpands expr assuming that all variables are real
, for integers, you can useAssuming[Element[x,Integers],Simplify[....]]
$\endgroup$Assumptions
option which affects that function. Take a look at reference.wolfram.com/language/tutorial/UsingAssumptions.html and alsoComplexExpand
. There can be a default for theAssumptions
option through$Assumptions
but it won't affect everything, only functions that know about assumptions. $\endgroup$