21

How to fill region on Folium of Descartes like this:

enter image description here

Here is my codes:

\documentclass[10pt]{article}
\usepackage{pstricks-add}
\usepackage{pst-func}
\pagestyle{empty}

\begin{document}

\begin{figure}[!ht]
\centering
\psset{algebraic=true,dimen=middle,dotstyle=o,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25,unit=4}
\begin{pspicture*}(-.5,-.5)(2,2)
\psaxes[linecolor=gray,xAxis=true,yAxis=true,labels=none,ticks=none]{->}(0,0)(-.5,-.5)(2,2)
\psplotImp[linecolor=blue,linewidth=1.5pt,plotpoints=500](0,0)(2,2){y^3-3*x*y+x^3}

\end{pspicture*}
\caption{Folium Descartes}
\end{figure}

\end{document}
  • You can make the code a little shorter: algebraic=true --> algebraic and dimen=middle --> dimen=m. Also, blank lines in pspicture environments are not a good idea. – Svend Tveskæg Jan 25 '15 at 16:52
  • It seems that the easy way around this problem is to use a parametric plot: tex.stackexchange.com/questions/8017/… – Franck Pastor Jan 25 '15 at 19:12
20

You can fill if you use \parametricplot:

\documentclass[10pt,x11names]{article}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\pagestyle{empty}

\begin{document}

\begin{figure}[!ht]
\centering
\psset{algebraic=true,dimen=middle,dotstyle=o,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25,unit=3,plotpoints=2000}
\begin{pspicture*}(-2,-2)(2,2)
 \psset{linecolor=SteelBlue4, linewidth=1.2pt}
 \pscustom[fillstyle=solid, fillcolor=lightgray!25!LightSteelBlue2!10!]{
 \parametricplot{-0.99}{0}{3*t/(1 + t^3) | 3*t^2/(1 + t^3)}
 \parametricplot{-600}{-1.01}{3*t/(1 + t^3) | 3*t^2/(1 + t^3)}
 }
\pscustom[fillstyle=solid, fillcolor=LightSteelBlue2!25! ]{
 \parametricplot{0}{200}{3*t/(1 + t^3) | 3*t^2/(1 + t^3)}
 }
 \psline[linewidth=0.4pt, linecolor=black](-2.5; 45)(2.5 ; 45)
 \psline[linewidth=0.4pt, linecolor=black](-2,1)(2,-3)
\psaxes[linecolor=gray,xAxis=true,yAxis=true,labels=none,ticks=none]{->}(0,0)(-2,-2)(2,2)
\end{pspicture*}
\caption{Folium of Descartes}
\end{figure}

\end{document} 

enter image description here

  • \parametricplot{0}{200}{3*t/(1 + t^3) | 3*t^2/(1 + t^3)} for the second \pscustom is enough and the \closepath is not needed – Herbert Oct 25 '17 at 8:09
  • @Herebert: That's right. I even can't remember why I plit it in two. Perhaps a remnant of some preliminary testing. Thanks! – Bernard Oct 25 '17 at 10:09
15

Done with mfpic, a LaTeX interface to MetaPost. To draw the folium you can use the cartesian form directly, thanks to the handy \levelcurve command of this package, so long as you write it as an inequation and you provide a point that verifies this inequation (here (1, 1)). The resulting curve is filled with the \gfill command with the desired color as an option.

\documentclass{standalone}
\usepackage[metapost]{mfpic}
  \setlength{\mfpicunit}{1cm}
  \opengraphsfile{\jobname}
\begin{document}
\begin{mfpic}[2]{-0.5}{2}{-0.5}{2}
  \draw\gfill[blue+green]\levelcurve{(1, 1), 0.01}{y**3 - 3x*y + x**3 < 0}
  \doaxes{xy}
\end{mfpic}
\closegraphsfile
\end{document}

To be compiled first with (PDF)LaTeX, then with MetaPost, and finally with (PDF)LaTeX. The result is as follows:

enter image description here

14

The folium of Descartes in parametric form with Asymptote (pun intended):

enter image description here

// file fod.asy
// 
// to get fod.pdf, run `asy -f pdf fod.asy` 
//
size(8cm);
import graph;
import fontsize;
defaultpen(fontsize(9pt));

texpreamble("\usepackage{lmodern}");

pen curvepen=darkblue+0.8bp;
pen linepen=darkred+0.8bp;
pen fillpen=orange+opacity(0.5);

real 
xmin=-20, xmax=-xmin, 
ymin=-20, ymax=-ymin; 

xaxis(xmin,xmax,RightTicks(Step=10,step=5,OmitTick(0)));
yaxis(ymin,ymax, LeftTicks(Step=10,step=5,OmitTick(0)));

real a=10;

real r(real t){return 3*a*sin(t)*cos(t)/(sin(t)^3+cos(t)^3);}; 

real tmin=-0.16pi, tmax=pi/2-tmin;

guide 
loop=polargraph(r,0,pi/2)--cycle,
curve=polargraph(r,tmin,tmax);

fill(loop, fillpen);
draw(curve,curvepen);

pair 
p=point(curve,0),
q=point(curve,length(curve));

draw((p.x,-p.x-a)--(-q.y-a,q.y),linepen);

A little more advanced example:

enter image description here

// file fodsp.asy
// 
// to get fodsp.pdf, run `asy -f pdf fodsp.asy` 
//
size(8cm);
import graph;
import fontsize; defaultpen(fontsize(9pt));
texpreamble("\usepackage{lmodern}");

pen[] fillpen={
  red, orange, yellow, green, lightblue, blue, darkblue
};

real 
xmin=0, xmax=20, 
ymin=0, ymax=20; 

xaxis(xmin,xmax,RightTicks(Step=10,step=5));
yaxis(ymin,ymax, LeftTicks(Step=10,step=5));

real ra(real t, real a){return 3*a*sin(t)*cos(t)/(sin(t)^3+cos(t)^3);}; 
real r(real);
guide loop;

real a, a0=10, da=1;
int n=fillpen.length;

real t; pair p;
a=a0;
for(int i=0;i<n;++i){  
  r=new real(real t){return ra(t,a);};
  loop =polargraph(r,0,pi/2)--cycle;  
  filldraw(loop, 0.7fillpen[i]+0.3white,fillpen[i]);
  t=atan(2^(1/3));
  p=r(t)*(cos(t),sin(t));
  unfill(circle(p,0.7));
  label("$"+string(a)+"$",p);  
  a-=da; 
}

label("$r(\theta)=\displaystyle"
+"\frac{3 a \sin\theta\cos\theta}{\sin^3\theta+\cos^3\theta}$, "
+"$\theta=[0,\frac\pi2]$, "
+"$a="+string(a0-(n-1)*da)+"$--$"+string(a0)+"$"
,((xmin+xmax)/2,ymax),S);

shipout(bbox(paleyellow,Fill));
14

In Metapost, you could just make the folium a closed path and fill it.

enter image description here

I've used the (rather simpler) polar form of the equation below.

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(1);

u := 2cm;

path xx, yy, folium;

xx = (1/2 left -- 2 right) scaled u;
yy = (1/2 down -- 2 up)    scaled u;

drawarrow xx withcolor .4 white;
drawarrow yy withcolor .4 white;

folium = (origin 
  for theta=1 step 1  until 89:  
    -- (3*sind(theta)*cosd(theta)/(sind(theta)**3+cosd(theta)**3),0) rotated theta
  endfor 
  -- cycle) scaled u;

fill folium withcolor .9[blue,white];
draw folium withcolor .67 blue;

endfig;
end.

And here's a fuller version, with the equation moved to a function, and showing how to extend the folium and pick out the loop as a sub path of it.

enter image description here

prologues := 3;
outputtemplate := "%j%c.eps";

beginfig(2);

u := 2cm;

path xx, yy, folium, loop, asymptote;

xx = (2 left -- 2 right) scaled u;
yy = (2 down -- 2 up)    scaled u;

drawarrow xx withcolor .4 white;
drawarrow yy withcolor .4 white;

% "a" is the scale factor
a = 1;
vardef r(expr t) = right scaled (3*a*sind(t)*cosd(t)/(sind(t)**3+cosd(t)**3)) 
                         rotated t enddef;

% define the folium with some wings 
b = 30; % should be less than 45
folium = (r(-b) for theta=1-b step 1 until 89+b: -- r(theta) endfor -- r(90+b)) scaled u;

% define the loop to be the part from theta=0 to theta=90
loop = subpath(b,b+89) of folium -- cycle;

% define an appropriate segment of the asymptote
asymptote = ( xpart point 0        of folium,    -xpart point 0        of folium-a*u) 
         -- (-ypart point infinity of folium-a*u, ypart point infinity of folium    );

% now draw them
fill loop withcolor .9[blue,white];
draw folium withcolor .67 blue;
draw asymptote dashed evenly;

endfig;
end.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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