0

I am attempting to draw the function 1/((x+1)^{3/2})) on the interval -1,0. I want to include the vertical asymptote at x=-1 as well as shade the region between the two intervals. However, I keep getting errors with my current code:

\documentclass{article}

\usepackage{mathtools} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsfonts}

\usepackage{tikz} \usepackage{scalerel} \usepackage{pict2e} \usepackage{tkz-euclide} \usetikzlibrary{calc} \usetikzlibrary{patterns,arrows.meta} \usetikzlibrary{shadows} \usetikzlibrary{external}

\usepackage{pgfplots} \pgfplotsset{compat=newest} \usepgfplotslibrary{statistics} \usepgfplotslibrary{fillbetween}

\usepackage{xcolor}

\usepackage{nicefrac}

\begin{document}

\pgfplotsset{ standard/.style={ axis line style = thick, trig format=rad, enlargelimits, axis x line=middle, axis y line=middle, enlarge x limits=0.15, enlarge y limits=0.15, every axis x label/.style={at={(current axis.right of origin)},anchor=north west}, every axis y label/.style={at={(current axis.above origin)},anchor=south east} } }

\begin{tikzpicture} \begin{axis}[standard, xtick={-1,0}, ytick=\empty, samples=1000, xlabel={$x$}, ylabel={$y$}, xmin=-1,xmax=0, ymin=-0.05,ymax=0.55]

\node[anchor=center,label=south west:$O$] at (axis cs:0,0){};

\addplot[domain={-1:0}]{1/((x+1)^{3/2})};

\end{axis} \end{tikzpicture}

\end{document}

EDIT: I have managed to add the asymptote by using a newly defined command called vasymptote. My graph currently looks like this: enter image description here

This plot is without the line \addplot[domain={-1:0}]{1/((x+1)^{3/2})};

The code for the above image is the same excpet it has the new command:

\newcommand{\vasymptote}[2][]{
    \draw [densely dashed,#1] ({rel axis cs:0,0} -| {axis cs:#2,0}) -- ({rel axis cs:0,1} -| {axis cs:#2,0});
}

Bumblebee
  • 255

1 Answers1

1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
axis line style=thick,
xmin=-1, xmax=0,
ymin=0, ymax=10,
enlarge x limits=0.15, enlarge y limits=0.15,
xtick={-1,0}, ytick=\empty,
xlabel={$x$}, ylabel={$y$},
every axis x label/.style={at={(current axis.right of origin)}, anchor=north west},
every axis y label/.style={at={(current axis.above origin)}, anchor=south east},
axis on top,
]
\node[anchor=center, label=south west:$O$] at (axis cs:0,0){};
\addplot[domain=-1:0, fill=pink, y filter/.expression={x==-1?10:y}, samples=50, smooth]{1/((x+1)^(3/2))} \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}

Graph with curve and fill under