Results 1 to 7 of 7

Math Help - How to draw a graph

  1. #1
    Junior Member
    Joined
    Oct 2008
    Posts
    41

    How to draw a graph

    I'm trying to create a calculus exam using LaTeX, and I want to draw a graph with discontinuities, asymptotes, etc.

    I'm trying to model the first part of the graph on [-9, -6) as -1/(x+6)

    When I type the following it works fine on [-9, -7]

    \begin{center}
    \mbox{\beginpicture
    \setcoordinatesystem units <.7cm, 1cm>
    \setplotarea x from -9 to 5, y from -5 to 5
    %% x axis:
    \arrow <.1in> [.15, .5] from -9 0 to 5 0
    \axis top shiftedto y=0 ticks out at -9 -8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 / /
    \axis bottom shiftedto y=0 ticks out numbered at -8 -4 4 / /
    \axis bottom shiftedto y=0 ticks out at -7 -6 -5 -3 -2 -1 1 2 3 / /
    %% y axis:
    \arrow <.1in> [.15, .5] from 0 -5 to 0 5
    \axis left shiftedto y=0 ticks in at -5 -4 -3 -2 -1 1 2 3 4 5 / /
    \axis left shiftedto y=0 ticks out numbered at -4 -2 2 4 / /
    \axis left shiftedto y=0 ticks out at -5 -3 -1 1 3 5 / /
    \setplotsymbol ({\large .})
    \setquadratic
    %%
    %% Graph of y = -1/(x+6)
    %%
    \plot
    -9 0.3333333
    -8.75 0.36364
    -8.5 0.4
    -8.25 0.44444
    -8 0.5
    -7.75 0.57143
    -7.5 0.666666
    -7.25 0.8
    -7 1
    /
    \endpicture}
    \end{center}

    However if I try to add the point (-6.75, 1.3333) to my list LaTeX returns an error and won't compile. Does anyone know why that is, or, better yet, a better way to do what I'm trying to do?
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Diamondlance View Post
    I'm trying to create a calculus exam using LaTeX, and I want to draw a graph with discontinuities, asymptotes, etc.

    I'm trying to model the first part of the graph on [-9, -6) as -1/(x+6)

    When I type the following it works fine on [-9, -7]

    \begin{center}
    \mbox{\beginpicture
    \setcoordinatesystem units <.7cm, 1cm>
    \setplotarea x from -9 to 5, y from -5 to 5
    %% x axis:
    \arrow <.1in> [.15, .5] from -9 0 to 5 0
    \axis top shiftedto y=0 ticks out at -9 -8 -7 -6 -5 -4 -3 -2 -1 1 2 3 4 / /
    \axis bottom shiftedto y=0 ticks out numbered at -8 -4 4 / /
    \axis bottom shiftedto y=0 ticks out at -7 -6 -5 -3 -2 -1 1 2 3 / /
    %% y axis:
    \arrow <.1in> [.15, .5] from 0 -5 to 0 5
    \axis left shiftedto y=0 ticks in at -5 -4 -3 -2 -1 1 2 3 4 5 / /
    \axis left shiftedto y=0 ticks out numbered at -4 -2 2 4 / /
    \axis left shiftedto y=0 ticks out at -5 -3 -1 1 3 5 / /
    \setplotsymbol ({\large .})
    \setquadratic
    %%
    %% Graph of y = -1/(x+6)
    %%
    \plot
    -9 0.3333333
    -8.75 0.36364
    -8.5 0.4
    -8.25 0.44444
    -8 0.5
    -7.75 0.57143
    -7.5 0.666666
    -7.25 0.8
    -7 1
    /
    \endpicture}
    \end{center}

    However if I try to add the point (-6.75, 1.3333) to my list LaTeX returns an error and won't compile. Does anyone know why that is, or, better yet, a better way to do what I'm trying to do?
    A better way is to generate the figure with a specialist tool outside of LaTeX (Matlab, Mathematica, ... ) save the graph as a graphics file and include that in your document.

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Oct 2008
    Posts
    41
    I figured as much...but I'm still curious as to why adding a point causes problems.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    A Plied Mathematician
    Joined
    Jun 2010
    From
    CT, USA
    Posts
    6,318
    Thanks
    4
    Awards
    2
    In general, I'd agree with CB. However, I do have to say that LaTeX I've found to be very persnickety when it comes to graphs. Everything has to be just right. The graphic has to be in eps format (which is not terribly difficult; Mathematica does output graphs and other pictures in that format), and the syntax for inclusion has to be just right, and the file has to be in the right place. There's a fair amount to it.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Ackbeet View Post
    In general, I'd agree with CB. However, I do have to say that LaTeX I've found to be very persnickety when it comes to graphs. Everything has to be just right. The graphic has to be in eps format (which is not terribly difficult; Mathematica does output graphs and other pictures in that format), and the syntax for inclusion has to be just right, and the file has to be in the right place. There's a fair amount to it.
    PDFLaTeX and other compilers allow formats other than eps most of the illurstarations in the MHFzine are png's

    CB
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Member Focus's Avatar
    Joined
    Aug 2009
    Posts
    228
    I think GNUPlot has a direct latex output (as well as eps and a ton of others).
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Senior Member
    Joined
    Mar 2010
    Posts
    280
    Your function
    -1/(x+6) at x=-6 goes to infinity.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. How do I draw a graph for this???
    Posted in the Algebra Forum
    Replies: 1
    Last Post: January 17th 2012, 06:04 AM
  2. draw cos graph
    Posted in the Pre-Calculus Forum
    Replies: 5
    Last Post: February 14th 2011, 10:30 AM
  3. How can I draw the graph
    Posted in the Trigonometry Forum
    Replies: 1
    Last Post: November 11th 2010, 03:46 AM
  4. Replies: 2
    Last Post: August 26th 2009, 04:51 AM
  5. How to draw graph?
    Posted in the Pre-Calculus Forum
    Replies: 5
    Last Post: September 19th 2008, 01:39 PM

Search Tags


/mathhelpforum @mathhelpforum