0
$\begingroup$

I run a code to NSolve long polynomial 1+a+x^2+b*x^4...+x^10for a particular input parameter with range of values say {a,0,7,1}. The solution give me a 'Table' of complex roots values with each row having different length for example:

{{ 1, 2, 3, 4, 5},
 { 1, 4, 6, 8, 10, 12, 14},
 { 4, 6, 8, 10, 14, 16, 18, 20},
 { 4, 3, 2, 1, 0, 1+i, 1+2*i, -1, -2, -3},
 { 4, 6, 8, 10, 14, 16, 18, 20},
 { 1, 4, 6, 8, 10, 12, 14},
 { 1, 2, 3, 4, 5}}

So each row represents the value of a and each column represents the value of x solution. Therefore for particular value of a=1 , the NSolve gives me 7 solutions or 7 roots. Therefore each a has a solution of different length. I have to plot column wise or each column in complex plane for range of a. The problem I have is that I cannot do PadRight with zeros. I think I have to leave null space as null which means that some columns do not have data points. How do I plot this table of complex values with unequal length in columns or rows in 2D or 3D without padding with zeros or any other value?

Thanks in advance,

WolfMath Ver.9

$\endgroup$
1
$\begingroup$
$Version

(*  "9.0 for Mac OS X x86 (64-bit) (January 24, 2013)"  *)

Note: use I not i for complex numbers

roots = {
   {1, 2, 3, 4, 5},
   {1, 4, 6, 8, 10, 12, 14},
   {4, 6, 8, 10, 14, 16, 18, 20},
   {4, 3, 2, 1, 0, 1 + I, 1 + 2*I, -1, -2, -3},
   {4, 6, 8, 10, 14, 16, 18, 20},
   {1, 4, 6, 8, 10, 12, 14},
   {1, 2, 3, 4, 5}};

It is not clear to me how you want this plotted. One approach

plotData = Table[{Re[#], Im[#], n - 1} & /@ roots[[n]], {n, Length[roots]}];

ListPointPlot3D[plotData, 
 AxesLabel -> (Style[#, 14, Bold] & /@ {Re, Im, Index}),
 BoxRatios -> {1, 1/2, 1}]

enter image description here

EDIT: In 2D the roots are difficult to see since there is significant overlap of the values

plotData2D = Table[{Re[#], Im[#]} & /@ roots[[n]], {n, Length[roots]}];

ListPlot[plotData2D,
 PlotMarkers -> Automatic,
 Frame -> True,
 Axes -> False, FrameLabel -> (Style[#, 14, Bold] & /@ {Re, Im}), 
 PlotLegends -> Automatic,
 PlotRange -> All]

enter image description here

$\endgroup$
  • $\begingroup$ n represents "a" or degree of polynomial? Real and Imaginary are great, but 3rd axis should be in values of 'a' instead of polynomial degree. Each row has assigned value specified in 'a' $\endgroup$ – Aschoolar Jun 17 '17 at 17:47
  • 1
    $\begingroup$ @Aschoolar - The "index" is the (row number -1), i.,e., a running from 0 to 6 since you gave seven data sets. $\endgroup$ – Bob Hanlon Jun 17 '17 at 17:55
  • $\begingroup$ Can index be modified? In my realistic data, I have decimal numbers 0.1, 0.2 etc. zz = {i,0.0,2.2,0.2} $\endgroup$ – Aschoolar Jun 17 '17 at 18:25
  • 1
    $\begingroup$ @Aschoolar - you can make it anything you like. I just used integers starting at zero because that is what you stated in the question. To start at zero and go in steps of 0.2: plotData = Table[{Re[#], Im[#], 0.2 (n - 1)} & /@ roots[[n]], {n, Length[roots]}]; $\endgroup$ – Bob Hanlon Jun 17 '17 at 18:35
  • $\begingroup$ can you put it in 2D? $\endgroup$ – Aschoolar Jul 12 '17 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.