[Tex/LaTex] Shaded region between the area and a circle

tikz-pgf

How can I draw a square whose side is 6 inscribed in a circle and make the program display the shaded region between the square and the circle

Best Answer

Here's a simple option; the value for \side controls half the side of the square:

\documentclass{article}
\usepackage{tikz}

\def\side{3}

\begin{document}

\begin{tikzpicture}
\draw[fill=yellow!40] (0,0) circle (\side*1.4142);
\draw[fill=white] (-\side,-\side) rectangle (\side,\side);
\end{tikzpicture}

\end{document}

enter image description here

Another option using the intersections library; this time the value for \radius controls the radius of the circle:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\def\radius{2}

\begin{document}

\begin{tikzpicture}
\draw[name path=circle,fill=yellow!40] (0,0) circle (\radius);
\path[name path=line1] (-\radius,-\radius) -- (\radius,\radius);
\path[name path=line2] (-\radius,\radius) -- (\radius,-\radius);
\filldraw[draw=black,fill=white,
  name intersections={of=circle and line1,by={a,b}},
  name intersections={of=circle and line2,by={c,d}}] 
  (a) -- (c) -- (b) -- (d) -- cycle;
\end{tikzpicture}

\end{document}

enter image description here