-----maxima-bounces at math.utexas.edu wrote: -----
>What?is?wrong?with?following?sequence?of?commands?
>
>eq1:x1=(-b+sqrt(b^2-4*c))/2;
>eq2:x2=(-b-sqrt(b^2-4*c))/2;
>solut:solve([eq1,eq2],[b,c]);
>
>I?expected?to?see?b=-(x1+x2)/2?...?but?I?just?get?[]
The solve function returns an empty list when either the solution set is empty or when solve
is unable to solve the equations. In this case, solve is unable to find the solution set.
A workaround:
(%i1) load(to_poly_solver)$
(%i2) eqs : [x1=(-b+sqrt(b^2-4*c))/2,x2=(-b-sqrt(b^2-4*c))/2]$
(%i3) sol : %solve(eqs,[b,c]);
(%o3) %union(%if((-%pi/2<parg(x1-x2)) %and (parg(x1-x2)<=%pi/2),[b=-x2-x1,c=x1*x2],%union()))
When x1-x2 is in the RHP (right half plane), the solution is [b=-x2-x1,c=x1*x2]. For x1-x2 not
in the RHP, the solution set is empty (%union() is the empty set). A partial check:
(%i4) scanmap('factor, subst(second(first(sol)),eqs)),domain : complex;
(%o4) [x1=(sqrt((x2-x1)^2)+x2+x1)/2,x2=-(sqrt((x2-x1)^2)-x2-x1)/2]
When x1-x2 is in the RHP, we have sqrt((x2-x1)^2) = x1-x2. Thus the solution is correct
for x1-x2 in the RHP.
--Barton