I need a little bit help about mathematica

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

Discussion Overview

The discussion revolves around using Mathematica to find and separate the roots of two non-linear equations. Participants explore methods to obtain independent roots for variables x and y, and how to visualize these roots in a 2D plot over a specified range of angles.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Exploratory

Main Points Raised

  • One participant seeks help with the FindRoot command in Mathematica to separate roots of two equations for x and y.
  • Another participant questions the use of ArcTan and suggests clarifying the expected results from the equations.
  • Several participants propose using NSolve to find roots and suggest methods to extract x and y values separately.
  • There is a discussion about the need for real roots and how to visualize them using plots, with suggestions to plot the imaginary components to identify real roots.
  • A participant shares source code and expresses the desire to create a point-cloud plot of all real roots in 2D.
  • One participant confirms that their proposed solution works effectively for obtaining the desired results.

Areas of Agreement / Disagreement

Participants generally agree on the approach of using NSolve to find roots, but there are varying opinions on how to visualize the results and the necessity of separating the roots. The discussion remains unresolved regarding the best method for plotting the roots effectively.

Contextual Notes

Some participants mention the need for real roots and the challenges of dealing with complex-conjugate roots. There are also references to specific ranges for angles and the implications of these choices on the results.

Who May Find This Useful

This discussion may be useful for Mathematica users dealing with non-linear equations, particularly those interested in root-finding techniques and graphical representations of mathematical solutions.

sedat
Messages
15
Reaction score
0
Hello, my problem is that I could not be able to find to separate the roots with the command of FindRoot. Altough I have 2 non-linear equations, I can solve these with FindRooot, but I'd like to have separetely the roots I mean independent roots each other (x apart and y apart). I wonder if i can print this in mathematica or not.

Since i need it to get into a equation separetely. After having the roots apart apart, I will need to have a loop from 0 degree to 359 degree in order to have X-Y loci.

I will be very gratefull If somebody helps me on this issue.

Already Thanks
Sending a print screen
 

Attachments

  • adsız.JPG
    adsız.JPG
    20.6 KB · Views: 488
Physics news on Phys.org
Looking forward to hearing smth from you...
 
Your FindRoot[] is going to return {T->nn.nnn, P->mm.mmm}.

It is unclear what you expect from the ArcTan[] following that. It has no trailing ; Can you explain what you expect the ArcTan[] to do.

N is a special symbol for Mathematica, I suggest using some other name.

Inside your For[] are you looking for the solution in T and P for the 12 angles a? If you can explain what you want for a result then perhaps I can suggest how to change this.
 
Bill Simpson said:
Your FindRoot[] is going to return {T->nn.nnn, P->mm.mmm}.

It is unclear what you expect from the ArcTan[] following that. It has no trailing ; Can you explain what you expect the ArcTan[] to do.

N is a special symbol for Mathematica, I suggest using some other name.

Inside your For[] are you looking for the solution in T and P for the 12 angles a? If you can explain what you want for a result then perhaps I can suggest how to change this.[/QUOT

I am looking for X and Y values for each angles till 12 degress, but I'd like to have X and Y as apart form, namely; printing X and then Y values separately on the screen that I can put these into different equations. As to Tan, I just realized it is unnecessary maybe I put it into another step soon. After getting X and Y values, I need to plot these in 2D graphics represantation as well.

I hope that it is clear now.
 
Last edited:
Replace beginning at your FindRoot[] with this

M=NSolve[{T,P},{x,y}];

and then

xroots=Table[x/.M,{a,0,11}]

and then

yroots=Table[y/.M,{a,0,11}]

Tell me if those are the correct solutions to the original problem.

For graphics, since it looks like you have 12 conjugate pairs of roots for x and for y, are you expecting the graphics to be two plots of 12 pairs of points in the complex plane? I can't tell what form you want your graphics to be in.
 
Bill Simpson said:
Replace beginning at your FindRoot[] with this

M=NSolve[{T,P},{x,y}];

and then

xroots=Table[x/.M,{a,0,11}]

and then

yroots=Table[y/.M,{a,0,11}]

Tell me if those are the correct solutions to the original problem.

For graphics, since it looks like you have 12 conjugate pairs of roots for x and for y, are you expecting the graphics to be two plots of 12 pairs of points in the complex plane? I can't tell what form you want your graphics to be in.

I wrote your suggestions into the programme and I saw that I have complex-conjugate roots as you predicted before, but I need to have only real roots and I trace the roots into a plotting in X-Y coordinate system.
 
Since you seem to be interested in 0<=a<=12 degrees and you must have real roots, If I use
M = NSolve[{T, P}, {x, y}];
xroots = x/.M;
yroots = y/.M;
and then look at these one at a time
Plot[Im[First[xroots]],{a,0,12}]
Plot[Im[Last[xroots]],{a,0,12}]
Plot[Im[First[yroots]],{a,0,12}]
Plot[Im[Last[yroots]],{a,0,12}]
that gives me an idea where you will have zero imaginary component and thus a real root.

Study those four plots and see what you can decide about real roots for your problem.
 
Bill Simpson said:
Since you seem to be interested in 0<=a<=12 degrees and you must have real roots, If I use
M = NSolve[{T, P}, {x, y}];
xroots = x/.M;
yroots = y/.M;
and then look at these one at a time
Plot[Im[First[xroots]],{a,0,12}]
Plot[Im[Last[xroots]],{a,0,12}]
Plot[Im[First[yroots]],{a,0,12}]
Plot[Im[Last[yroots]],{a,0,12}]
that gives me an idea where you will have zero imaginary component and thus a real root.

Study those four plots and see what you can decide about real roots for your problem.

source code is the following,

l1 = 40.1039;
l2 = 12;
l3 = 41.8413;
l4 = 42.2413;
l5 = 35.5833;
T = (x - l1*Cos[a Degree])^2 + (y - l1*Sin[a Degree])^2 - (l2 + l3)^2 == 0;
P = y^2 + (l5 - x)^2 - l4^2 == 0;
M = NSolve[{T, P}, {x, y}];
S = For[a = 0, a < 360, a++, Print[M]];
xroots = Table[x /. M, {a, 0, 360}];
yroots = Table[y /. M, {a, 0, 360}];
Plot[Im[First[xroots]], {a, 0, 360}]
Plot[Im[Last[xroots]], {a, 0, 360}]
Plot[Im[First[yroots]], {a, 0, 360}]
Plot[Im[Last[yroots]], {a, 0, 360}]

everything is fine apart from plotting, What I expect, my friend ; is to have a point-cloud in the plotting including all the real roots in 2D x and y

Thank you
 
M = NSolve[{T, P}, {x, y}];
roots = Table[{x, y} /. M, {a, 0, 360}];
realroots = Select[Flatten[roots, 1], Element[First[#], Reals] && Element[Last[#], Reals] &];
ListPlot[realroots]
 
  • #10
Bill Simpson said:
M = NSolve[{T, P}, {x, y}];
roots = Table[{x, y} /. M, {a, 0, 360}];
realroots = Select[Flatten[roots, 1], Element[First[#], Reals] && Element[Last[#], Reals] &];
ListPlot[realroots]

Thank you my friend, it works very well.
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 15 ·
Replies
15
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
10K