Using Mathematica's Solve operator can sometimes lead to an output involving a positive and negative root (say when solving for a variable such as N^2.

What Is Happening

Here I simply have a defined function Radial followed by implementation (Solve) of that function.

Radial[n_,l_,r_]:= LaguerreL[n-l-1, 2*l+1, ((2*Z)*r)/(n*a)] * ((Z*r)/(n*a))^l Exp[-((Z*r)/(n*a))];
        N^2 Radial[1,0,r] r^2, 
        Assumptions -> {Z>0,a>0,{Z,a},Reals}
      ]== 1,N]

Out[1]= {{N -> -(Z^(3/2)/(Sqrt[2] a^(3/2)))}, {N -> Z^(3/2)/(Sqrt[2] a^(3/2))}}

Mathematica is kind enough to give me both positive and negative roots.

What I Want

I would like to suppress the negative root, leaving only the positive root solution, i.e. {N -> (2 Z^(3/2))/a^(3/2)}

What I've Tried

Here I include a couple things I have tried (some suggested by the kind people in chat).

  1. Inserting N>=0 into Assumptions : Resulted in two roots.
  2. Inserting N>=0 and N into the Reals section. : Resulted in two roots.
  3. Inserting && N>0 following the ==1 combined with all possible permutations of Tries (1) and (2). : Resulted in no answer given (nor any errors).

Hopefully there is a simple way of fixing this (and not some convoluted input syntax). However, for the benefit of the community, any suggestion is welcomed. For my particular case, the simpler the better.


2 Answers 2


One way is to use Refine to filter out only the positive root. For example:

assume = Z > 0 && a > 0 && n > 0;
int = Integrate[n^2*Radial[1, 0, r]*r^2, {r, 0, ∞}, Assumptions -> assume];
sol = Solve[int == 1, n];
If[Refine[(n /. #) > 0, assume], #, ## &[]] & /@ sol

enter image description here

I've changed N to n since the former is a built-in function. In general, it's good practice in Mathematica to never use single capital letters for variables or start functions with capital letters (since internal functions always start with uppercase).

Another way of doing it is by passing the assumptions directly to Solve, and getting back only the roots that satisfy those assumptions. However, it has been my experience in the past, with more complicated inequalities, that both Solve and Reduce tend to choke when you try to impose the requirements of the roots inside it (i.e., it solves the general case faster than the specific), and it's simpler to filter out the general solution with Refine.

For the sake of completeness, here's a solution with the constraints inside Solve and then further simplified using Simplify:

Solve[int == 1 && assume, n] // Simplify[#, Assumptions -> assume] &

You need to pass to Solve conditions for all three variables. Solve cannot decide whether N is positive or negative unless it knows the sign of a and Z , because their values define sign of N. Note, passing the assumptions to Integrate won't pass them to Solve in your implementation. You also do not need to put the integral inside Solve. Of course, you may if you'd like to, but I found it separately to be

(2 a^3 N^2)/Z^3

Plug it in your equation:

Solve[(2 a^3 N^2)/Z^3 == 1 && a > 0 && Z > 0 && N > 0, N]


{{N -> ConditionalExpression[Sqrt[Z^3/a^3]/Sqrt[2], Z > 0 && a > 0]}}

Generally I wouldn't use variable N because it is a function in Mathematica and you can run into a trouble.


Your Answer

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

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