Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

solving an equation for the square of the variable?

Given a expression (polynomial, or any equation in general) such as

a s^2+b = 0

I want to solve for s^2, to get s^2 = -b/a. We all know that one can't just write

Solve[eq==0,s^2]

because s^2 is not a 'variable'. only s is a 'variable'. So what I do is

eq  = a s^2+b;
sol = First@Solve[eq==0/.s^2->z,z];
z/.sol

-(b/a)

I was wondering if there is a way to do the above, without the intermediate variable substitution? I tried many commands, but no success (reduce, collect, eliminate, factor. etc...).

thanks --Nasser

like image 906
Nasser Avatar asked May 28 '11 23:05

Nasser


1 Answers

One way is to solve for s and then square it...

eq=a s^2+b;
sol=#^2 &@ (s/.Solve[eq==0,s])//DeleteDuplicates

Out[1]= {-(b/a)}
like image 129
abcd Avatar answered Sep 27 '22 20:09

abcd