Plotting exponential functions
up vote
5
down vote
favorite
Can anyone give me a clue on how to plot this function:
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
add a comment |
up vote
5
down vote
favorite
Can anyone give me a clue on how to plot this function:
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
1
How would anyone know what's wrong with your code if you do not reveal it?
– marmot
16 hours ago
1
Add a minimum working example of what you have tried so far.
– nidhin
16 hours ago
since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
15 hours ago
There must be some code that causesTeX capacity exceeded, sorry
, right?
– marmot
15 hours ago
add a comment |
up vote
5
down vote
favorite
up vote
5
down vote
favorite
Can anyone give me a clue on how to plot this function:
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
Can anyone give me a clue on how to plot this function:
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
plot
edited 15 hours ago
asked 16 hours ago
writzlpfrimpft
383
383
1
How would anyone know what's wrong with your code if you do not reveal it?
– marmot
16 hours ago
1
Add a minimum working example of what you have tried so far.
– nidhin
16 hours ago
since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
15 hours ago
There must be some code that causesTeX capacity exceeded, sorry
, right?
– marmot
15 hours ago
add a comment |
1
How would anyone know what's wrong with your code if you do not reveal it?
– marmot
16 hours ago
1
Add a minimum working example of what you have tried so far.
– nidhin
16 hours ago
since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
15 hours ago
There must be some code that causesTeX capacity exceeded, sorry
, right?
– marmot
15 hours ago
1
1
How would anyone know what's wrong with your code if you do not reveal it?
– marmot
16 hours ago
How would anyone know what's wrong with your code if you do not reveal it?
– marmot
16 hours ago
1
1
Add a minimum working example of what you have tried so far.
– nidhin
16 hours ago
Add a minimum working example of what you have tried so far.
– nidhin
16 hours ago
since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
15 hours ago
since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
15 hours ago
There must be some code that causes
TeX capacity exceeded, sorry
, right?– marmot
15 hours ago
There must be some code that causes
TeX capacity exceeded, sorry
, right?– marmot
15 hours ago
add a comment |
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}
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}
Note that you can also generate the table in a foreach
loop, but I am not going to spell this out here.
add a comment |
up vote
3
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}
add a comment |
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}
add a comment |
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}
add a comment |
up vote
2
down vote
If you know R
, then knitr
is a simple option:
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:
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}
add a comment |
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}
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}
Note that you can also generate the table in a foreach
loop, but I am not going to spell this out here.
add a comment |
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}
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}
Note that you can also generate the table in a foreach
loop, but I am not going to spell this out here.
add a comment |
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}
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}
Note that you can also generate the table in a foreach
loop, but I am not going to spell this out here.
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}
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}
Note that you can also generate the table in a foreach
loop, but I am not going to spell this out here.
edited 11 hours ago
answered 16 hours ago
marmot
78.7k487166
78.7k487166
add a comment |
add a comment |
up vote
3
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}
add a comment |
up vote
3
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}
add a comment |
up vote
3
down vote
up vote
3
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}
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}
answered 14 hours ago
Herbert
266k23404713
266k23404713
add a comment |
add a comment |
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}
add a comment |
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}
add a comment |
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}
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}
answered 13 hours ago
Bernard
162k767192
162k767192
add a comment |
add a comment |
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}
add a comment |
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}
add a comment |
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}
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}
edited 14 hours ago
answered 14 hours ago
Franck Pastor
15.5k13459
15.5k13459
add a comment |
add a comment |
up vote
2
down vote
If you know R
, then knitr
is a simple option:
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:
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}
add a comment |
up vote
2
down vote
If you know R
, then knitr
is a simple option:
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:
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}
add a comment |
up vote
2
down vote
up vote
2
down vote
If you know R
, then knitr
is a simple option:
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:
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}
If you know R
, then knitr
is a simple option:
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:
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}
edited 7 hours ago
answered 10 hours ago
Fran
49.9k6110173
49.9k6110173
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
How would anyone know what's wrong with your code if you do not reveal it?
– marmot
16 hours ago
1
Add a minimum working example of what you have tried so far.
– nidhin
16 hours ago
since i was just experimenting with some packages, there isn't much code to show
– writzlpfrimpft
15 hours ago
There must be some code that causes
TeX capacity exceeded, sorry
, right?– marmot
15 hours ago