How can I plot a curve with a vertical and oblique asymptote, same as the following picture?

Curve equation: y=\sqrt[3]{\frac{x^7+3x^6-2x^5-x^4-3x^2+1}{x^4-2x^2}}

enter image description here

  • 1
    Welcome to TeX-SE! You can achieve this e.g. with pgfplots. What have you tried? – marmot Mar 15 at 2:57
  • I was looking in the pgfplots gallery for some example that looked like what you're asking, but I didn't find anything like that, however you can check for yourself if you want. Nevertheless I don't understand your question, you can graph those kind of equations in the software you prefer and place the image in your LaTeX document. – Aradnix Mar 15 at 3:01
  • you're right. But I dont know which software can do exactly the same thing that I showed by the picture. – Maryam Amini Mar 15 at 3:14
  • @MaryamAmini You drew the figure with a software, didn't you? Then you can include this figure to your document, or use the software to export your figure to a TikZ or Asymptote code. – The old JouleV Mar 15 at 3:52

It is true that you can draw the figure with other software and this has certainly some advantages. But you can also draw it with LaTeX, and then you do not have to worry to add equations to it. Here is an extended discussion of this topic.

\begin{tikzpicture}[declare function={%
   title={$\displaystyle f(x)=\sqrt[3]{\frac{x^7+3x^6-2x^5-x^4-3x^2+1}{x^4-2x^2}}$}]
    \addplot[color=blue,semithick,domain={sqrt(2.035)}:5,samples=71] {f(x)}
    \addplot[color=blue,semithick,domain=0.55:1.11,samples=71] {f(x)};
    \addplot[color=green!70!black,domain=0:5,samples=2] {x}
    \addplot[color=green!70!black,domain=-0.5:6,samples=2] ({sqrt(2)},{x})
    \addplot[color=red!70!black,domain=0:5,samples=2] {1.075};

enter image description here

  • thank you for your great help – Maryam Amini Mar 17 at 13:40
  • @MaryamAmini If the answer works for you, could you please consider accepting it? – marmot Mar 17 at 14:30

A solution with pstricks:

\documentclass[11pt,svgnames, border=5pt]{standalone}

\usepackage{pst-plot, multido}
\def\f{((x^7 + 3*x^6-2*x^5-x^4-3*x^2 + 1)/(x^4-2*x^2))^(1/3)}
\def\g{-((x^7 + 3*x^6-2*x^5-x^4-3*x^2 + 1)/(2*x^2- x^4))^(1/3)}


\psset{plotstyle=curve, algebraic, arrowinset=0.15, dx=2,Dx = 2}%
\psset{subgriddiv=2,gridcolor=LightSteelBlue, subgridcolor=LightSteelBlue!40, yunit=1.25}
\begin{pspicture}(-0.5,-0.8)(8.5, 6.5)
\psgrid[xunit=2, yunit=2, gridlabels=0pt, subgriddiv = 4]
\psaxes[labels=none, arrows=->, arrowscale=1.3, xsubticks=4, ysubticks=2, subtickcolor=black](0,0)(7.5,5.8)[$x$,-130] [$y$,-40]%
 \psplot[plotpoints=10, linewidth=1.2pt, linecolor=DodgerBlue]{0.549631}{1.103438}{\f}
 \psplot[plotpoints=10, linewidth=1.2pt, linecolor=DodgerBlue]{0.41}{0.54963}{\g}
 \psplot[plotpoints=10, linewidth=1.2pt, linecolor=DodgerBlue]{1.103439}{1.414}{\g}
\psplot[plotpoints=200, linewidth=1.2pt, linecolor=DodgerBlue]{1.418}{8}{\f}
\multido{\n = -0.5 + 0.5}{16}{\psline[linewidth=0.3pt](\n, -0.8)(\n, -0.65)\psline[linewidth=0.3pt](\n, 6.5)(\n, 6.35)%
 \psline[linewidth=0.3pt](-0.5, \n)(-0.35,\n) \psline[linewidth=0.3pt](8.5, \n)(8.35,\n)}
\multido{\i = 0 + 2}{5}{\uput{10pt}[d](\i, 0){\i}\psline(\i, -0.8)(\i, -0.6)%
\uput{11pt}[d](\i, 6.5){\i}\psline(\i, 6.5)(\i,6.3)}


enter image description here

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.