# Plot y=x^(-0.5)

How can I plot y=x^(-0.5)?

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\draw[->] (0,0) -- (6.2,0) node[right] {$Q$};
\draw[->] (0,0) -- (0,6.2) node[above] {$P$};
\draw[thick,purple,smooth] plot (\x,{(2)^(0.5)*(\x)^(-0.5)});
\draw[thick,brown,smooth] plot (\x,{(0.5)^(0.5)*(\x)^(-0.5)});

\end{tikzpicture}
\end{document}

• Plotting 1/sqrt x perhaps? – user31729 Feb 27 '15 at 11:10

This is a pgfplots solution, but it works with normal plot as well.

\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmax=3]
\draw[->] (0,0) -- (6.2,0) node[right] {$Q$};
\draw[->] (0,0) -- (0,6.2) node[above] {$P$};
%          \draw[thick,purple,smooth] plot (\x,{(2)^(0.5)*(\x)^-0.5});
%          \draw[thick,brown,smooth] plot (\x,{(0.5)^(0.5)*(\x)^-0.5});
\end{axis}
\end{tikzpicture}
\end{document}


• @LaRiFaRi: Why? – user31729 Feb 27 '15 at 11:20

You must add a valid domain because by default is (-5,5) and x^0.5 is not defined for negative values.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\draw[->] (0,0) -- (6.2,0) node[right] {$Q$};
\draw[->] (0,0) -- (0,6.2) node[above] {$P$};
\draw[thick,purple,smooth] plot [domain=0:5] (\x,{(2)^(0.5)*(\x)^(-0.5)});
\draw[thick,brown,smooth] plot [domain=0:5] (\x,{(0.5)^(0.5)*(\x)^(-0.5)});

\end{tikzpicture}
\end{document}


You could make your formula a bit easier and I would recommend for this:

% arara: pdflatex

\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}
\begin{axis}[%
,xlabel=$Q$
,ylabel=$P$
,xmin=0,xmax=6.2
,ymin=0,ymax=6.2
,axis x line=bottom
,axis y line=left
,every axis x label/.style={at={(current axis.right of origin)},anchor=west}
,every axis y label/.style={at={(current axis.north west)},anchor=south}
]
,samples at={0.05,0.1,...,6}
,smooth
,thick
,purple
] {sqrt(2/x)};