I need a little bit help about mathematica

  • Mathematica
  • Thread starter sedat
  • Start date
  • #1
15
0

Main Question or Discussion Point

Hello, my problem is that I could not be able to find to seperate 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

Answers and Replies

  • #2
15
0
Looking forward to hearing smth from you...
 
  • #3
1,069
29
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.
 
  • #4
15
0
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 seperately 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:
  • #5
1,069
29
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.
 
  • #6
15
0
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.
 
  • #7
1,069
29
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.
 
  • #8
15
0
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
 
  • #9
1,069
29
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
15
0
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.
 

Related Threads on I need a little bit help about mathematica

Replies
7
Views
2K
Replies
7
Views
2K
Replies
2
Views
1K
Replies
2
Views
3K
Replies
4
Views
2K
Replies
1
Views
2K
Replies
1
Views
1K
Replies
1
Views
1K
Replies
1
Views
2K
Top