How can I make this type of substitution in maple?

I have tried using subs but it is not working for what I am trying to do.

I have

r2 := (n_x^2+n_y^2-1);


and I want this expression:

E:=hbar*Pi/(2*M*A)*(n_x^2/L+n_y^2/L);


to put r2 in so I can solve for r2 (using maple). Does anyone know what the command is to do this? I cannot seem to articulate what I want well enough to bring it up in the help search!

• Why don't you do it by hand? Clearly, (n_x^2/L+n_y^2/L) is equal to (r2+1)/L. Hence, you can set E:=hbar*Pi/(2*M*A)*(r2+1)/L; and solve whatever you want with that. – user53153 Mar 6 '13 at 3:25
• because I know how to do it by hand already @5pm – Magpie Mar 6 '13 at 3:25
• Then it's not really a mathematical question, is it? It should not be asked at Math.SE. // Anyway, you can include the information about r2 as additional equation in the system you are solving: solve([hbar*Pi/(2*M*A)*(n_x^2/L+n_y^2/L)=42, r2=(n_x^2+n_y^2-1)], [r2, A, M]); – user53153 Mar 6 '13 at 3:26
• While there is no SE for mathematical computing it is fine for math SE, don't you think? – Magpie Mar 6 '13 at 3:46
• I don't. The fact that you can't find a better place to ask a question does not mean it's fine to ask it here. – user53153 Mar 6 '13 at 3:52

By assigning a value to r2 you made it (nearly) impossible to evaluate any expression and see an r2 in it. Get rid of that assignment:

> r2:= 'r2':


Now subs won't work because the expression you want to be r2 doesn't appear as an operand in E. However, you can use

> simplify(E, {n_x^2+n_y^2-1 = r2});


$${\frac {{\it hbar}\,\pi \,{\it r2}}{2\,MAL}}+{\frac {{\it hbar} \,\pi }{2\,MAL}}$$

or

> algsubs(n_x^2+n_y^2-1 = r2, E);


$$\frac{{\it hbar}\, \pi ({\it r2}+1)}{2\, MAL}$$

• The only problem with that is I can't then solve for r2 and this is my motivation for subbing it in. – Magpie Mar 6 '13 at 3:44
• Solving for r2 doesn't mean a whole lot when it itself is a relation of two other independent variables, n_x and n_y. The best you will get is a solution manifold, some curve, plane, or other subset of the Cartesian product of n_x and n_y's domains. – Emily Mar 6 '13 at 5:11
• Why not just put in r2 explicitly, solve for it, and then reconcile the issue with n_x and n_y? – Emily Mar 6 '13 at 5:12