How to Solve Simultaneous Equations for Variable Ranges in Mathematica?

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

Discussion Overview

The discussion revolves around solving simultaneous equations in Mathematica, particularly focusing on how to manage variable ranges and input values effectively. Participants share their experiences and suggestions regarding coding practices and problem-solving techniques within the software.

Discussion Character

  • Technical explanation
  • Homework-related
  • Debate/contested

Main Points Raised

  • One participant expresses difficulty in solving equations due to complex variable names and suggests simplifying them to standard symbols.
  • Another participant recommends using the Block function for variable definitions to avoid issues with variable scope.
  • There is a suggestion to use Solve instead of NSolve for non-polynomial functions, with a note about syntax requirements in Mathematica.
  • A participant identifies a common mistake involving the use of square brackets for grouping, which is reserved for function notation in Mathematica.
  • One participant seeks guidance on how to input a list of values for variables to obtain multiple results simultaneously, indicating a need for clarification on this aspect.
  • Responses suggest using a For loop or Table command for iterating over a list of values, but there is uncertainty about how these methods apply to the specific problem of solving simultaneous equations.

Areas of Agreement / Disagreement

Participants generally agree on the importance of proper variable naming and syntax in Mathematica. However, there is no consensus on the best method for inputting multiple variable values for simultaneous equation solutions, as different approaches are suggested without a clear resolution.

Contextual Notes

Participants note limitations in their understanding of how to apply certain Mathematica commands to their specific problem, indicating a reliance on documentation and examples for clarification.

Who May Find This Useful

This discussion may be useful for individuals learning Mathematica, particularly those working on engineering problems involving simultaneous equations and seeking to understand variable management and input techniques.

windfloyd
Messages
6
Reaction score
0
I just start to learn Mathematica to solve some engineering problem, and got stuck when I was trying to solve a set of equations. Pls see the attachment for the nb. file.
 

Attachments

Physics news on Phys.org
Welcome to PF!

I suggest you copy and paste the part(!) of the code you suppose you're having trouble with getting right and explain what you want to do.

If possible it would also be a good idea to state your problem as general as possible (nobody but you cares about some points specific to your particular problem which actually are not part of the question.)

Anyways, I haven't looked at the file yet (no mathematica here), maybe everything's fine.:smile:
 
The main problem is the names of the variables are too fancy, with subscripts and multiplication sign in the superscripts. Make sure your identifiers are symbols.

I see your programming in a C style, try putting your code in a Block:

Block[{a = 1, B = 2}, NDSolve ... ]
 
Crosson said:
The main problem is the names of the variables are too fancy, with subscripts and multiplication sign in the superscripts. Make sure your identifiers are symbols.

I see your programming in a C style, try putting your code in a Block:

Block[{a = 1, B = 2}, NDSolve ... ]

I have simplified the variables, but still got no answer. See new attached.
 

Attachments

Use Solve instead of NSolve for functions that aren't polynomials. There should be a comma at the end of the first line, and if you do get it running, it may take awhile to run.
 
I got it working. The major problem was that you used square brackets [ ] for grouping, when this is mathematica's notation for a function f[x].
 

Attachments

Thank you so much guys! It works now! But I still have a "silly" question: I'm supposed to get different results based on different input values for variables in the "Block" part, but I don't know how to input a list of values to let the software calculate at the same time instead of one by one? Can you please tell how to do that? In what form should I input the values of the variables?
 
You could use a For loop. Or if you have a predetermined list of values you could use a Table command. Look these up in the documentation center.
 
Crosson said:
You could use a For loop. Or if you have a predetermined list of values you could use a Table command. Look these up in the documentation center.

Thanks! I have looked up the information about how to input a list of values, but that doesn't apply here in my solving-equations problem. I want to get solutions of the simultaneous equations for different values of a variable in the equations. In the new attachment, i want to change t from 50 to 1000, ang get answers for the five unknowns.
 

Attachments

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K