Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I have this equation:

x+y=27
xy=180

I want to solve it using:

Solve[{x+y==27,xy==180},{x,y}]

However this results in the following errors:

  • Set::write: Tag Plus in x+y is Protected. >>
  • Solve::svars: Equations may not give solutions for all "solve" variables. >>

Why? And how do I fix this?

share|improve this question

closed as off-topic by DavidPostill, Kevin Panko, mdpc, Matteo, MariusMatutiae Jun 11 at 15:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is not about computer hardware or software, within the scope defined in the help center." – DavidPostill, Kevin Panko, mdpc, Matteo, MariusMatutiae
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
This question is about the syntax of Mathematica language and not about the use of the software, so is probably more suitable for stackoverflow. –  Simon Sep 27 '11 at 7:44
    
There is site for the Mathematica program, it is mathematica.stackexchange.com –  MariusMatutiae Jun 11 at 15:57

1 Answer 1

up vote 2 down vote accepted

If you just run the line

Solve[{x + y == 27, x y == 180}, {x, y}]

then everything runs fine and you find {{x -> 12, y -> 15}, {x -> 15, y -> 12}}.

The error you see is because somewhere you've got a statement like

In[1]:= x + y = 27

During evaluation of In[1]:= Set::write: Tag Plus in x+y is Protected. >>

Out[1]= 27

Where the head of x + y is Plus which is a protected symbol and can't be naively given new definitions. It might be that you have some weird definition hiding somewhere, in which case, it's simplest to restart the kernel and try again.

The moral of the story is that = (Set) is not the same as == (Equal).

share|improve this answer

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