Troubleshooting Mathematica: Identifying Strange Behavior & Solutions

In summary, the issue seems to be that when the user pasted in the equation, it changed the order in which Mathematica evaluated the cells, causing the problem.
  • #1
Dustinsfl
2,281
5
Can someone identity what the issue here is before I throw my computer out the window.
By the way, this just worked 10mins ago. I restarted Mathematica and my computer but it now insist z isn't an equation.
Code:
ClearAll["Global`*"];
me = 5.974*10^(24);
mm = 7.348*10^(22);
G = 6.67259*10^(-20);
\[Mu] = G*(me + mm);
re = 6378;
rm = 1737;
\[Pi]1 = me/(me + mm);
\[Pi]2 = mm/(me + mm);
x = -4671;
y = -6578;
r12 = r1 = r2 = 384400;
(*r1=Sqrt[(x+\[Pi]2*r12)^2+y^2];
r2=Sqrt[(x-\[Pi]1*r12)^2+y^2];*)
M = me + mm; vi = 8;
\[Nu] = -\[Pi]/2;
e = 1;
vi = 10.8662;

\[Gamma] = ArcTan[e*Sin[\[Nu]]/(1 + e*Cos[\[Nu]])];
vx = vi*(Sin[\[Gamma]]*Cos[\[Nu]] - Cos[\[Gamma]]*Sin[\[Nu]]);
vy = vi*(Sin[\[Gamma]]*Sin[\[Nu]] + Cos[\[Gamma]]*Cos[\[Nu]]);
rx = -4671;
ry = -6578;
rz = 0;

\[CapitalOmega] = Sqrt[\[Mu]/r12^3];
\[Mu]1 = G*me;
\[Mu]2 = G*mm;

r0 = {rx, ry, rz};
v0 = {vx, vy, rz};

s = NDSolve[{x''[t] - 
      2*\[CapitalOmega]*y'[t] - \[CapitalOmega]^2*
       x[t] == -\[Mu]1/r1^3*(x[t] + \[Pi]2*r12) - \[Mu]2/
        r2^3*(x[t] - \[Pi]1*r12),
    y''[t] - 
      2*\[CapitalOmega]*x'[t] - \[CapitalOmega]^2*
       y[t] == -\[Mu]1/r1^3*y[t] - \[Mu]2/r2^3*y[t], 
    z''[t] == -\[Mu]1/r1^3*z[t] - \[Mu]2/r2^3*z[t],
    x[0] == r0[[1]],
    y[0] == r0[[2]],
    z[0] == r0[[3]],
    x'[0] == v0[[1]],
    y'[0] == v0[[2]],
    z'[0] == v0[[3]]},
   {x, y, z}, {t, 0, 1000000}];

NDSolve::deqn: Equation or list of equations expected instead of False in the first argument {0. -7.10426\[CenterDot]10^-12 (-4671)[t]==-8.63204\[CenterDot]10^-14 (-379729.+(-4671)[t])-7.01794\[CenterDot]10^-12 (4670.66 +(-4671)[t]),0. -7.10426\[CenterDot]10^-12 (-6578)[t]==-7.10426\[CenterDot]10^-12 (-6578)[t],<<5>>,False,(z^\[Prime])[0]==0}. >>
 
Physics news on Phys.org
  • #2
dwsmith said:
...before I throw my computer out the window...

Sorry, can't help with the Mathematica issue, but just wanted to say I have considered throwing my computer in my pond before.(Tmi)
 
  • #3
You define

x = -4671;
y = -6578;

and then you use both x = x[t] and y = y[t] in NDSolve. That might be tripping you up. Try renaming variables. What might especially confirm this is that the double equals, which is definitely what you need in NDSolve, will yield TRUE or FALSE if the stuff on either side is already defined.

When something works, and then it doesn't work, in Mathematica, that's typically happening because of the order in which cells are evaluated. If these commands are spread out over a bunch of different cells, then the order really matters.
 
  • #4
Ackbach said:
You define

x = -4671;
y = -6578;

and then you use both x = x[t] and y = y[t] in NDSolve. That might be tripping you up. Try renaming variables. What might especially confirm this is that the double equals, which is definitely what you need in NDSolve, will yield TRUE or FALSE if the stuff on either side is already defined.

When something works, and then it doesn't work, in Mathematica, that's typically happening because of the order in which cells are evaluated. If these commands are spread out over a bunch of different cells, then the order really matters.

The only problem was mathematica. I copied everything over to a new notebook and it worked.
 
  • #5
dwsmith said:
The only problem was mathematica. I copied everything over to a new notebook and it worked.

Yep, that's a good trick, too. Glad it's working for you now.
 

Related to Troubleshooting Mathematica: Identifying Strange Behavior & Solutions

1. What are some common signs of strange behavior in Mathematica?

Some common signs of strange behavior in Mathematica include error messages, unexpected outputs, and slow performance.

2. How can I identify the cause of strange behavior in Mathematica?

One way to identify the cause of strange behavior in Mathematica is to carefully examine the code and inputs used. Another option is to use the built-in debugger to step through the code and locate any errors or unexpected behavior.

3. Can conflicting package installations cause strange behavior in Mathematica?

Yes, conflicting package installations can often lead to strange behavior in Mathematica. It is important to ensure that all packages and extensions are properly installed and up-to-date.

4. How can I troubleshoot issues with Mathematica's graphics or visualization functions?

If you are experiencing issues with Mathematica's graphics or visualization functions, try adjusting the display options or using a different graphics engine. It may also be helpful to check for any known bugs or conflicts with your operating system or graphics card.

5. Is there a community or support forum for troubleshooting Mathematica?

Yes, there is a community forum on the official Mathematica website where users can ask for help and share tips and solutions for troubleshooting issues. There are also many online resources and tutorials available for troubleshooting Mathematica.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
252
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
88
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top