如果有人能帮助我绘制该函数图我将非常感激\frac{1}{\sqrt{1-x^2}}
。
答案1
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\f(#1){1/sqrt(1-(#1)^2)}
\draw[->] (-2,0)--(2,0) node[below]{$x$};
\draw[->] (0,-.5)--(0,3) node[left]{$y$};
\draw[dashed] (-1,-.5)--(-1,3) (1,-.5)--(1,3);
\draw[blue,smooth] plot[domain=-.93:.93,samples=200] (\x,{\f(\x)});
\path
(1,0) node[below right]{1}
(-1,0) node[below left]{-1}
(0,1) node[below right]{1};
\end{tikzpicture}
\end{document}
答案2
这是使用该pgfplots
包的另一种方法。
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
unit vector ratio = {1 1},
grid = none,
tick style = {black},
% x axis
xmin = -2, xmax = 3,
axis x line = middle,
x axis line style = -{Stealth},
xlabel = $x$,
xlabel style = {below},
xtick = {-1, ..., 2},
xticklabels = {},
extra x ticks = {1},
% y axis
ymin = -2, ymax = 6,
axis y line = middle,
y axis line style = -{Stealth},
ylabel = $y$,
ylabel style = {left},
ytick = {-1, ..., 5},
yticklabels = {},
extra y ticks = {1}
]
\addplot[domain = -0.99 : 0.99, samples = 1000] {1 / sqrt(1 - x^2)};
\end{axis}
\end{tikzpicture}
\end{document}
由于选择的样本数量较多,因此需要一些时间进行编译。