How to Set Constraints on Variables in Mathematica?

  • Thread starter Thread starter Hazerboy
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
SUMMARY

The discussion focuses on setting constraints for variables in Mathematica, specifically for integrating and summing functions where the variable must be an odd integer greater than zero. Users suggest utilizing the "Assumptions" argument in functions like Integrate and Sum to specify that a variable is an integer. The conversation also highlights a common mistake in summation bounds and emphasizes the importance of consulting Mathematica's documentation for further understanding of variable constraints.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of quantum mechanics concepts, particularly wave functions
  • Knowledge of integrals and summations in mathematical contexts
  • Basic understanding of complex equations and dispersion relations
NEXT STEPS
  • Research "Mathematica Assumptions" for variable constraints
  • Learn about "Integrate" and "Sum" functions in Mathematica
  • Explore examples of using "Element" in Mathematica for integer constraints
  • Study quantum mechanics wave function calculations in Griffiths' text
USEFUL FOR

Students and researchers in physics, particularly those working with quantum mechanics and using Mathematica for mathematical computations. This discussion is also beneficial for anyone looking to enhance their skills in setting variable constraints in Mathematica.

Hazerboy
Messages
15
Reaction score
0
Sorry I'm sort of deleting the template here, but my question isn't a strict HW help problem. I wasn't sure where else to ask it. I need to take an integral given that a certain variable is an integer, odd, and greater than zero, on mathematica. I'm integrating with respect to the variable x, but its for a trig function that involves the integer n*Pi in the domain, meaning it will disappear for certain n, given n is an integer and > 0. Its for a quantum mechanics problem on griffiths (finding the coefficients of a wavefunction, given the wave function at time 0). For those of you familiar with griffiths text on QM, the equation is something like Cn = Integral (Your eigenfunction given a certain n)*(Your wave function at time 0).

I have already done it by hand and gotten the correct answer (almost! my answer switches sign depending on the variable n, where as the solution I have is positive for all n), but now the problem asks for me find the expectation value for the energy, which is <H> = summation (Cn^2* En) from zero --> infinity.

After getting rid of some constants, I now have a summation from n = 1 --> infinity, given n is odd, for 1/(n^2). So really this isn't a QM question at all, its "how do I tell mathematica my variable is an odd integer and make it do the problem." I am familiar with how to do integrals and summations on mathematica, just not very familiar on how to tell it constraints on a variable. Any help?

Honestly I could probably look up the summation in a reference or something, though I feel like this would be very useful knowledge to know to begin with.
 
Physics news on Phys.org
Well, if I understand you correctly, you can do it with a simple change of variables: Sum 1 / (2n+1)^2, from n=0 to infinity.
 
nicksauce said:
Well, if I understand you correctly, you can do it with a simple change of variables: Sum 1 / (2n+1)^2, from n=0 to infinity.

Yep, that will work well for summation, but not for integration - Mathematica won't have the initial condition that n is an integer.

AND I don't think it yields *quiet* the right answer, though I don't understand why. Mathematica gives the sum as (-1+(Pi^2)/8), while the answer I found on the internet gives Pi^2 / 8 (difference of one between the two, though the second was calculated by "maple." No idea why, or even which one is really correct. I'm sure there are some subtleties here that I am missing. )
 
Did you ask Sum[1/(2n+1)^2, {n, 1, :inf:}] on accident? (Instead of using {n, 0, :inf:} as your bounds)


Some functions take an additional argument called "Assumptions"; Integrate is one of them, meaning you can do

Integrate[ f, {x, a, b}, Assumptions->Element[x, Integers] ]

If I've remembered wrongly, you can still do something like

FullSimplify[ [Integrate[ f, {x, a, b}], Assumptions->Element[n, Integers] ]

or

Assuming[ Element[n, Integers], Integrate[ f, {x, a, b}] ]

(I think I have the syntax right for this last one)

I think there's a way to specify that it has to be odd.

I think you can even declare to Mathematica an assumption that you will always use. In any case, you have a lead, now you can go read up on assumptions in the help documentation.
 
Hurkyl said:
Did you ask Sum[1/(2n+1)^2, {n, 1, :inf:}] on accident? (Instead of using {n, 0, :inf:} as your bounds)


Some functions take an additional argument called "Assumptions"; Integrate is one of them, meaning you can do

Integrate[ f, {x, a, b}, Assumptions->Element[x, Integers] ]

If I've remembered wrongly, you can still do something like

FullSimplify[ [Integrate[ f, {x, a, b}], Assumptions->Element[n, Integers] ]

or

Assuming[ Element[n, Integers], Integrate[ f, {x, a, b}] ]

(I think I have the syntax right for this last one)

I think there's a way to specify that it has to be odd.

I think you can even declare to Mathematica an assumption that you will always use. In any case, you have a lead, now you can go read up on assumptions in the help documentation.

Ah yes you were definitely right about the sum. Simple mistake. As for the integration, that is exactly the sort of thing that I was looking for. Now that I have a lead, I'm sure I can read up on the documention and figure out exactly how to do it.
 
Hello everybody,
I a new to Mathematica and I want t find the roots of a complex equation. It is basically a dispersion relation with omega as a function of K.

\[Rho] = 0.01;
we = 1000;
oh = 0.1;
k =.;
n =.;
m = (Sqrt[k^2 + n^2]);
F[ome_] = (ome + I (we)^0.5 k + 4 m^2 oh)*(ome + I (we)^0.5 k) Tanh[
m] + 4 m^3 oh^2 *(m Tanh[
m] - (m^2 + (ome + I (we)^0.5 k)/oh)^0.5 *
Tanh[(m^2 + (ome + I (we)^0.5 k)/oh)^0.5]) + \[Rho] ome^2 +
m^3;
n = 1;

t = Table[{k,
Re[ome /.
FindRoot[F[ome] == 0, {ome, {(1.5 + 50 I), (3 + 100 I)}},
MaxIterations -> 500]]}, {k, 1, 100, 1}]

ListPlot[t, PlotJoined -> True]

This is how i have been trying to solve the equation, my email i.d is kumar.kannan@uni.lu.Any suggestions about solving the equation is welcome. It is urgent.
Thanks in advance
bye
 

Similar threads

  • · Replies 19 ·
Replies
19
Views
2K
Replies
2
Views
2K
Replies
4
Views
1K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
3
Views
2K
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K