# VectorDensityPlot, [closed]

I'm trying to plot the following function for two different values of variable m. However, it seems the second figure never appears. Weirdly, I noticed that real numbers are being attributed to variables x and y.

mp[m_, r_, θ_] := {r^2 + Cos[m θ],r^2 - Sin[m θ]};
mc[m_, x_, y_]:=
Evaluate @ TransformedField["Polar" -> "Cartesian", mp[m, r, θ], {r, θ} -> {x, y}];

{VectorDensityPlot[mc[0, x, y], {x, -5, 5}, {y, -5, 5}],
VectorDensityPlot[mc[1, x, y], {x, -5, 5}, {y, -5, 5}]}


## closed as off-topic by Michael E2, Henrik Schumacher, m_goldberg, Bill Watts, José Antonio Díaz NavasFeb 16 at 11:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, Henrik Schumacher, m_goldberg, Bill Watts, José Antonio Díaz Navas
If this question can be reworded to fit the rules in the help center, please edit the question.

• If I use the code in the image -- it seems the posted code has a theta missing the brackets, \Theta instead of \[Theta], the latter being what it shown in the image of the code -- it works and give a correct plot for both. – Michael E2 Feb 13 at 2:52

mp[m_, r_, \[Theta]_] := {r^2 + Cos[m \[Theta]], r^2 - Sin[m \[Theta]]};

mc[m_, x_, y_] := Evaluate@TransformedField["Polar" -> "Cartesian", mp[m, r, \[Theta]], {r, \[Theta]} -> {x, y}];

{VectorDensityPlot[mc[0, x, y], {x, -5, 5}, {y, -5, 5}], VectorDensityPlot[mc[1, x, y], {x, -5, 5}, {y, -5, 5}]}


• You might also consider to post the corrected code in copyable form. – Henrik Schumacher Feb 13 at 1:10
• Thanks for the suggestion. I must be missing something but had to insert the code line-by-line. Okay, only three lines! But it could get tedious. Probably there is a way to insert all the code at once, yes? – mjw Feb 13 at 1:57
• Copy (right-click->As Input) and paste does not work? – Henrik Schumacher Feb 13 at 1:59
• I tried that. Didn't quite work. The first two lines were copied correctly with proper indentation. The third line was not. – mjw Feb 13 at 2:07
• Anyways, you've already got my upvote. Welcome on Mathematica.StackExchange! – Henrik Schumacher Feb 13 at 2:22

Here we can get beautiful pictures

    mp = {r^2 + Cos[m*\[Theta]], r^2 - Sin[m*\[Theta]]};
mc = TransformedField["Polar" -> "Cartesian",
mp, {r, \[Theta]} -> {x, y}];
Table[VectorDensityPlot[mc, {x, -2, 2}, {y, -2, 2},
PlotLabel -> Row[{"m = ", m}], ColorFunction -> Hue,
StreamPoints -> Fine], {m, 0, 9}]


• This is very nice! For m=7, for example, we see a regular heptagon and one of the heptagrams indicated in your figure. I wonder what it would take to see the other one (or is it somehow already in the picture?). [Weisstein, Eric W. "Heptagram." From MathWorld--A Wolfram Web Resource.] (mathworld.wolfram.com/Heptagram.html) – mjw Feb 14 at 0:55
• This is an interesting vector field. Perhaps the author will explain what it describes. – Alex Trounev Feb 14 at 1:20