1
$\begingroup$

Below is my current code in Mathematica. I am trying to plot in polar coordinates from the Points1 list but cannot figure out how to do this correctly.

For each phi value, there are 3 or more values for r. I'm assuming I need to organize these as pairs first, but am having trouble extracting the elements with the || in the middle. Any suggestions for how to organize these as coordinate pairs of phi and r would be greatly appreciated. The || appeared after finding the real.

Thanks for your time, and sorry if I goofed up this post as it is my first. -T

Points1 = {};

Do[Points1 = 
Append[Points1, {phivals[[i]], 
Reduce[{PolarDJ == 0 /. {\[CurlyPhi] -> phivals[[i]]}}, r, 
Reals]}], {i, Length[phivals]}]

Points1 =  {{0., r == -0.91018 || r == 0 || r == 0.91018}, {0.0628319, 
r == -0.905105 || r == -1.22951*10^-8 || r == 1.22951*10^-8 || 
r == 0.905105}, {0.125664, 
r == -0.890241 || r == 0 || r == 0.890241}, {0.188496, 
r == -0.866617 || r == 0 || r == 0.866617}, {0.251327, 
r == -0.835761 || r == 0 || r == 0.835761}, {0.314159, 
r == -0.799487 || r == 0.799487}, {0.376991, 
r == -0.759666 || r == -1.28907*10^-8 || r == 1.28907*10^-8 || 
r == 0.759666}, {0.439823, 
r == -0.718043 || r == 0 || r == 0.718043}, {0.502655, 
r == -0.676112 || r == -1.5092*10^-8 || r == 1.5092*10^-8 || 
r == 0.676112}, {0.565487, 
r == -0.635062 || r == -1.36407*10^-8 || r == 1.36407*10^-8 || 
r == 0.635062}, {0.628319, 
r == -0.595771 || r == 0 || r == 0.595771}, {0.69115, 
r == -0.558838 || r == -1.53443*10^-8 || r == 1.53443*10^-8 || 
r == 0.558838}, {0.753982, 
r == -0.524632 || r == 0 || r == 0.524632}, {0.816814, 
r == -0.493346 || r == 0 || r == 0.493346}, {0.879646, 
r == -0.465044 || r == 0 || r == 0.465044},..}
$\endgroup$
3
  • $\begingroup$ I replaced theta with r in your post, that was a mistake, right? $\endgroup$ – Kuba Jun 29 '17 at 7:09
  • $\begingroup$ What is phivals and PolarDJ? $\endgroup$ – SPPearce Jun 29 '17 at 10:32
  • $\begingroup$ "PolarDJ" is an expression I wrote for a matrix determinant in polar coordinates and "phivals" is a table of values that span from 0 to 2pi with increments of pi/400. I'm writing code to model gravitational microlensing events. If you want to see more code, I can post it, but I didn't want to clutter the page. :) $\endgroup$ – Astroturf Jun 29 '17 at 22:41
1
$\begingroup$

|| is Or you can always investigate with FullForm and then use it to e.g. ReplaceAll with what you need. Here is one variation:

Thread /@ (Points1 /. r == v_ :> v /. Or -> List) // ListPolarPlot

enter image description here

Thread converts {phi, {r1, r2, r3}} to {{phi, r1}, {phi, r2}, {phi, r3}}

You could add Catenate but now each phi set has unique color.

$\endgroup$
2
  • $\begingroup$ Thank you so much! (The r and theta were correct initially). $\endgroup$ – Astroturf Jun 29 '17 at 8:46
  • $\begingroup$ @TiffanyVisgaitis I'm glad it works for you. Please take a tour $\endgroup$ – Kuba Jul 3 '17 at 8:14
0
$\begingroup$

Here are two somewhat shorter alternatives to Kuba's replacement method:

a = Tuples@{{#}, Last /@ #2} & @@@ Points1;

b = {#,r} /. {ToRules@#2} & @@@ Points1;

a === b   (* True *)

ListPolarPlot[a]

enter image description here

$\endgroup$

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.