I need a little bit help about mathematica

In summary, you are looking for a way to plot the real roots of a equation separately from the imaginary roots. You use M=NSolve to solve for T and P for the 12 angles. You use xroots and yroots to find the real and imaginary roots, and then you use Plot to plot them on a graph.
  • #1
sedat
15
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: 418
Physics news on Phys.org
  • #2
Looking forward to hearing smth from you...
 
  • #3
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
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 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
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
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.
 
  • #7
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
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
 
  • #9
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.
 

Related to I need a little bit help about mathematica

1. Can Mathematica help me with my specific mathematical problem?

Yes, Mathematica is a powerful tool for solving a wide range of mathematical problems. It can handle algebra, calculus, statistics, and more. It also has built-in functions for common mathematical operations and the ability to create custom functions.

2. How can I learn how to use Mathematica?

There are many resources available for learning how to use Mathematica, including online tutorials, user guides, and in-person classes. The Mathematica website also has a vast knowledge base and community forums for support and learning.

3. Can I use Mathematica for data analysis and visualization?

Yes, Mathematica has powerful data analysis capabilities, including built-in statistical functions and the ability to import and manipulate large datasets. It also has advanced visualization tools for creating graphs, charts, and other visual representations of data.

4. Can I use Mathematica for programming and creating applications?

Yes, Mathematica has a programming language called Wolfram Language that allows users to create programs and applications. It also has a built-in development environment for coding and debugging.

5. How can I get help if I get stuck while using Mathematica?

There are several ways to get help while using Mathematica. You can consult the built-in documentation, search the knowledge base, or ask questions on the community forums. There are also user groups and online resources for additional support.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
355
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
10K
  • Programming and Computer Science
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top