System of equation with Mathematica: HELP

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

Discussion Overview

The discussion revolves around solving a system of equations using Mathematica, specifically focusing on the challenges encountered when introducing a magnetic field parameter into the equations. The context includes numerical methods for finding solutions and potential code improvements.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant describes their Mathematica code for solving a system of equations and notes that it works without a magnetic field but fails to find a solution when a magnetic field is introduced.
  • The same participant inquires about the possibility of using numerical methods to find solutions when the system does not yield results with the current approach.
  • Another participant shares an improved version of the code, suggesting a method to simplify the equations and apply criteria for selecting solutions.
  • A later post expresses gratitude for the assistance received in the discussion.
  • One participant asks how the Mathematica code could be translated into MATLAB, indicating a potential interest in cross-platform coding solutions.

Areas of Agreement / Disagreement

Participants have not reached a consensus on the effectiveness of the proposed solutions, and the discussion remains open regarding the best approach to solving the system of equations with the magnetic field included.

Contextual Notes

The discussion includes unresolved issues related to the behavior of the system of equations under different conditions, particularly the introduction of the magnetic field, and the limitations of the Mathematica code provided.

ilvreth
Messages
33
Reaction score
0
System of equations with Mathematica: HELP

Hi there. I am trying to solve a system of equations. I have written a mathematica code to solve this systems
Code:
<< VectorAnalysis`
Kc > Ku > 0;
Kuz > 0;
SS = 2.5;
Hfz > 0;
Kc = 0.0144;
Ku = Kc/3;
Kuz = 5 Kc;
B = 0.1;
Hfz = 0.1157676*B;
S = {Sx, Sy, Sz};
Eh = Kc (Sx^2  Sy^2 + Sx^2  Sz^2 + Sy^2   Sz^2) + Kuz   Sz^2 - Ku  Sx  Sy + SS  Hfz Sz; 
Heffx = D[Eh, Sx];
Heffy = D[Eh, Sy];
Heffz = D[Eh, Sz];
Heff = -{Heffx, Heffy, Heffz};
Cross[S, Heff]; 
Sx = Sin[\[Phi]] Sin[\[Theta]];
Sy = Cos[\[Phi]] Sin[\[Theta]];
Sz = Cos[\[Theta]]; 
eq = Cross[S, Heff] == 0;
Reduce[{eq && 0 <= \[Phi] <= 2 \[Pi] && 0 <= \[Theta] <= \[Pi]}, {\[Phi], \[Theta]}, Reals]

where B is the magnetic field in Tesla. When i have B=0 it finds solution (which is simple without mathematica). But when you put a magnetic field e.g. B=0.1 does not give a solution and the program is running anyway...

Is there any way to find solutions with a numerical method or something?
(The system of equations contains 3 equations and these are the 3 components of the vector S x Heff )
 
Last edited:
Physics news on Phys.org
I managed to make a slight improvement.
I'll just give you the code

Code:
eq = Cross[S, Heff] == {0, 0, 0} // Thread // FullSimplify
criteria[\[Phi]_, \[Theta]_] := \[Phi] \[Element] 
   Reals && \[Theta] \[Element] Reals && 0 <= \[Phi] <= 2 \[Pi] && 
  0 <= \[Theta] < \[Pi]
Select[NSolve[eq, {\[Theta], \[Phi]}], 
 criteria[\[Phi] /. #, \[Theta] /. #] &]
If you get confused, just shout, ok?
 
Thank you very much my friend! Thank you for you help!
 
How this code could be written in MATLAB?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K