Representación gráfica de una función en un marco de referencia ortonormal bien elegido.

Representación gráfica de una función en un marco de referencia ortonormal bien elegido.

Quiero crear esta imagen exacta en látex pero no logro encontrar el código para hacerlo... Este es mi intento:

ingrese la descripción de la imagen aquí

\begin{tikzpicture}
\begin{axis}\[
    axis lines=middle,
    axis line style={-Latex, thick},
    xlabel={$x$},
    ylabel={$y$},
    xlabel style={at={(ticklabel* cs:1)},anchor=north west},
    ylabel style={at={(ticklabel* cs:1)},anchor=south west},
    xmin=-4, xmax=4,
    ymin=-4, ymax=4,
    xtick={-3,-2,...,3},
    ytick={-3,-2,...,3},
    grid=both,
    grid style={line width=.1pt, draw=gray!10},
    major grid style={line width=.2pt,draw=gray!50},
    minor tick num=1, % number of minor ticks between major ticks
    ticklabel style={font=\small,fill=white},
    legend style={draw=none, at={(0.5,-0.1)},anchor=north},
    legend cell align={left}
\]

\addplot \[
    domain=-3:3, 
    samples=100, 
    color=red,
    thick
\]
{1/x};
\addlegendentry{$y = \frac{1}{x}$}

% Add points
\node\[label={180:{(1,1)}},circle,fill,inner sep=2pt\] at (axis cs:1,1) {};
\node\[label={180:{(2,0.5)}},circle,fill,inner sep=2pt\] at (axis cs:2,0.5) {};
\node\[label={180:{(3,0.333)}},circle,fill,inner sep=2pt\] at (axis cs:3,0.333) {};

\end{axis}
\end{tikzpicture}]

Respuesta1

Como esto:

ingrese la descripción de la imagen aquí

Código ( tikz):

\documentclass[a4paper]{article}
\usepackage{tikz}

\begin{document}
    
    \begin{center}
        \begin{tikzpicture}[font=\sffamily\small]
            %
            \draw[gray!20,step=0.2] (-4,-4) grid (4,4);
            \draw[gray!40] (-4,-4) grid (4,4);
            %
            \draw[->,thick] (-4,0) -- (4.5,0) node[anchor=west]{$x$};
            \draw[->,thick] (0,-4) -- (0,4.5) node[anchor=south]{$y$};
            %
            \foreach \x in {-4,...,-1,1,2,3,4} \draw [thick](\x cm,-2pt) -- (\x cm,2pt) node[below] {\x};
            \foreach \y in {-4,...,-1,1,2,3,4} \draw [thick](-2pt,\y) -- (2pt,\y) node[left]{\y};
            \node at (-.2,-.2) () {$O$};
            %
            \clip (-4,-4) rectangle (4,4);
            \draw[red,line width=2pt,step=.01] plot[domain=-4:-.1,smooth,samples=50] (\x,{1/\x});
            \draw[red,line width=2pt,step=.01] plot[domain=.1:4,smooth,samples=50] (\x,{1/\x});
            \fill (1,1) circle(2pt) node[above right] () {\bfseries $y=1$};
            \fill (2,.5) circle(2pt) node[above right] () {\bfseries $y=\frac12$};
            \fill (3,.33) circle(2pt) node[above right] () {\bfseries $y=\frac13$};
        \end{tikzpicture}
    \end{center}
\end{document}

Note: Dividí el dominio en dos partes para saltar la singularidad en x=0.

información relacionada