Message Boards Message Boards

0
|
5078 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Equation Solving - Bug?

Posted 11 years ago
Hi all,

I'm trying to solve a set of three equations in three variables: ax, ay, and az. However, Mathematica's ability to solve the equations seems to depend on the way in which I write them, in a trivial way.

This one works:

but this one doesn't:



The only difference between the two is that I moved things around (solved for the v dot a expression), and used a1 instead of ax, v1 to mean vx, etc.

Why does this happen? How can I structure my equations in a way that Mathematica will be able to solve them?

Thanks a ton!
POSTED BY: Felix Feist
3 Replies
Hi Frank,

this might help:
DeleteCases[
Table[{Names["Global`*"][[k4313]], (Names["Global`*"] // ToExpression)[[k4313]]}, {k4313, 1, Length[Names["Global`*"]]}],
{"k4313", ___}] // TableForm
 I am quite sure that here is an easier way though. This particular function works only for the global context.

M.
POSTED BY: Marco Thiel
Posted 11 years ago
On the menu bar try clicking on Evaluation, Quit Kernel,  Local, Quit
and then try evaluating your two problems again.
 In[1]:= Solve[{
   c^2 (F1 - m*g*a1)/(g^3*v1*m) == v1*a1 + v2*a2 + v3*a3,
   c^2 (F2 - m*g*a2)/(g^3*v2*m) == v1*a1 + v2*a2 + v3*a3,
   c^2 (F3 - m*g*a3)/(g^3*v3*m) == v1*a1 + v2*a2 + v3*a3},
  {a1, a2, a3}]
 
 Out[1]= {{
   a1 -> -((-c^2 F1 + F2 g^2 v1 v2 - F1 g^2 v2^2 + F3 g^2 v1 v3 - F1 g^2 v3^2)/
    (g m (c^2 + g^2 v1^2 + g^2 v2^2 + g^2 v3^2))),
  a2 -> -((-c^2 F2 - F2 g^2 v1^2 + F1 g^2 v1 v2 + F3 g^2 v2 v3 - F2 g^2 v3^2)/
   (g m (c^2 + g^2 v1^2 + g^2 v2^2 + g^2 v3^2))),
  a3 -> -((-c^2 F3 - F3 g^2 v1^2 - F3 g^2 v2^2 + F1 g^2 v1 v3 + F2 g^2 v2 v3)/
   (g m (c^2 + g^2 v1^2 + g^2 v2^2 + g^2 v3^2)))}}

In[2]:= Solve[{
  fx == m*vx*g^3 (vx*ax + vy*ay + vz*az)/c^2 + g*m*ax,
  fy == m*vy*g^3 (vx*ax + vy*ay + vz*az)/c^2 + g*m*ay,
  fz == m*vz*g^3 (vx*ax + vy*ay + vz*az)/c^2 + g*m*az},
{ax, ay, az}]

Out[2]= {{
   ax -> -((-c^2 fx + fy g^2 vx vy - fx g^2 vy^2 + fz g^2 vx vz - fx g^2 vz^2)/
   (g m (c^2 + g^2 vx^2 + g^2 vy^2 + g^2 vz^2))),
  ay -> -((-c^2 fy - fy g^2 vx^2 + fx g^2 vx vy + fz g^2 vy vz - fy g^2 vz^2)/
   (g m (c^2 + g^2 vx^2 + g^2 vy^2 + g^2 vz^2))),
  az -> -((-c^2 fz - fz g^2 vx^2 - fz g^2 vy^2 + fx g^2 vx vz + fy g^2 vy vz)/
   (g m (c^2 + g^2 vx^2 + g^2 vy^2 + g^2 vz^2)))}}
It is likely, but impossible to verify now, that you had some value assigned to something which gave no solution to the second problem.
This is a somewhat common problem and often extremely difficult to recognize when it happens unless you know the result is incorrect.

In the future, a powerful method for checking this is to scrape-n-paste your three equations into a new cell and tapping <shift><enter>.
If the result appears to be exactly what your system was then it is unlikely that something had accidentally been assigned to some variable.
But if the result looks somewhat or very different then you can try to track down which variable might have have some unexpected value.

Or perhaps it is a difference in behavior between one version of Mathematica and another.
POSTED BY: Bill Simpson
Is there a way of displaying all variables with assigned values?
POSTED BY: Frank Kampas
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