2

How to calculate $x,y,k$ in terms of constants $a$ and $b$ in the following equations in Mathematica:

4*y-k*2*x/a^2=0,
4*x-k*2*y/b^2=0,
x^2/a^2+y^2/b^2-1=0

Why doesn't the following command work? (I am new)

Solve[4*y-k*2*x/a^2=0&&4*x-k*2*y/b^2=0&&x^2/a^2+y^2/b^2-1=0,{x,y,k},reals]
captain23
  • 113
  • 1
  • 4

1 Answers1

6

There are many errors in your code:

  1. it is Reals not reals
  2. you have to write == instead of = (read here for example)
  3. you need curl brackets (as Bob Hanlon points out, there is no need of brackets if && is used).

The correct code is:

Solve[{4*y - k*2*x/a^2 == 0 && 4*x - k*2*y/b^2 == 0 && 
   x^2/a^2 + y^2/b^2 - 1 == 0}, {x, y, k}, Reals]

EDIT If you have to consider some assumptions, use the following code:

Assuming[{your assumptions},Simplify[Solve[{4*y - k*2*x/a^2 == 0 && 4*x - k*2*y/b^2 == 0 && 
   x^2/a^2 + y^2/b^2 - 1 == 0}, {x, y, k}, Reals]]]
mattiav27
  • 6,677
  • 3
  • 28
  • 64
  • Thank you very much. How can we add to more conditions which are $x>0$ and $x>0$? – captain23 Mar 22 '17 at 12:19
  • 2
    @mattiav27, you'd actually want to put Simplify[] within Assuming[] so that any assumptions set get accounted for in simplification. – J. M.'s missing motivation Mar 22 '17 at 12:32
  • 2
    Since && is used, equations do not have to be inside brackets, Brackets are needed if the equations are separated by commas. First argument to Solve can include inequalities, e.g., Solve[4*y - k*2*x/a^2 == 0 && 4*x - k*2*y/b^2 == 0 && x^2/a^2 + y^2/b^2 - 1 == 0 && x > 0 && y > 0, {x, y, k}, Reals]; however, Assuming is better since as @J.M.points out they are passed to Simplify. – Bob Hanlon Mar 22 '17 at 16:54