Message Boards Message Boards

Problem solving system of three equations

Posted 11 months ago

Hello everyone, I'm new to Mathematica and to this forum, so if my post is wrong here please tell me where the question is more appropriate.
Probably my problem is quite simple, but I have the system of equations

Solve[x^2 + y^2 + z^2 == 1 && 
  2*x*y*1/sqrt (d - 1) + y^2*(d - 2)/(d - 1) + z^2 == 0 && 
  x^2*A^2 + y^2*B^2 + z^2*F^2 + x*y*2*G + x*z*2*H + y*z*2*J == C, {x, 
  y, z}, Reals]

where I want to get symbolic solutions for x, y and z, but when I run that in Mathematica, I get the error line "Solve: 0 is not a valid variable." and the Output

Solve[x^2 == 1 && A^2 x^2 == C, {x, 0, 0}, Reals]

So what am I doing wrong?

POSTED BY: Alex B.
4 Replies

Again, case matters. Sqrt is a built-in function whereas sqrt is just an unknown symbol. sqrt(...) multiplies this symbol by the ... in the parens.

C is a "constant" used in functions like Integrate for results. The usage states "...is a ...constant generated in representing the results of various symbolic computations". In particular this refers to results, not input. It is not advised to use it for input. You might instead use c as that has no built-in meaning attached.

POSTED BY: Daniel Lichtblau
Posted 11 months ago

Thank you for your reply! I thought that clicking "Evaluate -> Notebook" does clear the cache and does start to calculate the whole document from scratch. But apparently this assumption was wrong? Thanks also for pointing out the use of sqrt. Now I know that sqrt[ ] is what I intended. What does sqrt( ) do? I saw in Mathematica that "C" is specified as constant and I had intended to use C as a placeholder for some unknown constant. So is my use of it correct? x,y,z were intended to be variables and all the other letters should be some fixed numerical values.

I added the line Clear[x,y,z] to the top of the document and changed the sqrt. Now I ran (and are still running, because it hasn't given me any output yet) "Evaluate -> Notebook". Is this the correct way to get the result? Is there a possibility to check if Mathematica is still calculating and will come to a solution or if it is stuck in an endless calculation due to a coding mistake? Is pressing "Evaluate -> Quit -> Local" the right way to quit the calculation or is there a better option?

Thanks to everyone reading and answering this in advance!

POSTED BY: Alex B.

Your system is of degree 8, with 8 parameters. If the parameters are replaced with numbers, as in

With[{d = 3, A = 1, B = 2, F = 1,
  G = 1, H = 1, J = 1, c = 1},
 Solve[x^2 + y^2 + z^2 == 1 &&
   2*x*y*1/Sqrt [d - 1] +
     y^2*(d - 2)/(d - 1) + z^2 == 0 &&
   x^2*A^2 + y^2*B^2 + z^2*F^2 + x*y*2*G +
     x*z*2*H + y*z*2*J == c,
  {x, y, z}, Reals]]

it is solved very quickly. Unfortunately, the parameters make everything complicated. Look at what happens by leaving the parameter c free:

With[{d = 3, A = 1, B = 2, F = 1,
  G = 1, H = 1, J = 1},
 Solve[x^2 + y^2 + z^2 == 1 &&
   2*x*y*1/Sqrt [d - 1] +
     y^2*(d - 2)/(d - 1) + z^2 == 0 &&
   x^2*A^2 + y^2*B^2 + z^2*F^2 + x*y*2*G +
     x*z*2*H + y*z*2*J == c,
  {x, y, z}, Reals]]

the solution is an expression that takes 2.5 MB to store, and it hard to understand and use. With 8 free parameters the situation is hopeless.

POSTED BY: Gianluca Gorni

You apparently set y and z to 0. So you can run

Clear[y,z];

to address this.

Also note that sqrt(d-1) is not related to Sqrt[d-1] (syntax and case both matter). Last, be aware that some capitalized letters such as C are built-in symbols and this can in some cases affect the outcome. I doubt it will matter in this example but it is best practice to avoid using such symbols as variables or parameters.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract