I'm trying to graph a rational function in tikz

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I'm attempting to graph the function y=[(x-2)(x+2)]/[(x-3)(x+3)]. However, I get bizarre output, which consists of straight lines. Any idea what's wrong?



Thanks!



documentclassarticle

usepackagetikz

begindocument

begintikzpicture

draw[gray,very thin] (-5,-5) grid (5,5);

draw[black, very thick,<->](-5,0) -- (5,0);

draw[black,very thick,<->](0,-5) -- (0,5);

draw[very thick,domain=-5:-3.20156] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=-2.8577:2.8577] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=3.20156:5] plot (x,((x-2)(x+2))/((x-3)(x+3)));

endtikzpicture

enddocument









share|improve this question























  • You get what you ask for, I think. What fixes the domains you're using?
    – marmot
    34 mins ago










  • The domain is determined by the bounds -5<y<5.
    – Ben W
    32 mins ago










  • Yes, but you also forgot the multiplication signs.
    – marmot
    30 mins ago










  • Oops! That fixed it, thank you!
    – Ben W
    28 mins ago














up vote
2
down vote

favorite












I'm attempting to graph the function y=[(x-2)(x+2)]/[(x-3)(x+3)]. However, I get bizarre output, which consists of straight lines. Any idea what's wrong?



Thanks!



documentclassarticle

usepackagetikz

begindocument

begintikzpicture

draw[gray,very thin] (-5,-5) grid (5,5);

draw[black, very thick,<->](-5,0) -- (5,0);

draw[black,very thick,<->](0,-5) -- (0,5);

draw[very thick,domain=-5:-3.20156] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=-2.8577:2.8577] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=3.20156:5] plot (x,((x-2)(x+2))/((x-3)(x+3)));

endtikzpicture

enddocument









share|improve this question























  • You get what you ask for, I think. What fixes the domains you're using?
    – marmot
    34 mins ago










  • The domain is determined by the bounds -5<y<5.
    – Ben W
    32 mins ago










  • Yes, but you also forgot the multiplication signs.
    – marmot
    30 mins ago










  • Oops! That fixed it, thank you!
    – Ben W
    28 mins ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm attempting to graph the function y=[(x-2)(x+2)]/[(x-3)(x+3)]. However, I get bizarre output, which consists of straight lines. Any idea what's wrong?



Thanks!



documentclassarticle

usepackagetikz

begindocument

begintikzpicture

draw[gray,very thin] (-5,-5) grid (5,5);

draw[black, very thick,<->](-5,0) -- (5,0);

draw[black,very thick,<->](0,-5) -- (0,5);

draw[very thick,domain=-5:-3.20156] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=-2.8577:2.8577] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=3.20156:5] plot (x,((x-2)(x+2))/((x-3)(x+3)));

endtikzpicture

enddocument









share|improve this question















I'm attempting to graph the function y=[(x-2)(x+2)]/[(x-3)(x+3)]. However, I get bizarre output, which consists of straight lines. Any idea what's wrong?



Thanks!



documentclassarticle

usepackagetikz

begindocument

begintikzpicture

draw[gray,very thin] (-5,-5) grid (5,5);

draw[black, very thick,<->](-5,0) -- (5,0);

draw[black,very thick,<->](0,-5) -- (0,5);

draw[very thick,domain=-5:-3.20156] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=-2.8577:2.8577] plot (x,((x-2)(x+2))/((x-3)(x+3)));

draw[very thick,domain=3.20156:5] plot (x,((x-2)(x+2))/((x-3)(x+3)));

endtikzpicture

enddocument






tikz-pgf graphs






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 35 mins ago









marmot

71.5k476152




71.5k476152










asked 43 mins ago









Ben W

1214




1214











  • You get what you ask for, I think. What fixes the domains you're using?
    – marmot
    34 mins ago










  • The domain is determined by the bounds -5<y<5.
    – Ben W
    32 mins ago










  • Yes, but you also forgot the multiplication signs.
    – marmot
    30 mins ago










  • Oops! That fixed it, thank you!
    – Ben W
    28 mins ago
















  • You get what you ask for, I think. What fixes the domains you're using?
    – marmot
    34 mins ago










  • The domain is determined by the bounds -5<y<5.
    – Ben W
    32 mins ago










  • Yes, but you also forgot the multiplication signs.
    – marmot
    30 mins ago










  • Oops! That fixed it, thank you!
    – Ben W
    28 mins ago















You get what you ask for, I think. What fixes the domains you're using?
– marmot
34 mins ago




You get what you ask for, I think. What fixes the domains you're using?
– marmot
34 mins ago












The domain is determined by the bounds -5<y<5.
– Ben W
32 mins ago




The domain is determined by the bounds -5<y<5.
– Ben W
32 mins ago












Yes, but you also forgot the multiplication signs.
– marmot
30 mins ago




Yes, but you also forgot the multiplication signs.
– marmot
30 mins ago












Oops! That fixed it, thank you!
– Ben W
28 mins ago




Oops! That fixed it, thank you!
– Ben W
28 mins ago










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










You simply forgot multiplication signs and can make your life much more comfortable if you use declare function. And even even simpler with pgfplots because then you can just "jump" over singularities.



documentclassarticle
usepackagetikz
usepackagepgfplots
pgfplotssetcompat=1.16

begindocument
begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));,
samples=101]
draw[gray,very thin] (-5,-5) grid (5,5);
draw[black, very thick,<->](-5,0) -- (5,0);
draw[black,very thick,<->](0,-5) -- (0,5);
draw[very thick,domain=-5:-3.20156] plot (x,f(x));
draw[very thick,domain=-2.8577:2.8577] plot (x,f(x));
draw[very thick,domain=3.20156:5] plot (x,f(x));
endtikzpicture


begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));]
beginaxis[grid=major,axis lines=middle,xtick=empty,ytick=empty,
unbounded coords=jump,samples=101]
addplot[domain=-5:5] f(x);
endaxis
endtikzpicture

enddocument


enter image description here






share|improve this answer



























    up vote
    0
    down vote













    run with xelatex



    documentclassarticle
    usepackagepst-plot
    begindocument

    beginpspicture*[showgrid](-5,-5)(5,5)
    psaxes[labels=none,ticks=none,arrowscale=1.5]<->(0,0)(-5,-5)(5,5)
    psplot[algebraic,plotpoints=501,yMaxValue=5.5,
    linewidth=1.5pt]-55(x-2)*(x+2)/((x-3)*(x+3))
    endpspicture*

    enddocument


    enter image description here





    share




















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "85"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458348%2fim-trying-to-graph-a-rational-function-in-tikz%23new-answer', 'question_page');

      );

      Post as a guest






























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      2
      down vote



      accepted










      You simply forgot multiplication signs and can make your life much more comfortable if you use declare function. And even even simpler with pgfplots because then you can just "jump" over singularities.



      documentclassarticle
      usepackagetikz
      usepackagepgfplots
      pgfplotssetcompat=1.16

      begindocument
      begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));,
      samples=101]
      draw[gray,very thin] (-5,-5) grid (5,5);
      draw[black, very thick,<->](-5,0) -- (5,0);
      draw[black,very thick,<->](0,-5) -- (0,5);
      draw[very thick,domain=-5:-3.20156] plot (x,f(x));
      draw[very thick,domain=-2.8577:2.8577] plot (x,f(x));
      draw[very thick,domain=3.20156:5] plot (x,f(x));
      endtikzpicture


      begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));]
      beginaxis[grid=major,axis lines=middle,xtick=empty,ytick=empty,
      unbounded coords=jump,samples=101]
      addplot[domain=-5:5] f(x);
      endaxis
      endtikzpicture

      enddocument


      enter image description here






      share|improve this answer
























        up vote
        2
        down vote



        accepted










        You simply forgot multiplication signs and can make your life much more comfortable if you use declare function. And even even simpler with pgfplots because then you can just "jump" over singularities.



        documentclassarticle
        usepackagetikz
        usepackagepgfplots
        pgfplotssetcompat=1.16

        begindocument
        begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));,
        samples=101]
        draw[gray,very thin] (-5,-5) grid (5,5);
        draw[black, very thick,<->](-5,0) -- (5,0);
        draw[black,very thick,<->](0,-5) -- (0,5);
        draw[very thick,domain=-5:-3.20156] plot (x,f(x));
        draw[very thick,domain=-2.8577:2.8577] plot (x,f(x));
        draw[very thick,domain=3.20156:5] plot (x,f(x));
        endtikzpicture


        begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));]
        beginaxis[grid=major,axis lines=middle,xtick=empty,ytick=empty,
        unbounded coords=jump,samples=101]
        addplot[domain=-5:5] f(x);
        endaxis
        endtikzpicture

        enddocument


        enter image description here






        share|improve this answer






















          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          You simply forgot multiplication signs and can make your life much more comfortable if you use declare function. And even even simpler with pgfplots because then you can just "jump" over singularities.



          documentclassarticle
          usepackagetikz
          usepackagepgfplots
          pgfplotssetcompat=1.16

          begindocument
          begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));,
          samples=101]
          draw[gray,very thin] (-5,-5) grid (5,5);
          draw[black, very thick,<->](-5,0) -- (5,0);
          draw[black,very thick,<->](0,-5) -- (0,5);
          draw[very thick,domain=-5:-3.20156] plot (x,f(x));
          draw[very thick,domain=-2.8577:2.8577] plot (x,f(x));
          draw[very thick,domain=3.20156:5] plot (x,f(x));
          endtikzpicture


          begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));]
          beginaxis[grid=major,axis lines=middle,xtick=empty,ytick=empty,
          unbounded coords=jump,samples=101]
          addplot[domain=-5:5] f(x);
          endaxis
          endtikzpicture

          enddocument


          enter image description here






          share|improve this answer












          You simply forgot multiplication signs and can make your life much more comfortable if you use declare function. And even even simpler with pgfplots because then you can just "jump" over singularities.



          documentclassarticle
          usepackagetikz
          usepackagepgfplots
          pgfplotssetcompat=1.16

          begindocument
          begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));,
          samples=101]
          draw[gray,very thin] (-5,-5) grid (5,5);
          draw[black, very thick,<->](-5,0) -- (5,0);
          draw[black,very thick,<->](0,-5) -- (0,5);
          draw[very thick,domain=-5:-3.20156] plot (x,f(x));
          draw[very thick,domain=-2.8577:2.8577] plot (x,f(x));
          draw[very thick,domain=3.20156:5] plot (x,f(x));
          endtikzpicture


          begintikzpicture[declare function=f(x)=((x-2)*(x+2))/((x-3)*(x+3));]
          beginaxis[grid=major,axis lines=middle,xtick=empty,ytick=empty,
          unbounded coords=jump,samples=101]
          addplot[domain=-5:5] f(x);
          endaxis
          endtikzpicture

          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 28 mins ago









          marmot

          71.5k476152




          71.5k476152




















              up vote
              0
              down vote













              run with xelatex



              documentclassarticle
              usepackagepst-plot
              begindocument

              beginpspicture*[showgrid](-5,-5)(5,5)
              psaxes[labels=none,ticks=none,arrowscale=1.5]<->(0,0)(-5,-5)(5,5)
              psplot[algebraic,plotpoints=501,yMaxValue=5.5,
              linewidth=1.5pt]-55(x-2)*(x+2)/((x-3)*(x+3))
              endpspicture*

              enddocument


              enter image description here





              share
























                up vote
                0
                down vote













                run with xelatex



                documentclassarticle
                usepackagepst-plot
                begindocument

                beginpspicture*[showgrid](-5,-5)(5,5)
                psaxes[labels=none,ticks=none,arrowscale=1.5]<->(0,0)(-5,-5)(5,5)
                psplot[algebraic,plotpoints=501,yMaxValue=5.5,
                linewidth=1.5pt]-55(x-2)*(x+2)/((x-3)*(x+3))
                endpspicture*

                enddocument


                enter image description here





                share






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  run with xelatex



                  documentclassarticle
                  usepackagepst-plot
                  begindocument

                  beginpspicture*[showgrid](-5,-5)(5,5)
                  psaxes[labels=none,ticks=none,arrowscale=1.5]<->(0,0)(-5,-5)(5,5)
                  psplot[algebraic,plotpoints=501,yMaxValue=5.5,
                  linewidth=1.5pt]-55(x-2)*(x+2)/((x-3)*(x+3))
                  endpspicture*

                  enddocument


                  enter image description here





                  share












                  run with xelatex



                  documentclassarticle
                  usepackagepst-plot
                  begindocument

                  beginpspicture*[showgrid](-5,-5)(5,5)
                  psaxes[labels=none,ticks=none,arrowscale=1.5]<->(0,0)(-5,-5)(5,5)
                  psplot[algebraic,plotpoints=501,yMaxValue=5.5,
                  linewidth=1.5pt]-55(x-2)*(x+2)/((x-3)*(x+3))
                  endpspicture*

                  enddocument


                  enter image description here






                  share











                  share


                  share










                  answered 9 mins ago









                  Herbert

                  264k23399710




                  264k23399710



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458348%2fim-trying-to-graph-a-rational-function-in-tikz%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      Confectionery