1

This is my first post here so I'm learning how to use the different features of the website. Sorry if there's any awkwardness...

I would like to fill an area between the x axis, a curve and a hyperbola. I've already found some answers in other posts here but I'm struggling to find a solution that would match what I would like to do.

Here is what I would like to fill, or just one of the two parts on either side of the x axis (made with Paint):

enter image description here

Here is my preamble:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[top=60pt, bottom=60pt, left=60pt, right=60pt]{geometry}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{mathrsfs}
\usepackage{fancyhdr}
\usepackage{adjustbox}
\usepackage{mathtools}
\usepackage{titlesec}
\usepackage{relsize}
\usepackage{setspace}
\usepackage{mathrsfs}
\usepackage{sectsty}
\usepackage{xcolor}
\usepackage{array}
\usepackage{comment}
\sectionfont{\centering}

\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.16}
\usetikzlibrary{patterns}

\DeclareMathOperator{\sh}{sh}
\DeclareMathOperator{\ch}{ch}
\let\th\relax
\DeclareMathOperator{\th}{th}

\definecolor{magenta}{RGB}{240, 25, 255}
\def\radius{4}
\def\zoom{1.8}
\def\point{1.3}

\centering
\onehalfspacing

Here is my current code:

\begin{tikzpicture}
    % Axes
    \coordinate (O) (0,0);
    \draw [->, name path=X] ({-\radius},0)--(\radius,0) coordinate (x) node[xshift=10]{$x$};
    \draw [->, name path=Y] (0,{-\radius})--(0,\radius) coordinate (y) node[yshift=10]{$y$};
    \draw (O) circle (\zoom*1); % Cercle unité
    % Hyperboles (équation)
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=right] plot ({\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=left] plot ({-\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    % Droites
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {\x});
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {-\x});
    \draw [thick, name path=A] (O)--({\zoom*cosh(\point)},{\zoom*sinh(\point)}) coordinate (M);
    \draw [thick, name path=B] (O)--({\zoom*cosh(\point)},{-\zoom*sinh(\point)}) coordinate (M');
    % ch
    \draw [line width=1, blue] (O)--({\zoom*cosh(\point)},0);
    \draw [thick, blue, densely dashed] (M)--({\zoom*cosh(\point)},0) coordinate (ch) node[yshift=-10]{$\ch{a}$};;
    \fill [blue] (ch) circle (0.055);
    % sh
    \draw [line width=1, red] (0,{\zoom/tanh(\point)})--(0,{\zoom*sinh(\point)});
    \draw [thick, red, densely dashed] (M)--(0,{\zoom*sinh(\point)}) coordinate (sh) node[xshift=-15]{$\sh{a}$};
    \fill [red] (sh) circle (0.055);
    % th
    \draw [name path=T] (\zoom,-3)--(\zoom,3);
    \draw [line width=1, magenta] (\zoom,0)--(\zoom,{\zoom*tanh(\point)}) coordinate (th) node[xshift=-15, yshift=10]{$\th{a}$};
    \fill [magenta] (th) circle (0.055);
    % coth
    \draw [domain=-2:4, variable=\x] plot (\x, {(-1/sinh(\point)*\x+\zoom/tanh(\point))});
    \draw [line width=1, orange] (O)--(0,{\zoom/tanh(\point)}) coordinate (coth) node[xshift=-20]{$\coth{a}$};
    \fill [orange] (coth) circle (0.055);
    % Aire
    \tikzfillbetween [of=A and B] {gray, opacity=.4};
\end{tikzpicture}

And the result, what I managed to do:

enter image description here

2

Welcome! Something like this?

\documentclass[tikz,border=3mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\sh}{sh}
\DeclareMathOperator{\ch}{ch}
\let\th\relax % <- bad practice
\DeclareMathOperator{\th}{th}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
    \def\radius{4} % <- bad practice to add these outside tikzpicture
    \def\zoom{1.8}
    \def\point{1.3}
    % Axes
    \coordinate (O) at (0,0);
    \draw [->, name path=X] ({-\radius},0)--(\radius,0) coordinate (x) node[xshift=10]{$x$};
    \draw [->, name path=Y] (0,{-\radius})--(0,\radius) coordinate (y) node[yshift=10]{$y$};
    \draw (O) circle (\zoom*1); % Cercle unité
    % Hyperboles (équation)
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=right] plot ({\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    \draw [line width=1, domain=-1.4:1.4, smooth, variable=\x, name path=left] plot ({-\zoom*cosh(\x)}, {\zoom*sinh(\x)});
    % Droites
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {\x});
    \draw [domain=-3.5:3.5, variable=\x] plot (\x, {-\x});
    \draw [thick, name path=A] ({\zoom*cosh(\point)},{-\zoom*sinh(\point)})
        coordinate (M') --(O)--({\zoom*cosh(\point)},{\zoom*sinh(\point)}) coordinate (M);
    % ch
    \draw [line width=1, blue] (O)--({\zoom*cosh(\point)},0);
    \draw [thick, blue, densely dashed] (M)--({\zoom*cosh(\point)},0) coordinate (ch) node[yshift=-10]{$\ch{a}$};;
    \fill [blue] (ch) circle (0.055);
    % sh
    \draw [line width=1, red] (0,{\zoom/tanh(\point)})--(0,{\zoom*sinh(\point)});
    \draw [thick, red, densely dashed] (M)--(0,{\zoom*sinh(\point)}) coordinate (sh) node[xshift=-15]{$\sh{a}$};
    \fill [red] (sh) circle (0.055);
    % th
    \draw [name path=T] (\zoom,-3)--(\zoom,3);
    \draw [line width=1, magenta] (\zoom,0)--(\zoom,{\zoom*tanh(\point)}) coordinate (th) node[xshift=-15, yshift=10]{$\th{a}$};
    \fill [magenta] (th) circle (0.055);
    % coth
    \draw [domain=-2:4, variable=\x] plot (\x, {(-1/sinh(\point)*\x+\zoom/tanh(\point))});
    \draw [line width=1, orange] (O)--(0,{\zoom/tanh(\point)}) coordinate (coth) node[xshift=-20]{$\coth{a}$};
    \fill [orange] (coth) circle (0.055);
    % Aire
    \tikzfillbetween [of=A and right] {gray, opacity=.4};
\end{tikzpicture}
\end{document}

enter image description here

I just combined the two lines to one path. Please also note that I reduced your preamble to a more minimal version. When exchanging codes it is important to avoid carrying with us stuff that is not needed. Also I think that

\let\th\relax
\DeclareMathOperator{\th}{th}

is bad practice. Can't you just give the math operator a different macro?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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