# How to graph an implicit polar equation?

I need to graph the following implicit polar equation using Latex

I would be very thankful for any help. Thanks

• Welcome to TeX.SX! pgfplots can draw polar graphs; you can make the equation explicit, by the way. – egreg Dec 12 '15 at 23:44

As @egreg suggests, you can plot your data in polar graphs. Say you want to plot r = sin(2a) where a is the angle and r is the magnitude,

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.polar}

\begin{document}

\begin{tikzpicture}
\begin{polaraxis}
{sin(2*x)};
% the expression is the RADIUS
\end{polaraxis}
\end{tikzpicture}

\end{document}


Now for your question, according to Matlab, the solution is

The above function is undefined if the angle equals to zero or pi.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.polar}

\begin{document}

\begin{tikzpicture}
\begin{polaraxis}
{ (x + sqrt( (x - 2*sin(x) )*(x + 2*sin(x)) ))  /(2*sin(x) };
\end{polaraxis}
\end{tikzpicture}

\end{document}


The result is

• This should really be plotted in radians, not degrees, since you have theta in the same units as sin(theta). – Charles Staats Dec 13 '15 at 9:08

Here's how to do it using Asymptote, together with some code borrowed from Transform/Mapping of path in asymptote.

% file: foo.tex
% to compile: pdflatex --shell-escape foo
%
% For MikTeX users: Asymptote requires a separate program that cannot be installed
% by the package manager. You can get the installation file from
% https://sourceforge.net/projects/asymptote/files/2.35/
% (specifically, the file ending in setup.exe).
\documentclass[margin=10pt]{standalone}
\usepackage{asypictureB}

struct planeTransformation {
int nInterpolate = 4;
pair apply(real, real);
pair apply(pair uv) { return apply(uv.x, uv.y); }
transform derivative(real, real);
transform derivative(pair uv) { return derivative(uv.x, uv.y); }
transform linearization(real u, real v) {
return shift(apply(u,v)) * derivative(u,v) * shift(-(u,v));
}
transform linearization(pair uv) {
return linearization(uv.x, uv.y);
}
/* Apply to a single Bezier spline. */
guide _apply(pair p1, pair c1, pair c2, pair p2) {
return apply(p1) .. controls linearization(p1)*c1 and linearization(p2)*c2 .. apply(p2);
}
guide _apply(path g) {
assert((length(g)) == 1);
return _apply(point(g,0), postcontrol(g,0), precontrol(g,1), point(g,1));
}
path apply(path g, int nInterpolate = nInterpolate) {
guide toreturn;
for (int i = 0; i < nInterpolate*length(g); ++i) {
real currentpos = i / nInterpolate;
real nextpos = (i+1) / nInterpolate;
toreturn = toreturn & _apply(subpath(g, currentpos, nextpos));
}
if (cyclic(g)) toreturn = toreturn & cycle;
}
}

planeTransformation polar;

polar.apply = new pair(real theta, real r) {
return r * expi(theta);
};

polar.derivative = new transform(real theta, real r) {
transform t = (0, 0, -r*sin(theta), cos(theta), r*cos(theta), sin(theta));
return t;
};

\begin{document}
\begin{asypicture}{name=ImplicitPolarGraph}
settings.outformat = "pdf";
import contour;
size(10cm);

real F(real theta, real r) {
return r^2*sin(theta) + sin(theta) - r*theta;
}

real rmax = 2;

path[] xygraphcomponents = contour(F, (-6 pi, -rmax), (6 pi, rmax), new real[] {0}, nx=600, ny=100)[0];

// Draw polar "axes"
for (real r = 1/2; r < rmax; r += 1/2) {
draw(circle(r=r, c=(0,0)), gray + linewidth(0.4),
L=Label("$"+(string)r+"$", black, position=BeginPoint, align=N, filltype=UnFill));
}
draw(circle(r=2, c=(0,0)), black);

for (int degrees = 0; degrees < 360; degrees += 30) {
draw((0,0) -- scale(rmax)*dir(degrees), p=gray + linewidth(0.4), L=Label("$"+(string)degrees+"^{\circ}$", black, position=EndPoint, align=dir(degrees)));
}

for (path xycomponent : xygraphcomponents) {
path rthetacomponent = polar.apply(xycomponent);
draw(rthetacomponent, blue);
}

\end{asypicture}
\end{document}


Here is the graph of the function, having simplified the expressions of the roots to

where sinc is the cardinal sine. It is defined for sinc θ <= 1/2, θ different from kπ. It happens that pst-math defines a SINC function, which simplifies the code:

\documentclass[11pt, a2paper, pdf, svgnames]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{ pst-plot, pst-math}
\usepackage{auto-pst-pdf}
\let\TwoPi\psPiTwo
\let\Pi\psPi

\def\Fone{(1 + sqrt(1-(2*SINC(x))^2))/(2*SINC(x))}
\def\Ftwo{(1 - sqrt(1-(2*SINC(x))^2))/(2*SINC(x))}

\begin{document}

\psset{arrowinset=0.15, ticksize=2.5pt -2.5pt, labelFontSize=\footnotesize, tickwidth =0.6pt}
\begin{pspicture*}(-11,-10)(11,9)
\psaxes[arrows=->, linecolor=LightSteelBlue, tickcolor=LightSteelBlue, Dx=2,ytrigLabels ,dy = \psPi] (0,0)(-11,-9)(11,9)[$x$,-110][$y$,-140]
\psset{linewidth=1.2pt, plotpoints=200, plotstyle=curve, polarplot, algebraic, labelsep=0.5em}
%First series
\psset{linecolor=IndianRed}
\psplot[arrows=*-]{1.896}{3.14159}{\Fone}%
\psplot{6.28}{9.42}{\Fone}
\psplot{12.57}{15.71}{\Fone}%
\psplot[arrows=*-]{-1.896}{-3.14}{\Fone}%
\psplot{-6.28}{-9.42}{\Fone}%
\psplot{-12.57}{-15.71}{\Fone}
\psset{linecolor=Coral}
\psplot{3.15160}{6.28}{\Ftwo}%
\psplot{9.42}{12.57}{\Ftwo}%
\psplot{-3.15}{-6.28}{\Ftwo}%
\psplot{-9.42}{-12.57}{\Ftwo}%
\psline[linecolor=LightSteelBlue](-11, \TwoPi)(11,\TwoPi)
\psline[linecolor=LightSteelBlue](-11, \Pi)(11,\Pi)
\psline[linecolor=LightSteelBlue](-11, -\Pi)(11,-\Pi)%
\psline[linecolor=LightSteelBlue](-11, -\TwoPi)(11,-\TwoPi)

%Second series
\psset{linecolor =OliveDrab }
\psplot{1.896}{3.14160}{\Ftwo}
\psplot{-1.896}{-3.14160}{\Ftwo}
\psplot{6.28}{9.42}{\Ftwo}%
\psplot{-6.28}{-9.42}{\Ftwo}%
\psset{linecolor =DarkSeaGreen}
\psplot{3.14160}{6.28}{\Fone}%
\psplot{9.42}{12.57}{\Fone}%
\psplot{-3.15}{-6.28}{\Fone}%
\psplot{-9.42}{-12.57}{\Fone}%%%
\end{pspicture*}

\end{document}