0

I just read this about how to make asymptotes, but could someone teach me the same method if I want to draw for \dfrac{x^2+0.5x+1.5}{x+3} with their asymptotes? Also teach me about the concept of this.

2
  • This site is not for teaching but for well defined questions. If you have problems creating the asymptotes, then you should show compilable code for the plot itself. -this makes it a lot easier to help and to understand, what you want. Commented Sep 15, 2020 at 10:26
  • 1
    The thing is: As far as I know, there is no LaTeX method that performs the polynomial division for any rational functions or calculates the asymptote functions. You have to do this yourself or use a CAS. As soon as you know the asymptote function, you can simply draw it with pgfplots.
    – cis
    Commented Sep 15, 2020 at 10:41

2 Answers 2

2
  1. Get the functions of asymptotes: open https://www.wolframalpha.com/, type in asymptotes (x^2 + 0.5 * x + 1.5)/(x + 3) followed by Enter. The computation results will tell you the two asymptotes are y = x - 2.5 and y = -3.
  2. Draw the image of (x^2 + 0.5 * x + 1.5)/(x + 3), as well as its two asymptotes:
% based on the example given in https://tex.stackexchange.com/a/291629
\documentclass[tikz,border=5pt]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    axis lines = center,
    xlabel = $x$,
    ylabel = $y$,
    xmax = 5,
    xmin = -15,
    ymax = 5,
    ymin = -15,
    domain=-15:5
  ]
    % Image of function y = (x^2 + 0.5 * x + 1.5)/(x + 3)
    \addplot[
      restrict y to domain = -15:10,
      samples = 100,
    ] {(x^2 + 0.5 * x + 1.5)/(x + 3)};
    
    % Oblique asymptote at y = x - 2.5
    \addplot[dashed] {x - 2.5};
    % Vertical asymptote at x = -3
    \addplot[dashed] (-3, x);
  \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

In general,

  • to draw an oblique asymptote at y = f(x), use \addplot[dashed] {f(x)} or (x, f(x)), and
  • to draw a vertical asymptote at x = c (c is a constant), use \addplot[dashed] (c, x).
7
  • Hello, thanks for answering my question. I have a question, may I know how you add the grid by adding the code on your MWE, please? Thanks, then.
    – Wilory Lu
    Commented Sep 15, 2020 at 12:56
  • @WiloryLu When you say "grid", do yo mean the grid documented in manual of pgfplots v1.17, sec. 3.3.3 Add a Legend and a Grid? If so, try adding grid=major to the option list of axis environment. Commented Sep 15, 2020 at 13:28
  • Oh, I don't have the module on that version, but yes that's what I mean, thanks P.S. In my version it is called grid path construction
    – Wilory Lu
    Commented Sep 15, 2020 at 13:44
  • Oh yeah, another question, do I have to do the same way if I have another equation of asymptotic graph? And, what does sample = 100 mean?
    – Wilory Lu
    Commented Sep 15, 2020 at 13:47
  • And, then how can I change the ticks?
    – Wilory Lu
    Commented Sep 15, 2020 at 13:57
1

enter image description here

\documentclass[tikz,border=5pt]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}[font=\footnotesize]
\begin{axis}[
axis lines = center,
xlabel=$x$,
ylabel=$y$,
axis line style = {-latex},
xlabel style={anchor=north},
ylabel style={anchor=east},
%xmin=-10,      xmax=7,
ymin=-25,     ymax=25,
ytick={-25,-20,...,25},
restrict y to domain = -30:30,
domain=-10:10, 
enlarge x limits={abs=1.5},
enlarge y limits={abs=3.5},
%clip=false, 
]
\addplot[samples=111,  black,]{(x^2 + 0.5*x + 1.5)/(x + 3)} 
       node[above, xshift=-12mm]{$f(x)=\dfrac{x^2+0.5x+1.5}{x+3}$};
\addplot[dashed] {0.5*x-1}
      node[below=1mm, pos=0.1]{$a(x)=x-2.5$};
\addplot[dashdotted, domain=-25:29] ({-3},{x})
      node[left, pos=0.9]{$x_p=-3$};;
\end{axis}
\end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .