5

I am not able to get the correct graph of (sqrt(1+x)-sqrt(1-x))/x by using the following

\begin{tikzpicture}[scale=1,>=stealth]
\tkzInit[xmin=-1.5,xmax=1.5,ymin=0,ymax=2,xstep=0.5,ystep=0.5]
\tkzAxeXY[color=black!80]
\draw[scale=1,domain=-1:1,smooth,thick,variable=\x,red,->] plot ({\x},{((sqrt(1+\x)) - (sqrt(1-\x)))/(\x)});
\end{tikzpicture}

Please help me with this

9

You only need to avoid the apparent singularity at 0, which can be achieved by setting the samples to an even number (for the symmetric domain at hand).

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=1,>=stealth] 
\tkzInit[xmin=-1.5,xmax=1.5,ymin=0,ymax=2,xstep=0.5,ystep=0.5]
\tkzAxeXY[color=black!80]
\draw[scale=1,domain=-1:1,smooth,thick,variable=\x,red,->,samples=100] 
plot ({\x},{((sqrt(1+\x)) - (sqrt(1-\x)))/(\x)}); 
\end{tikzpicture}
\end{document}

enter image description here

The result can be improved (IMHO) by bending the arrow and using pgfplots.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{arrows.meta,bending}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-1.5,xmax=1.5,ymin=0,ymax=2,axis lines=middle]
 \addplot [domain=-1:1,smooth,thick,red,-{Stealth[bend]},samples=100] 
  {((sqrt(1+\x)) - (sqrt(1-\x)))/(\x)}; 
\end{axis} 
\end{tikzpicture}
\end{document}

enter image description here

1

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.