2
$\begingroup$

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]
$\endgroup$
0

1 Answer 1

6
$\begingroup$

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]]]
$\endgroup$
3
  • $\begingroup$ Thank you very much. How can we add to more conditions which are $x>0$ and $x>0$? $\endgroup$
    – captain23
    Mar 22, 2017 at 12:19
  • 2
    $\begingroup$ @mattiav27, you'd actually want to put Simplify[] within Assuming[] so that any assumptions set get accounted for in simplification. $\endgroup$ Mar 22, 2017 at 12:32
  • 2
    $\begingroup$ 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. $\endgroup$
    – Bob Hanlon
    Mar 22, 2017 at 16:54

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