0

I'm am trying to get Mathematica to determine the intersection of a line and a parabola, like so:

Solve[{x + y == 6, x^2 == y}, {x, y}]

But evaluating this gives Recursion depth of 1024 exceeded. and Iteration limit of 4096 exceeded.

Does this problem need to be expressed in some other way?

billc
  • 684
  • 5
  • 16

1 Answers1

2

As @belisarius noted, the problem here is that x and y were defined at an earlier point in the Mathematica session.

This kind of error can be prevented like so:

Block[{x, y}, Solve[{x + y == 6, x^2 == y}, {x, y}]]

which localizes x and y, correctly giving:

{{x -> -3, y -> 9}, {x -> 2, y -> 4}}

This problem is discussed in more detail in the Lingering Definitions section of Pitfalls for New Users.

billc
  • 684
  • 5
  • 16
  • Speaking as a new user I also recommend to make use of ? or ?? rather often to see if variables and or functions are internally implemented as desired. If not, as you mentioned Blockwould be a workaround or to use Clear – Spaced May 08 '15 at 23:58
  • 1
    If we are going to take walkarounds ..Solve[{\[FormalX] + \[FormalY] == 6, \[FormalX]^2 == \[FormalY]}, {\[FormalX], \[FormalY]}] – Dr. belisarius May 09 '15 at 00:01