0
$\begingroup$

I'm trying a version of the code with the concavity of the parabola upwards (y=x^2), but I'm not succeeding. I appreciate any help.

Manipulate[
 With[{np = NextPrime[xf]}, 
  Plot[{Sqrt[x], -Sqrt[x]}, {x, 0, xf}, Axes -> {False, True}, 
   Epilog -> {Opacity[.4], Purple, 
     Line /@ Flatten[
       Outer[List, Table[{n^2, n}, {n, 2, np}], 
        Table[{n^2, -n}, {n, 2, np}], 1], 1], 
     Opacity[1], {Black, 
      Text[#, {#, 0}] & /@ 
       Complement[Range[np], Table[Prime[n], {n, np}]]}, Red, 
     PointSize[.01], 
     Table[Tooltip[Point@{Prime[n], 0}, Prime[n]], {n, np}], 
     Table[Tooltip[Point@{n^2, n}, n], {n, 2, np}], 
     Table[Tooltip[Point@{n^2, -n}, n], {n, 2, np}]}, 
   ImageSize -> 600]],
 {{xf, 9, "x"}, 4, 50, Appearance -> "Labeled"}]
$\endgroup$
1
  • 2
    $\begingroup$ Could you clarify what your issue is, The code works. However, the visualization of composite numbers with multiple factors means more and more lines will intersect with composites on x-axis. $\endgroup$
    – ubpdqn
    Commented Jun 29 at 2:53

3 Answers 3

1
$\begingroup$

I made some adjustments to the coordinates.

Manipulate[With[{np = NextPrime[xf]}, Plot[{x^2}, {x, -10, xf}, Axes -> {True, True},
   Epilog -> { Opacity[0.4], Purple, Line /@ Flatten[ Outer[List, Table[{n, n^2}, {n, 2, np}], Table[{-n, n^2}, {n, 2, np}], 1], 1], Opacity[1], {Black, Text[#, {#, 0}] & /@ 
   Complement[Range[np], Table[Prime[n], {n, np}]]},
         Red, PointSize[0.01],
         Table[Tooltip[Point@{Prime[n], 0}, Prime[n]], {n, np}],
         Table[Tooltip[Point@{n, n^2}, n], {n, 2, np}],
         Table[Tooltip[Point@{-n, n^2}, n], {n, 2, np}]
       },
     ImageSize -> 600
   ]
],
{{xf, 9, "x"}, 4, 50, Appearance -> "Labeled"}]
$\endgroup$
0
$\begingroup$

Not sure this is what you are after, but you can just rotate the graph:

Manipulate[
With[{np = NextPrime[xf]}, 
Rotate[Plot[{Sqrt[x], -Sqrt[x]}, {x, 0, xf}, Axes -> {False, True}, 
Epilog -> {Opacity[.4], Purple, 
  Line /@ Flatten[
    Outer[List, Table[{n^2, n}, {n, 2, np}], 
     Table[{n^2, -n}, {n, 2, np}], 1], 1], 
  Opacity[1], {Black, 
   Text[#, {#, 0}] & /@ 
    Complement[Range[np], Table[Prime[n], {n, np}]]}, Red, 
  PointSize[.01], 
  Table[Tooltip[Point@{Prime[n], 0}, Prime[n]], {n, np}], 
  Table[Tooltip[Point@{n^2, n}, n], {n, 2, np}], 
  Table[Tooltip[Point@{n^2, -n}, n], {n, 2, np}]}, 
ImageSize -> 600], 90  Degree]], {{xf, 9, "x"}, 4, 50, 
Appearance -> "Labeled"}]
$\endgroup$
1
  • $\begingroup$ I appreciate your attention, but just rotating doesn't solve it. The values on the horizontal axis will be inverted, the numbers will be upside down. What I wanted was the same procedure as in the parabola y=x^2. That is, I don't want to analyze the situation with the concavity to the right, but with the concavity upwards. $\endgroup$ Commented Jun 28 at 18:31
0
$\begingroup$

It looks like you are trying to visualize a plot involving the square root function and points on a parabola. The Manipulate function in Mathematica can be used to create dynamic plots. I'll provide a version that corrects and refines your code for plotting points and lines associated with the parabola y=x^2,I just corrected and refined version of your code it may work as you want:

Manipulate[
  With[{np = NextPrime[xf]},
    Plot[{Sqrt[x], -Sqrt[x]}, {x, 0, xf},
      Axes -> {False, True},
      Epilog -> {
        Opacity[0.4], Purple,
        Line /@ Flatten[
          Outer[List, Table[{n^2, n}, {n, 2, np}],
            Table[{n^2, -n}, {n, 2, np}], 1], 1],
        Opacity[1], {Black,
          Text[#, {#, 0}] & /@ Complement[Range[np], Table[Prime[n], {n, np}]]},
        Red, PointSize[0.01],
        Table[Tooltip[Point@{Prime[n], 0}, Prime[n]], {n, np}],
        Table[Tooltip[Point@{n^2, n}, n], {n, 2, np}],
        Table[Tooltip[Point@{n^2, -n}, n], {n, 2, np}]
      },
      ImageSize -> 600
    ]
  ],
  {{xf, 9, "x"}, 4, 50, Appearance -> "Labeled"}
]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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