2

I am trying to recreate a graph from the 2024 AP Daily Practice Session. I need to fill in the area of R and directly below it. I have tried FillBetween Command and Soft Clip, but I am just not able to get the correct Clip. From the graph, I have the R shaded, but you can see there is extra shading above and below. Any help is much appreciated.

Nick

\documentclass[12pt,a4paper]{article}
    \usepackage{amsmath,amsfonts,amssymb}
    \usepackage{parskip}
    \usepackage{fancyhdr}
    \usepackage[margin=1in]{geometry}
    \usepackage{tabularray}
    \usepackage{enumitem}
    \usepackage{soul}
    \usepackage{multicol}
    \usepackage[many]{tcolorbox}
    \usepackage{ragged2e}
    \usepackage{tikz,pgfplots}
    \usetikzlibrary{arrows.meta}
    \usetikzlibrary{backgrounds}
    \pgfplotsset{compat=newest}
    \usetikzlibrary{calc}
    \usepgfplotslibrary{fillbetween}

    
        \pagestyle{fancy}
            \fancyhead[L]{Polar Curves on Calc BC}
            \fancyhead[R]{Name:\enspace\makebox[2in]{\hrulefill}}
            \fancyfoot[C]{BC Calculus}
            \fancyfoot[R]{\thepage}
            \fancyfoot[L]{Created By: Mr. Bennett}
                \renewcommand{\headrulewidth}{0.4pt}
                \renewcommand{\footrulewidth}{2pt}
                \newcommand*{\myprime}{^{\prime}\mkern-1.2mu}
                \newcommand*{\dprime}{^{\prime\prime}\mkern-1.2mu}
                \newcommand*{\trprime}{^{\prime\prime\prime}\mkern-1.2mu}   
        
        \addtolength{\topmargin}{-2.49998pt}
        
%For Polar      
\pgfplotsset{
    interpret as polar/.style={
            x filter/.code=\pgfmathparse{cos(rawx)*rawy},
            y filter/.code=\pgfmathparse{sin(rawx)*rawy}
        }
}

\begin{document}

    \subsection*{\hl{What Do We Need To Know?}}

        \begin{Center}
            \begin{tblr}{width=\textwidth,hlines={1pt},vlines={1pt},colspec={Q[m]Q[m]Q[m]Q[m]}}
            {Conversion \\ Formulas} &  \(x=r\cos\big(\theta\big)\)\, \(y=r\sin\big(\theta\big)\)   &   {Slope of the\\ Tangent to a Polar Curve}   & \(\dfrac{dy}{dx}=\dfrac{dy/d\theta}{dx/d\theta}\)\\
            {Area Bounded \\ by a Polar Curve}  &   \(A=\displaystyle\frac{1}{2}\int_{a}^{b}\left[f\big(\theta\big)\right]^2\, d\theta\)    &   {Distance to the \\ Origin}     & \(r=f\big(\theta\big)\) \\
            \end{tblr}
        \end{Center}    

\begin{Center}
\begin{tikzpicture}
\begin{axis}[
            axis lines=center,
            axis equal image,
            enlargelimits=true
        ]
    \addplot[name path=A,
            red, thick,
            domain=0:360,
            samples=360,
            smooth,
            interpret as polar
        ] 
        (x,{4-3*cos(x)});
    \addplot[name path=B,
            blue, thick,
            domain=0:360,
            samples=360,
            smooth,
            interpret as polar
        ] (x,{5*cos(x)});
        \addplot[fill=blue!30,opacity=0.5]fill between[of = A and B,soft clip={domain=-pi/2:pi/2}];
       \node at (.75,1){\(R\)};
\end{axis}
\end{tikzpicture}
\end{Center}

    \begin{enumerate}
        \item Let \(R\) be the region that is inside the graph of \(r=4-\cos \theta\) and also inside the graph of \(r=5\cos\theta\), as shaded in the figure above.  What is the area of \(R\)? 
            \begin{enumerate}[itemsep=.15in,label=(\Alph*)]
                \item 2.261
                \item 3.764
                \item 11.398
                \item 23.999
            \end{enumerate}
    \end{enumerate}
        \rule{\textwidth}{1pt}
\end{document}

enter image description here

1 Answer 1

4

Polar or not, for more complex shapes, I suggest that you use a regular \fill with intersection segments and sequence as follows (place on background layer if needed):

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{calc, backgrounds}
\usepgfplotslibrary{fillbetween}
        
%For Polar      
\pgfplotsset{
    interpret as polar/.style={
        x filter/.code=\pgfmathparse{cos(rawx)*rawy},
        y filter/.code=\pgfmathparse{sin(rawx)*rawy}
    }
}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
            axis lines=center,
            axis equal image,
            enlargelimits=true
        ]
    \addplot[name path=A,
            red, thick,
            domain=0:360,
            samples=360,
            smooth,
            interpret as polar
        ] 
        (x,{4-3*cos(x)});
    \addplot[name path=B,
            blue, thick,
            domain=0:360,
            samples=360,
            smooth,
            interpret as polar
        ] (x,{5*cos(x)});
    \begin{scope}[on background layer]
        \fill[blue!30, opacity=0.5, intersection segments={
                of=A and B, sequence={L1 -- R2 -- L3}
            }] -- cycle;
    \end{scope}
    \node at (.75,1) {\(R\)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here


To better understand what is meant by L1 -- R2 -- L3, you can check out the following code:

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{calc, backgrounds}
\usepgfplotslibrary{fillbetween}
        
%For Polar      
\pgfplotsset{
    interpret as polar/.style={
        x filter/.code=\pgfmathparse{cos(rawx)*rawy},
        y filter/.code=\pgfmathparse{sin(rawx)*rawy}
    }
}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
            axis lines=center,
            axis equal image,
            enlargelimits=true
        ]
    \addplot[name path=A,
            red, thick,
            domain=0:360,
            samples=100,
            smooth,
            interpret as polar
        ] 
        (x,{4-3*cos(x)});
    \addplot[name path=B,
            blue, thick,
            domain=0:360,
            samples=100,
            smooth,
            interpret as polar
        ] (x,{5*cos(x)});
    \begin{scope}[on background layer]
        \fill[blue!30, opacity=0.5, intersection segments={
                of=A and B, sequence={L1 -- R2 -- L3}
            }] -- cycle;

        \draw[->, red, thick, intersection segments={
                of=A and B, sequence={L1}
            }] node[below left] {L1};
        \draw[->, red, thick, intersection segments={
                of=A and B, sequence={L2}
            }] node[below left] {L2};
        \draw[->, red, thick, intersection segments={
                of=A and B, sequence={L3}
            }] node[below left] {L3};

        \draw[->, blue, thick, intersection segments={
                of=A and B, sequence={R1}
            }] node[below right] {R1};
        \draw[->, blue, thick, intersection segments={
                of=A and B, sequence={R2}
            }] node[below right] {R2};
        \draw[->, blue, thick, intersection segments={
                of=A and B, sequence={R3}
            }] node[below right] {R3};
    \end{scope}
    \node at (.75,1) {\(R\)};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

You can see that L1 means "first segment of the left path (which is A here)" where segments means the part between the intersections of the paths starting from the rightmost point on the x axis and going counterclockwise.

3
  • thank you. I am trying to figure out what the L1 R2 L3 represent via the link Commented May 10, 2024 at 14:02
  • L means left, so path A in this case, and R means right, so path B. The number denotes the part of the path between the intersections starting from 0deg (which is at the rightmost point of the path on the x axis) and going counterclockwise. Commented May 10, 2024 at 19:35
  • Let’s see: L1 means first segment of the left path. We start at 0deg of path A and go counterclockwise to the first intersection with B. Now R2, we start at 0deg of path B, go counterclockwise to the next intersection (this would be R1) and then to the next. This way we got the second segment of the right path. Then L3, we continue from the endpoint of L1 and move counterclockwise to the next intersection (this would be L2). From there starts L3 to the end of the path (at 0deg). Commented May 10, 2024 at 19:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.