Plotting exponential functions











up vote
5
down vote

favorite












Can anyone give me a clue on how to plot this function:



4(t-1)e^-0,5t+8



It can be with any package, as the ones I've tried to use don't work (pgfplots gives me TeX capacity exceeded, sorry), my attempts with other packages aren't even remotely working :(



The graph only has to be in between 0 and 10. Also, is there any way to put a table with the values next to the graph?



Thanks for your help..










share|improve this question




















  • 1




    How would anyone know what's wrong with your code if you do not reveal it?
    – marmot
    12 hours ago






  • 1




    Add a minimum working example of what you have tried so far.
    – nidhin
    12 hours ago












  • since i was just experimenting with some packages, there isn't much code to show
    – writzlpfrimpft
    12 hours ago










  • There must be some code that causes TeX capacity exceeded, sorry, right?
    – marmot
    12 hours ago

















up vote
5
down vote

favorite












Can anyone give me a clue on how to plot this function:



4(t-1)e^-0,5t+8



It can be with any package, as the ones I've tried to use don't work (pgfplots gives me TeX capacity exceeded, sorry), my attempts with other packages aren't even remotely working :(



The graph only has to be in between 0 and 10. Also, is there any way to put a table with the values next to the graph?



Thanks for your help..










share|improve this question




















  • 1




    How would anyone know what's wrong with your code if you do not reveal it?
    – marmot
    12 hours ago






  • 1




    Add a minimum working example of what you have tried so far.
    – nidhin
    12 hours ago












  • since i was just experimenting with some packages, there isn't much code to show
    – writzlpfrimpft
    12 hours ago










  • There must be some code that causes TeX capacity exceeded, sorry, right?
    – marmot
    12 hours ago















up vote
5
down vote

favorite









up vote
5
down vote

favorite











Can anyone give me a clue on how to plot this function:



4(t-1)e^-0,5t+8



It can be with any package, as the ones I've tried to use don't work (pgfplots gives me TeX capacity exceeded, sorry), my attempts with other packages aren't even remotely working :(



The graph only has to be in between 0 and 10. Also, is there any way to put a table with the values next to the graph?



Thanks for your help..










share|improve this question















Can anyone give me a clue on how to plot this function:



4(t-1)e^-0,5t+8



It can be with any package, as the ones I've tried to use don't work (pgfplots gives me TeX capacity exceeded, sorry), my attempts with other packages aren't even remotely working :(



The graph only has to be in between 0 and 10. Also, is there any way to put a table with the values next to the graph?



Thanks for your help..







plot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 hours ago

























asked 12 hours ago









writzlpfrimpft

383




383








  • 1




    How would anyone know what's wrong with your code if you do not reveal it?
    – marmot
    12 hours ago






  • 1




    Add a minimum working example of what you have tried so far.
    – nidhin
    12 hours ago












  • since i was just experimenting with some packages, there isn't much code to show
    – writzlpfrimpft
    12 hours ago










  • There must be some code that causes TeX capacity exceeded, sorry, right?
    – marmot
    12 hours ago
















  • 1




    How would anyone know what's wrong with your code if you do not reveal it?
    – marmot
    12 hours ago






  • 1




    Add a minimum working example of what you have tried so far.
    – nidhin
    12 hours ago












  • since i was just experimenting with some packages, there isn't much code to show
    – writzlpfrimpft
    12 hours ago










  • There must be some code that causes TeX capacity exceeded, sorry, right?
    – marmot
    12 hours ago










1




1




How would anyone know what's wrong with your code if you do not reveal it?
– marmot
12 hours ago




How would anyone know what's wrong with your code if you do not reveal it?
– marmot
12 hours ago




1




1




Add a minimum working example of what you have tried so far.
– nidhin
12 hours ago






Add a minimum working example of what you have tried so far.
– nidhin
12 hours ago














since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
12 hours ago




since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
12 hours ago












There must be some code that causes TeX capacity exceeded, sorry, right?
– marmot
12 hours ago






There must be some code that causes TeX capacity exceeded, sorry, right?
– marmot
12 hours ago












5 Answers
5






active

oldest

votes

















up vote
6
down vote













documentclass[tikz,border=3.14mm]{standalone}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
begin{axis}
addplot [domain=0:5] {myexp(x)};
end{axis}
end{tikzpicture}
end{document}


enter image description here



And of course it is possible to add the range from 1 to 10, and to add a table. (You added these requests only after I answer was there.)



documentclass[tikz,border=3.14mm]{standalone}
usetikzlibrary{matrix,calc}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
begin{axis}
addplot [domain=0:10,samples=101] {myexp(x)};
end{axis}
matrix[matrix of math nodes,anchor=north west,%
column 1/.style={align=right,text width=5mm},
column 2/.style={align=left,text width=8mm}] (mat) at ([xshift=0.2cm]current axis.north
east) {%
x & f(x)\
0 & pgfmathparse{myexp(0)}pgfmathprintnumber{pgfmathresult}\
1 & pgfmathparse{myexp(1)}pgfmathprintnumber{pgfmathresult}\
2 & pgfmathparse{myexp(2)}pgfmathprintnumber{pgfmathresult}\
3 & pgfmathparse{myexp(3)}pgfmathprintnumber{pgfmathresult}\
4 & pgfmathparse{myexp(4)}pgfmathprintnumber{pgfmathresult}\
5 & pgfmathparse{myexp(5)}pgfmathprintnumber{pgfmathresult}\
6 & pgfmathparse{myexp(6)}pgfmathprintnumber{pgfmathresult}\
7 & pgfmathparse{myexp(7)}pgfmathprintnumber{pgfmathresult}\
8 & pgfmathparse{myexp(8)}pgfmathprintnumber{pgfmathresult}\
9 & pgfmathparse{myexp(9)}pgfmathprintnumber{pgfmathresult}\
10 & pgfmathparse{myexp(10)}pgfmathprintnumber{pgfmathresult}\
};
draw ($(mat-1-1.south west)!0.5!(mat-2-1.north west)$) --
($(mat-1-2.south east)!0.5!(mat-2-2.north east)$);
draw ($(mat-1-1.north east)!0.5!(mat-1-2.north west)$) --
($(mat-12-1.south east)!0.5!(mat-12-2.south west)$);
end{tikzpicture}
end{document}


enter image description here



Note that you can also generate the table in a foreach loop, but I am not going to spell this out here.






share|improve this answer






























    up vote
    3
    down vote













    A variant with pstricks:



    documentclass[11pt, svgnames, border=6pt]{standalone}
    usepackage{pst-func}
    usepackage{auto-pst-pdf}

    begin{document}

    begin{pspicture*}(-1.2,-1.2)(11,11)
    psset{psgrid, gridcoor ={(0,0)(10,10)}, algebraic}
    defF{4*(x-1)*EXP(-x/2) + 8}
    psaxes[labels=all, arrows=->, arrowinset=0.1, linecolor=SteelBlue, tickcolor=LightSteelBlue, Dx = 5, Dy = 5, subticks = 5]%
    (0,0)(-1,-1)(11,11)[$t$, -120][$y$,-135]
    uput[dl](0,0){$ O $}%
    psplot[linewidth=1.5pt, linecolor=IndianRed, plotstyle=curve, plotpoints=200]{0}{10}{F}%
    psCoordinates[linestyle=dashed, linewidth=0.4pt, linecolor=LightSteelBlue](3, 9.785)
    psplotTangent[linecolor=LightSteelBlue]{3}{1}{F}
    uput[d](3,0){small$3$}
    end{pspicture*}

    end{document}


    enter image description here






    share|improve this answer




























      up vote
      2
      down vote













      Quick and dirty attempt with MetaPost, included in a LuaLaTeX program:



      RequirePackage{luatex85}
      documentclass[border=2mm]{standalone}
      usepackage{luamplib}
      mplibsetformat{metafun}
      mplibtextextlabel{enable}
      mplibnumbersystem{double}
      begin{document}
      begin{mplibcode}
      u := cm; v = .75cm;
      vardef f(expr t) = 4(t-1)*exp(-.5t) + 8 enddef;
      tmin = -1.25; tmax = 9.75; tstep = .1; ymin = -8.75; ymax = 10.5;
      path curve;
      curve = (tmin, f(tmin))
      for t = tmin + tstep step tstep until tmax+.5tstep: .. (t, f(t)) endfor;
      beginfig(1);
      draw curve xyscaled (u, v);
      drawarrow (tmin*u, 0) -- (tmax*u, 0); drawarrow (0, ymin*v) -- (0, ymax*v);
      for i = ceiling(tmin) upto floor(tmax):
      if i<>0:
      draw (i*u, -2bp) -- (i*u, 2bp);
      label.bot("$" & decimal i & "$", (i*u, 0)); fi
      endfor;
      for j = ceiling(ymin) upto floor(ymax):
      if j<>0:
      draw (2bp, j*v) -- (-2bp, j*v);
      label.lft("$" & decimal j & "$", (0, j*v)); fi
      endfor;
      label.llft("$O$", origin); label.bot("$t$", (tmax*u, 0)); label.lft("$y$", (0, ymax*v));
      endfig;
      end{mplibcode}
      end{document}


      enter image description here






      share|improve this answer






























        up vote
        2
        down vote













        run with xelatex



        documentclass[pstricks,border=5mm]{standalone}
        usepackage{pst-plot}

        begin{document}
        begin{pspicture}(-1,-1)(11,11)
        psaxes{->}(0,0)(-0.5,-0.5)(10,10)[$x$,0][$y$,90]
        psplot[algebraic,linecolor=blue,linewidth=2pt]{0}{10}{4*(x-1)*Euler^(-0.5*x)+8}
        end{pspicture}
        end{document}


        enter image description here






        share|improve this answer




























          up vote
          2
          down vote













          If you know R, then knitr is a simple option:



          mwe



          documentclass{article}
          begin{document}
          <<echo=F,dev="tikz",fig.cap="My function $f(t)=4(t-1)e^{-0.5t}+8$", fig.width=5, fig.height=5, out.width = "\linewidth">>=
          t <- seq(0,10,.1)
          y <- 4*(t-1)*exp(-0.5*t)+8
          plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
          @
          end{document}


          R could also produce the table easily, but place it beside the figure need some tuning of R and LaTeX code:



          MWE



          documentclass{article}
          usepackage{booktabs}
          begin{document}
          begin{figure}
          <<xxx, echo=F,dev="tikz", fig.show='hide', fig.width=3, fig.height=3, out.width = "3in", out.height="3in">>=
          t <- seq(0,10,.1)
          y <- 4*(t-1)*exp(-0.5*t)+8
          par(mar=c(4.5,4.5,0.5,0))
          plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
          @
          begin{minipage}[t]{3in}vspace{0pt}
          includegraphics{figure/xxx-1}
          end{minipage}hfill%
          begin{minipage}[t]{.2linewidth}smallskip
          <<echo=F,results='asis'>>=
          x <- seq(0,10)
          y <- 4*(x-1)*exp(-0.5*x)+8
          df <- data.frame(t=x,f=y)
          names(df) <- c("t (time)","Function f(t)")
          library(xtable)
          print(xtable(df,align=rep("c",3)), include.rownames=F,floating=F, booktabs=T)
          @
          end{minipage}
          caption{My function $f(t)=4(t-1)e^{-0.5t}+8$}
          end{figure}
          end{document}





          share|improve this answer























            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%2f462050%2fplotting-exponential-functions%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            6
            down vote













            documentclass[tikz,border=3.14mm]{standalone}
            usepackage{pgfplots}
            pgfplotsset{compat=1.16}
            begin{document}
            begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
            begin{axis}
            addplot [domain=0:5] {myexp(x)};
            end{axis}
            end{tikzpicture}
            end{document}


            enter image description here



            And of course it is possible to add the range from 1 to 10, and to add a table. (You added these requests only after I answer was there.)



            documentclass[tikz,border=3.14mm]{standalone}
            usetikzlibrary{matrix,calc}
            usepackage{pgfplots}
            pgfplotsset{compat=1.16}
            begin{document}
            begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
            begin{axis}
            addplot [domain=0:10,samples=101] {myexp(x)};
            end{axis}
            matrix[matrix of math nodes,anchor=north west,%
            column 1/.style={align=right,text width=5mm},
            column 2/.style={align=left,text width=8mm}] (mat) at ([xshift=0.2cm]current axis.north
            east) {%
            x & f(x)\
            0 & pgfmathparse{myexp(0)}pgfmathprintnumber{pgfmathresult}\
            1 & pgfmathparse{myexp(1)}pgfmathprintnumber{pgfmathresult}\
            2 & pgfmathparse{myexp(2)}pgfmathprintnumber{pgfmathresult}\
            3 & pgfmathparse{myexp(3)}pgfmathprintnumber{pgfmathresult}\
            4 & pgfmathparse{myexp(4)}pgfmathprintnumber{pgfmathresult}\
            5 & pgfmathparse{myexp(5)}pgfmathprintnumber{pgfmathresult}\
            6 & pgfmathparse{myexp(6)}pgfmathprintnumber{pgfmathresult}\
            7 & pgfmathparse{myexp(7)}pgfmathprintnumber{pgfmathresult}\
            8 & pgfmathparse{myexp(8)}pgfmathprintnumber{pgfmathresult}\
            9 & pgfmathparse{myexp(9)}pgfmathprintnumber{pgfmathresult}\
            10 & pgfmathparse{myexp(10)}pgfmathprintnumber{pgfmathresult}\
            };
            draw ($(mat-1-1.south west)!0.5!(mat-2-1.north west)$) --
            ($(mat-1-2.south east)!0.5!(mat-2-2.north east)$);
            draw ($(mat-1-1.north east)!0.5!(mat-1-2.north west)$) --
            ($(mat-12-1.south east)!0.5!(mat-12-2.south west)$);
            end{tikzpicture}
            end{document}


            enter image description here



            Note that you can also generate the table in a foreach loop, but I am not going to spell this out here.






            share|improve this answer



























              up vote
              6
              down vote













              documentclass[tikz,border=3.14mm]{standalone}
              usepackage{pgfplots}
              pgfplotsset{compat=1.16}
              begin{document}
              begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
              begin{axis}
              addplot [domain=0:5] {myexp(x)};
              end{axis}
              end{tikzpicture}
              end{document}


              enter image description here



              And of course it is possible to add the range from 1 to 10, and to add a table. (You added these requests only after I answer was there.)



              documentclass[tikz,border=3.14mm]{standalone}
              usetikzlibrary{matrix,calc}
              usepackage{pgfplots}
              pgfplotsset{compat=1.16}
              begin{document}
              begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
              begin{axis}
              addplot [domain=0:10,samples=101] {myexp(x)};
              end{axis}
              matrix[matrix of math nodes,anchor=north west,%
              column 1/.style={align=right,text width=5mm},
              column 2/.style={align=left,text width=8mm}] (mat) at ([xshift=0.2cm]current axis.north
              east) {%
              x & f(x)\
              0 & pgfmathparse{myexp(0)}pgfmathprintnumber{pgfmathresult}\
              1 & pgfmathparse{myexp(1)}pgfmathprintnumber{pgfmathresult}\
              2 & pgfmathparse{myexp(2)}pgfmathprintnumber{pgfmathresult}\
              3 & pgfmathparse{myexp(3)}pgfmathprintnumber{pgfmathresult}\
              4 & pgfmathparse{myexp(4)}pgfmathprintnumber{pgfmathresult}\
              5 & pgfmathparse{myexp(5)}pgfmathprintnumber{pgfmathresult}\
              6 & pgfmathparse{myexp(6)}pgfmathprintnumber{pgfmathresult}\
              7 & pgfmathparse{myexp(7)}pgfmathprintnumber{pgfmathresult}\
              8 & pgfmathparse{myexp(8)}pgfmathprintnumber{pgfmathresult}\
              9 & pgfmathparse{myexp(9)}pgfmathprintnumber{pgfmathresult}\
              10 & pgfmathparse{myexp(10)}pgfmathprintnumber{pgfmathresult}\
              };
              draw ($(mat-1-1.south west)!0.5!(mat-2-1.north west)$) --
              ($(mat-1-2.south east)!0.5!(mat-2-2.north east)$);
              draw ($(mat-1-1.north east)!0.5!(mat-1-2.north west)$) --
              ($(mat-12-1.south east)!0.5!(mat-12-2.south west)$);
              end{tikzpicture}
              end{document}


              enter image description here



              Note that you can also generate the table in a foreach loop, but I am not going to spell this out here.






              share|improve this answer

























                up vote
                6
                down vote










                up vote
                6
                down vote









                documentclass[tikz,border=3.14mm]{standalone}
                usepackage{pgfplots}
                pgfplotsset{compat=1.16}
                begin{document}
                begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
                begin{axis}
                addplot [domain=0:5] {myexp(x)};
                end{axis}
                end{tikzpicture}
                end{document}


                enter image description here



                And of course it is possible to add the range from 1 to 10, and to add a table. (You added these requests only after I answer was there.)



                documentclass[tikz,border=3.14mm]{standalone}
                usetikzlibrary{matrix,calc}
                usepackage{pgfplots}
                pgfplotsset{compat=1.16}
                begin{document}
                begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
                begin{axis}
                addplot [domain=0:10,samples=101] {myexp(x)};
                end{axis}
                matrix[matrix of math nodes,anchor=north west,%
                column 1/.style={align=right,text width=5mm},
                column 2/.style={align=left,text width=8mm}] (mat) at ([xshift=0.2cm]current axis.north
                east) {%
                x & f(x)\
                0 & pgfmathparse{myexp(0)}pgfmathprintnumber{pgfmathresult}\
                1 & pgfmathparse{myexp(1)}pgfmathprintnumber{pgfmathresult}\
                2 & pgfmathparse{myexp(2)}pgfmathprintnumber{pgfmathresult}\
                3 & pgfmathparse{myexp(3)}pgfmathprintnumber{pgfmathresult}\
                4 & pgfmathparse{myexp(4)}pgfmathprintnumber{pgfmathresult}\
                5 & pgfmathparse{myexp(5)}pgfmathprintnumber{pgfmathresult}\
                6 & pgfmathparse{myexp(6)}pgfmathprintnumber{pgfmathresult}\
                7 & pgfmathparse{myexp(7)}pgfmathprintnumber{pgfmathresult}\
                8 & pgfmathparse{myexp(8)}pgfmathprintnumber{pgfmathresult}\
                9 & pgfmathparse{myexp(9)}pgfmathprintnumber{pgfmathresult}\
                10 & pgfmathparse{myexp(10)}pgfmathprintnumber{pgfmathresult}\
                };
                draw ($(mat-1-1.south west)!0.5!(mat-2-1.north west)$) --
                ($(mat-1-2.south east)!0.5!(mat-2-2.north east)$);
                draw ($(mat-1-1.north east)!0.5!(mat-1-2.north west)$) --
                ($(mat-12-1.south east)!0.5!(mat-12-2.south west)$);
                end{tikzpicture}
                end{document}


                enter image description here



                Note that you can also generate the table in a foreach loop, but I am not going to spell this out here.






                share|improve this answer














                documentclass[tikz,border=3.14mm]{standalone}
                usepackage{pgfplots}
                pgfplotsset{compat=1.16}
                begin{document}
                begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
                begin{axis}
                addplot [domain=0:5] {myexp(x)};
                end{axis}
                end{tikzpicture}
                end{document}


                enter image description here



                And of course it is possible to add the range from 1 to 10, and to add a table. (You added these requests only after I answer was there.)



                documentclass[tikz,border=3.14mm]{standalone}
                usetikzlibrary{matrix,calc}
                usepackage{pgfplots}
                pgfplotsset{compat=1.16}
                begin{document}
                begin{tikzpicture}[declare function={myexp(x)=4*(x-1)*exp(-0.5*x)+8;}]
                begin{axis}
                addplot [domain=0:10,samples=101] {myexp(x)};
                end{axis}
                matrix[matrix of math nodes,anchor=north west,%
                column 1/.style={align=right,text width=5mm},
                column 2/.style={align=left,text width=8mm}] (mat) at ([xshift=0.2cm]current axis.north
                east) {%
                x & f(x)\
                0 & pgfmathparse{myexp(0)}pgfmathprintnumber{pgfmathresult}\
                1 & pgfmathparse{myexp(1)}pgfmathprintnumber{pgfmathresult}\
                2 & pgfmathparse{myexp(2)}pgfmathprintnumber{pgfmathresult}\
                3 & pgfmathparse{myexp(3)}pgfmathprintnumber{pgfmathresult}\
                4 & pgfmathparse{myexp(4)}pgfmathprintnumber{pgfmathresult}\
                5 & pgfmathparse{myexp(5)}pgfmathprintnumber{pgfmathresult}\
                6 & pgfmathparse{myexp(6)}pgfmathprintnumber{pgfmathresult}\
                7 & pgfmathparse{myexp(7)}pgfmathprintnumber{pgfmathresult}\
                8 & pgfmathparse{myexp(8)}pgfmathprintnumber{pgfmathresult}\
                9 & pgfmathparse{myexp(9)}pgfmathprintnumber{pgfmathresult}\
                10 & pgfmathparse{myexp(10)}pgfmathprintnumber{pgfmathresult}\
                };
                draw ($(mat-1-1.south west)!0.5!(mat-2-1.north west)$) --
                ($(mat-1-2.south east)!0.5!(mat-2-2.north east)$);
                draw ($(mat-1-1.north east)!0.5!(mat-1-2.north west)$) --
                ($(mat-12-1.south east)!0.5!(mat-12-2.south west)$);
                end{tikzpicture}
                end{document}


                enter image description here



                Note that you can also generate the table in a foreach loop, but I am not going to spell this out here.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 7 hours ago

























                answered 12 hours ago









                marmot

                78.7k487166




                78.7k487166






















                    up vote
                    3
                    down vote













                    A variant with pstricks:



                    documentclass[11pt, svgnames, border=6pt]{standalone}
                    usepackage{pst-func}
                    usepackage{auto-pst-pdf}

                    begin{document}

                    begin{pspicture*}(-1.2,-1.2)(11,11)
                    psset{psgrid, gridcoor ={(0,0)(10,10)}, algebraic}
                    defF{4*(x-1)*EXP(-x/2) + 8}
                    psaxes[labels=all, arrows=->, arrowinset=0.1, linecolor=SteelBlue, tickcolor=LightSteelBlue, Dx = 5, Dy = 5, subticks = 5]%
                    (0,0)(-1,-1)(11,11)[$t$, -120][$y$,-135]
                    uput[dl](0,0){$ O $}%
                    psplot[linewidth=1.5pt, linecolor=IndianRed, plotstyle=curve, plotpoints=200]{0}{10}{F}%
                    psCoordinates[linestyle=dashed, linewidth=0.4pt, linecolor=LightSteelBlue](3, 9.785)
                    psplotTangent[linecolor=LightSteelBlue]{3}{1}{F}
                    uput[d](3,0){small$3$}
                    end{pspicture*}

                    end{document}


                    enter image description here






                    share|improve this answer

























                      up vote
                      3
                      down vote













                      A variant with pstricks:



                      documentclass[11pt, svgnames, border=6pt]{standalone}
                      usepackage{pst-func}
                      usepackage{auto-pst-pdf}

                      begin{document}

                      begin{pspicture*}(-1.2,-1.2)(11,11)
                      psset{psgrid, gridcoor ={(0,0)(10,10)}, algebraic}
                      defF{4*(x-1)*EXP(-x/2) + 8}
                      psaxes[labels=all, arrows=->, arrowinset=0.1, linecolor=SteelBlue, tickcolor=LightSteelBlue, Dx = 5, Dy = 5, subticks = 5]%
                      (0,0)(-1,-1)(11,11)[$t$, -120][$y$,-135]
                      uput[dl](0,0){$ O $}%
                      psplot[linewidth=1.5pt, linecolor=IndianRed, plotstyle=curve, plotpoints=200]{0}{10}{F}%
                      psCoordinates[linestyle=dashed, linewidth=0.4pt, linecolor=LightSteelBlue](3, 9.785)
                      psplotTangent[linecolor=LightSteelBlue]{3}{1}{F}
                      uput[d](3,0){small$3$}
                      end{pspicture*}

                      end{document}


                      enter image description here






                      share|improve this answer























                        up vote
                        3
                        down vote










                        up vote
                        3
                        down vote









                        A variant with pstricks:



                        documentclass[11pt, svgnames, border=6pt]{standalone}
                        usepackage{pst-func}
                        usepackage{auto-pst-pdf}

                        begin{document}

                        begin{pspicture*}(-1.2,-1.2)(11,11)
                        psset{psgrid, gridcoor ={(0,0)(10,10)}, algebraic}
                        defF{4*(x-1)*EXP(-x/2) + 8}
                        psaxes[labels=all, arrows=->, arrowinset=0.1, linecolor=SteelBlue, tickcolor=LightSteelBlue, Dx = 5, Dy = 5, subticks = 5]%
                        (0,0)(-1,-1)(11,11)[$t$, -120][$y$,-135]
                        uput[dl](0,0){$ O $}%
                        psplot[linewidth=1.5pt, linecolor=IndianRed, plotstyle=curve, plotpoints=200]{0}{10}{F}%
                        psCoordinates[linestyle=dashed, linewidth=0.4pt, linecolor=LightSteelBlue](3, 9.785)
                        psplotTangent[linecolor=LightSteelBlue]{3}{1}{F}
                        uput[d](3,0){small$3$}
                        end{pspicture*}

                        end{document}


                        enter image description here






                        share|improve this answer












                        A variant with pstricks:



                        documentclass[11pt, svgnames, border=6pt]{standalone}
                        usepackage{pst-func}
                        usepackage{auto-pst-pdf}

                        begin{document}

                        begin{pspicture*}(-1.2,-1.2)(11,11)
                        psset{psgrid, gridcoor ={(0,0)(10,10)}, algebraic}
                        defF{4*(x-1)*EXP(-x/2) + 8}
                        psaxes[labels=all, arrows=->, arrowinset=0.1, linecolor=SteelBlue, tickcolor=LightSteelBlue, Dx = 5, Dy = 5, subticks = 5]%
                        (0,0)(-1,-1)(11,11)[$t$, -120][$y$,-135]
                        uput[dl](0,0){$ O $}%
                        psplot[linewidth=1.5pt, linecolor=IndianRed, plotstyle=curve, plotpoints=200]{0}{10}{F}%
                        psCoordinates[linestyle=dashed, linewidth=0.4pt, linecolor=LightSteelBlue](3, 9.785)
                        psplotTangent[linecolor=LightSteelBlue]{3}{1}{F}
                        uput[d](3,0){small$3$}
                        end{pspicture*}

                        end{document}


                        enter image description here







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 10 hours ago









                        Bernard

                        162k767192




                        162k767192






















                            up vote
                            2
                            down vote













                            Quick and dirty attempt with MetaPost, included in a LuaLaTeX program:



                            RequirePackage{luatex85}
                            documentclass[border=2mm]{standalone}
                            usepackage{luamplib}
                            mplibsetformat{metafun}
                            mplibtextextlabel{enable}
                            mplibnumbersystem{double}
                            begin{document}
                            begin{mplibcode}
                            u := cm; v = .75cm;
                            vardef f(expr t) = 4(t-1)*exp(-.5t) + 8 enddef;
                            tmin = -1.25; tmax = 9.75; tstep = .1; ymin = -8.75; ymax = 10.5;
                            path curve;
                            curve = (tmin, f(tmin))
                            for t = tmin + tstep step tstep until tmax+.5tstep: .. (t, f(t)) endfor;
                            beginfig(1);
                            draw curve xyscaled (u, v);
                            drawarrow (tmin*u, 0) -- (tmax*u, 0); drawarrow (0, ymin*v) -- (0, ymax*v);
                            for i = ceiling(tmin) upto floor(tmax):
                            if i<>0:
                            draw (i*u, -2bp) -- (i*u, 2bp);
                            label.bot("$" & decimal i & "$", (i*u, 0)); fi
                            endfor;
                            for j = ceiling(ymin) upto floor(ymax):
                            if j<>0:
                            draw (2bp, j*v) -- (-2bp, j*v);
                            label.lft("$" & decimal j & "$", (0, j*v)); fi
                            endfor;
                            label.llft("$O$", origin); label.bot("$t$", (tmax*u, 0)); label.lft("$y$", (0, ymax*v));
                            endfig;
                            end{mplibcode}
                            end{document}


                            enter image description here






                            share|improve this answer



























                              up vote
                              2
                              down vote













                              Quick and dirty attempt with MetaPost, included in a LuaLaTeX program:



                              RequirePackage{luatex85}
                              documentclass[border=2mm]{standalone}
                              usepackage{luamplib}
                              mplibsetformat{metafun}
                              mplibtextextlabel{enable}
                              mplibnumbersystem{double}
                              begin{document}
                              begin{mplibcode}
                              u := cm; v = .75cm;
                              vardef f(expr t) = 4(t-1)*exp(-.5t) + 8 enddef;
                              tmin = -1.25; tmax = 9.75; tstep = .1; ymin = -8.75; ymax = 10.5;
                              path curve;
                              curve = (tmin, f(tmin))
                              for t = tmin + tstep step tstep until tmax+.5tstep: .. (t, f(t)) endfor;
                              beginfig(1);
                              draw curve xyscaled (u, v);
                              drawarrow (tmin*u, 0) -- (tmax*u, 0); drawarrow (0, ymin*v) -- (0, ymax*v);
                              for i = ceiling(tmin) upto floor(tmax):
                              if i<>0:
                              draw (i*u, -2bp) -- (i*u, 2bp);
                              label.bot("$" & decimal i & "$", (i*u, 0)); fi
                              endfor;
                              for j = ceiling(ymin) upto floor(ymax):
                              if j<>0:
                              draw (2bp, j*v) -- (-2bp, j*v);
                              label.lft("$" & decimal j & "$", (0, j*v)); fi
                              endfor;
                              label.llft("$O$", origin); label.bot("$t$", (tmax*u, 0)); label.lft("$y$", (0, ymax*v));
                              endfig;
                              end{mplibcode}
                              end{document}


                              enter image description here






                              share|improve this answer

























                                up vote
                                2
                                down vote










                                up vote
                                2
                                down vote









                                Quick and dirty attempt with MetaPost, included in a LuaLaTeX program:



                                RequirePackage{luatex85}
                                documentclass[border=2mm]{standalone}
                                usepackage{luamplib}
                                mplibsetformat{metafun}
                                mplibtextextlabel{enable}
                                mplibnumbersystem{double}
                                begin{document}
                                begin{mplibcode}
                                u := cm; v = .75cm;
                                vardef f(expr t) = 4(t-1)*exp(-.5t) + 8 enddef;
                                tmin = -1.25; tmax = 9.75; tstep = .1; ymin = -8.75; ymax = 10.5;
                                path curve;
                                curve = (tmin, f(tmin))
                                for t = tmin + tstep step tstep until tmax+.5tstep: .. (t, f(t)) endfor;
                                beginfig(1);
                                draw curve xyscaled (u, v);
                                drawarrow (tmin*u, 0) -- (tmax*u, 0); drawarrow (0, ymin*v) -- (0, ymax*v);
                                for i = ceiling(tmin) upto floor(tmax):
                                if i<>0:
                                draw (i*u, -2bp) -- (i*u, 2bp);
                                label.bot("$" & decimal i & "$", (i*u, 0)); fi
                                endfor;
                                for j = ceiling(ymin) upto floor(ymax):
                                if j<>0:
                                draw (2bp, j*v) -- (-2bp, j*v);
                                label.lft("$" & decimal j & "$", (0, j*v)); fi
                                endfor;
                                label.llft("$O$", origin); label.bot("$t$", (tmax*u, 0)); label.lft("$y$", (0, ymax*v));
                                endfig;
                                end{mplibcode}
                                end{document}


                                enter image description here






                                share|improve this answer














                                Quick and dirty attempt with MetaPost, included in a LuaLaTeX program:



                                RequirePackage{luatex85}
                                documentclass[border=2mm]{standalone}
                                usepackage{luamplib}
                                mplibsetformat{metafun}
                                mplibtextextlabel{enable}
                                mplibnumbersystem{double}
                                begin{document}
                                begin{mplibcode}
                                u := cm; v = .75cm;
                                vardef f(expr t) = 4(t-1)*exp(-.5t) + 8 enddef;
                                tmin = -1.25; tmax = 9.75; tstep = .1; ymin = -8.75; ymax = 10.5;
                                path curve;
                                curve = (tmin, f(tmin))
                                for t = tmin + tstep step tstep until tmax+.5tstep: .. (t, f(t)) endfor;
                                beginfig(1);
                                draw curve xyscaled (u, v);
                                drawarrow (tmin*u, 0) -- (tmax*u, 0); drawarrow (0, ymin*v) -- (0, ymax*v);
                                for i = ceiling(tmin) upto floor(tmax):
                                if i<>0:
                                draw (i*u, -2bp) -- (i*u, 2bp);
                                label.bot("$" & decimal i & "$", (i*u, 0)); fi
                                endfor;
                                for j = ceiling(ymin) upto floor(ymax):
                                if j<>0:
                                draw (2bp, j*v) -- (-2bp, j*v);
                                label.lft("$" & decimal j & "$", (0, j*v)); fi
                                endfor;
                                label.llft("$O$", origin); label.bot("$t$", (tmax*u, 0)); label.lft("$y$", (0, ymax*v));
                                endfig;
                                end{mplibcode}
                                end{document}


                                enter image description here







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 10 hours ago

























                                answered 11 hours ago









                                Franck Pastor

                                15.5k13459




                                15.5k13459






















                                    up vote
                                    2
                                    down vote













                                    run with xelatex



                                    documentclass[pstricks,border=5mm]{standalone}
                                    usepackage{pst-plot}

                                    begin{document}
                                    begin{pspicture}(-1,-1)(11,11)
                                    psaxes{->}(0,0)(-0.5,-0.5)(10,10)[$x$,0][$y$,90]
                                    psplot[algebraic,linecolor=blue,linewidth=2pt]{0}{10}{4*(x-1)*Euler^(-0.5*x)+8}
                                    end{pspicture}
                                    end{document}


                                    enter image description here






                                    share|improve this answer

























                                      up vote
                                      2
                                      down vote













                                      run with xelatex



                                      documentclass[pstricks,border=5mm]{standalone}
                                      usepackage{pst-plot}

                                      begin{document}
                                      begin{pspicture}(-1,-1)(11,11)
                                      psaxes{->}(0,0)(-0.5,-0.5)(10,10)[$x$,0][$y$,90]
                                      psplot[algebraic,linecolor=blue,linewidth=2pt]{0}{10}{4*(x-1)*Euler^(-0.5*x)+8}
                                      end{pspicture}
                                      end{document}


                                      enter image description here






                                      share|improve this answer























                                        up vote
                                        2
                                        down vote










                                        up vote
                                        2
                                        down vote









                                        run with xelatex



                                        documentclass[pstricks,border=5mm]{standalone}
                                        usepackage{pst-plot}

                                        begin{document}
                                        begin{pspicture}(-1,-1)(11,11)
                                        psaxes{->}(0,0)(-0.5,-0.5)(10,10)[$x$,0][$y$,90]
                                        psplot[algebraic,linecolor=blue,linewidth=2pt]{0}{10}{4*(x-1)*Euler^(-0.5*x)+8}
                                        end{pspicture}
                                        end{document}


                                        enter image description here






                                        share|improve this answer












                                        run with xelatex



                                        documentclass[pstricks,border=5mm]{standalone}
                                        usepackage{pst-plot}

                                        begin{document}
                                        begin{pspicture}(-1,-1)(11,11)
                                        psaxes{->}(0,0)(-0.5,-0.5)(10,10)[$x$,0][$y$,90]
                                        psplot[algebraic,linecolor=blue,linewidth=2pt]{0}{10}{4*(x-1)*Euler^(-0.5*x)+8}
                                        end{pspicture}
                                        end{document}


                                        enter image description here







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 10 hours ago









                                        Herbert

                                        265k23404713




                                        265k23404713






















                                            up vote
                                            2
                                            down vote













                                            If you know R, then knitr is a simple option:



                                            mwe



                                            documentclass{article}
                                            begin{document}
                                            <<echo=F,dev="tikz",fig.cap="My function $f(t)=4(t-1)e^{-0.5t}+8$", fig.width=5, fig.height=5, out.width = "\linewidth">>=
                                            t <- seq(0,10,.1)
                                            y <- 4*(t-1)*exp(-0.5*t)+8
                                            plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                            @
                                            end{document}


                                            R could also produce the table easily, but place it beside the figure need some tuning of R and LaTeX code:



                                            MWE



                                            documentclass{article}
                                            usepackage{booktabs}
                                            begin{document}
                                            begin{figure}
                                            <<xxx, echo=F,dev="tikz", fig.show='hide', fig.width=3, fig.height=3, out.width = "3in", out.height="3in">>=
                                            t <- seq(0,10,.1)
                                            y <- 4*(t-1)*exp(-0.5*t)+8
                                            par(mar=c(4.5,4.5,0.5,0))
                                            plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                            @
                                            begin{minipage}[t]{3in}vspace{0pt}
                                            includegraphics{figure/xxx-1}
                                            end{minipage}hfill%
                                            begin{minipage}[t]{.2linewidth}smallskip
                                            <<echo=F,results='asis'>>=
                                            x <- seq(0,10)
                                            y <- 4*(x-1)*exp(-0.5*x)+8
                                            df <- data.frame(t=x,f=y)
                                            names(df) <- c("t (time)","Function f(t)")
                                            library(xtable)
                                            print(xtable(df,align=rep("c",3)), include.rownames=F,floating=F, booktabs=T)
                                            @
                                            end{minipage}
                                            caption{My function $f(t)=4(t-1)e^{-0.5t}+8$}
                                            end{figure}
                                            end{document}





                                            share|improve this answer



























                                              up vote
                                              2
                                              down vote













                                              If you know R, then knitr is a simple option:



                                              mwe



                                              documentclass{article}
                                              begin{document}
                                              <<echo=F,dev="tikz",fig.cap="My function $f(t)=4(t-1)e^{-0.5t}+8$", fig.width=5, fig.height=5, out.width = "\linewidth">>=
                                              t <- seq(0,10,.1)
                                              y <- 4*(t-1)*exp(-0.5*t)+8
                                              plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                              @
                                              end{document}


                                              R could also produce the table easily, but place it beside the figure need some tuning of R and LaTeX code:



                                              MWE



                                              documentclass{article}
                                              usepackage{booktabs}
                                              begin{document}
                                              begin{figure}
                                              <<xxx, echo=F,dev="tikz", fig.show='hide', fig.width=3, fig.height=3, out.width = "3in", out.height="3in">>=
                                              t <- seq(0,10,.1)
                                              y <- 4*(t-1)*exp(-0.5*t)+8
                                              par(mar=c(4.5,4.5,0.5,0))
                                              plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                              @
                                              begin{minipage}[t]{3in}vspace{0pt}
                                              includegraphics{figure/xxx-1}
                                              end{minipage}hfill%
                                              begin{minipage}[t]{.2linewidth}smallskip
                                              <<echo=F,results='asis'>>=
                                              x <- seq(0,10)
                                              y <- 4*(x-1)*exp(-0.5*x)+8
                                              df <- data.frame(t=x,f=y)
                                              names(df) <- c("t (time)","Function f(t)")
                                              library(xtable)
                                              print(xtable(df,align=rep("c",3)), include.rownames=F,floating=F, booktabs=T)
                                              @
                                              end{minipage}
                                              caption{My function $f(t)=4(t-1)e^{-0.5t}+8$}
                                              end{figure}
                                              end{document}





                                              share|improve this answer

























                                                up vote
                                                2
                                                down vote










                                                up vote
                                                2
                                                down vote









                                                If you know R, then knitr is a simple option:



                                                mwe



                                                documentclass{article}
                                                begin{document}
                                                <<echo=F,dev="tikz",fig.cap="My function $f(t)=4(t-1)e^{-0.5t}+8$", fig.width=5, fig.height=5, out.width = "\linewidth">>=
                                                t <- seq(0,10,.1)
                                                y <- 4*(t-1)*exp(-0.5*t)+8
                                                plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                                @
                                                end{document}


                                                R could also produce the table easily, but place it beside the figure need some tuning of R and LaTeX code:



                                                MWE



                                                documentclass{article}
                                                usepackage{booktabs}
                                                begin{document}
                                                begin{figure}
                                                <<xxx, echo=F,dev="tikz", fig.show='hide', fig.width=3, fig.height=3, out.width = "3in", out.height="3in">>=
                                                t <- seq(0,10,.1)
                                                y <- 4*(t-1)*exp(-0.5*t)+8
                                                par(mar=c(4.5,4.5,0.5,0))
                                                plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                                @
                                                begin{minipage}[t]{3in}vspace{0pt}
                                                includegraphics{figure/xxx-1}
                                                end{minipage}hfill%
                                                begin{minipage}[t]{.2linewidth}smallskip
                                                <<echo=F,results='asis'>>=
                                                x <- seq(0,10)
                                                y <- 4*(x-1)*exp(-0.5*x)+8
                                                df <- data.frame(t=x,f=y)
                                                names(df) <- c("t (time)","Function f(t)")
                                                library(xtable)
                                                print(xtable(df,align=rep("c",3)), include.rownames=F,floating=F, booktabs=T)
                                                @
                                                end{minipage}
                                                caption{My function $f(t)=4(t-1)e^{-0.5t}+8$}
                                                end{figure}
                                                end{document}





                                                share|improve this answer














                                                If you know R, then knitr is a simple option:



                                                mwe



                                                documentclass{article}
                                                begin{document}
                                                <<echo=F,dev="tikz",fig.cap="My function $f(t)=4(t-1)e^{-0.5t}+8$", fig.width=5, fig.height=5, out.width = "\linewidth">>=
                                                t <- seq(0,10,.1)
                                                y <- 4*(t-1)*exp(-0.5*t)+8
                                                plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                                @
                                                end{document}


                                                R could also produce the table easily, but place it beside the figure need some tuning of R and LaTeX code:



                                                MWE



                                                documentclass{article}
                                                usepackage{booktabs}
                                                begin{document}
                                                begin{figure}
                                                <<xxx, echo=F,dev="tikz", fig.show='hide', fig.width=3, fig.height=3, out.width = "3in", out.height="3in">>=
                                                t <- seq(0,10,.1)
                                                y <- 4*(t-1)*exp(-0.5*t)+8
                                                par(mar=c(4.5,4.5,0.5,0))
                                                plot(t,y,type='l',col='navy', lwd=3,ylab="f(t)",las=1,frame.plot = F, cex.lab=1.2)
                                                @
                                                begin{minipage}[t]{3in}vspace{0pt}
                                                includegraphics{figure/xxx-1}
                                                end{minipage}hfill%
                                                begin{minipage}[t]{.2linewidth}smallskip
                                                <<echo=F,results='asis'>>=
                                                x <- seq(0,10)
                                                y <- 4*(x-1)*exp(-0.5*x)+8
                                                df <- data.frame(t=x,f=y)
                                                names(df) <- c("t (time)","Function f(t)")
                                                library(xtable)
                                                print(xtable(df,align=rep("c",3)), include.rownames=F,floating=F, booktabs=T)
                                                @
                                                end{minipage}
                                                caption{My function $f(t)=4(t-1)e^{-0.5t}+8$}
                                                end{figure}
                                                end{document}






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 4 hours ago

























                                                answered 7 hours ago









                                                Fran

                                                49.9k6110173




                                                49.9k6110173






























                                                     

                                                    draft saved


                                                    draft discarded



















































                                                     


                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function () {
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f462050%2fplotting-exponential-functions%23new-answer', 'question_page');
                                                    }
                                                    );

                                                    Post as a guest















                                                    Required, but never shown





















































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown

































                                                    Required, but never shown














                                                    Required, but never shown












                                                    Required, but never shown







                                                    Required, but never shown







                                                    Popular posts from this blog

                                                    數位音樂下載

                                                    格利澤436b

                                                    When can things happen in Etherscan, such as the picture below?