0
$\begingroup$

I have the following situation and I completely do not understand why the second system can be solved but the first (of the same equations, as it seems) cannot. How is it possible?

In[1]:= a={x^2+y^2==1};
Append[a,x+y==0]
Solve[a,{x,y}]

b={x^2+y^2==1,x+y==0}
Solve[b,{x,y}]

Out[2]= {x^2+y^2==1,x+y==0}
During evaluation of In[1]:= Solve::svars: Equations may not give solutions for all "solve" variables. >>
Out[3]= {{y->-Sqrt[1-x^2]},{y->Sqrt[1-x^2]}}
Out[4]= {x^2+y^2==1,x+y==0}
Out[5]= {{x->-(1/Sqrt[2]),y->1/Sqrt[2]},{x->1/Sqrt[2],y->-(1/Sqrt[2])}}
$\endgroup$
2
  • 1
    $\begingroup$ Did you mean to use AppendTo[a,x+y==0]? ...because simply using Append does not modify a $\endgroup$ Apr 14 '15 at 16:13
  • $\begingroup$ @Manuel--Moe--G Thank you! So that is just a consequence of my poor knowledge of the program. $\endgroup$
    – Hypsoline
    Apr 14 '15 at 16:23
2
$\begingroup$

Append has no side effect

You may try AppendTo

a = {x^2 + y^2 == 1};
AppendTo[a, x + y == 0]
Solve[a, {x, y}]

resulting in

 (* {{x -> -(1/Sqrt[2]), y -> 1/Sqrt[2]}, {x -> 1/Sqrt[2], 
      y -> -(1/Sqrt[2])}} *)

or consider simply

Append[a, x + y == 0] // Solve
$\endgroup$
1
  • $\begingroup$ a=Append[a,x+y==0] also would work. $\endgroup$
    – corey979
    Apr 14 '15 at 23:29

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