Replacing Mass in Equations of Motion: Quick Mathematica Question

  • Context: Mathematica 
  • Thread starter Thread starter kq6up
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around the challenge of replacing mass variables in equations of motion with negative mass using Mathematica. Participants explore methods to achieve this without manually altering complex equations.

Discussion Character

  • Technical explanation, Homework-related

Main Points Raised

  • Chris initially attempted to replace m1 with -m1 directly, which resulted in infinite recursion.
  • One participant suggested using a temporary variable (mm1) to replace m1, then substituting mm1 with -m1 as a workaround.
  • Chris later confirmed using a similar approach with a different notation (m_1=-m_{11}).
  • Another participant proposed a straightforward replacement rule in Mathematica: eq /.{m1 -> -m1}, which effectively replaces all occurrences of m1 with -m1 in the equation.

Areas of Agreement / Disagreement

Participants generally agree on the need for a workaround to avoid recursion when replacing mass variables, with multiple methods proposed but no consensus on a single best approach.

Contextual Notes

The discussion highlights the complexity of the equations involved and the potential for confusion when directly substituting variables in Mathematica.

Who May Find This Useful

Students and practitioners using Mathematica for physics problems, particularly those dealing with equations of motion and variable substitutions.

kq6up
Messages
366
Reaction score
13
I have equation of motion that our instructor wants to replace one or both of the masses with a negative mass in Mathematica. I tried m1=-m1, but I get an infinite recursion. What is the best way to do this? The equations of motion is a monster, so I don't really want to do this by hand.

Thanks,
Chris
 
Physics news on Phys.org
Just a thought: Replace m1 by mm1 or some such, then replace mm1 by - m1. This may allow you to fool the computer.
 
Yes, I ended up doing something just like that ##m_1=-m_{11}##.

Thanks,
Chris
 
kq6up said:
I have equation of motion that our instructor wants to replace one or both of the masses with a negative mass in Mathematica. I tried m1=-m1, but I get an infinite recursion. What is the best way to do this? The equations of motion is a monster, so I don't really want to do this by hand.
The easiest way is:
eq /.{m1 -> -m1}

This goes through the expression eq and replaces every occurrence of m1 with -m1. It is very worthwhile learning this technique of using replacement rules.
 
Awesome, thank you.

Chris
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 19 ·
Replies
19
Views
4K