9

inverse of Gamma function while x to the infinite by Maple

I want to plot Gamma function and reciprocal of that but I am beginner in Latex. Please help me!

0
10

The Gamma function is not defined for negative integer. The reason why I used a \multido here. Run the example with xelatex:

\documentclass[pstricks,border=12pt]{standalone}  
\usepackage{pst-plot}
\begin{document}

\psset{yunit=0.75}
\begin{pspicture}(-5,-5)(5,5)
  \psaxes{->}(0,0)(-4.5,-4.5)(4.5,4.5)
  \multido{\rA=-3.999+1.000}{8}{%
    \psplot[linewidth=1.5pt,linecolor=red,
          plotpoints=500,algebraic]{\rA}{\rA\space 0.9999 add}{ 1/GAMMA(x) }}
\end{pspicture}
\end{document}

enter image description here

9

Here's two other possibilities: sagetex with Sage output (easiest) or sagetex with pgfplots (more complicate). You need Sage installed on your computer or use SagemathCloud to avoid having Sage on your computer.

\documentclass{article}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{pgfplots}
\usepackage{sagetex}
\usetikzlibrary{spy}
\usetikzlibrary{backgrounds}
\usetikzlibrary{decorations}
\pagestyle{empty}
\begin{document}
The easiest way to plot with Sage using its output.
\begin{sagesilent}
from sage.functions.other import gamma1
P = plot(1/gamma1(x),(x,-4.25,4.25),ymin=-4)
Q = text("1/$\Gamma(x)$", (4,1), alpha=0.3, fontsize='large', fontweight='extra bold', color='blue')
\end{sagesilent}
\begin{center}
\sageplot[width=4in]{P+Q}
\end{center}

If you want output plotted with pgfplots then more work is required.
\begin{sagesilent}
LowerX = -4.25
UpperX = 4.25
LowerY = -4.25
UpperY = 4.25
step = .01
Scale = 1.0
xscale=1.0
yscale=1.0
output = r""
output += r"\begin{tikzpicture}"
output += r"[line cap=round,line join=round,x=8.75cm,y=8cm]"
output += r"\begin{axis}["
output += r"grid = none,"
output += r"minor tick num=4,"
output += r"every major grid/.style={Red!30, opacity=1.0},"
output += r"every minor grid/.style={ForestGreen!30, opacity=1.0},"
output += r"height= %f\textwidth,"%(yscale)
output += r"width = %f\textwidth,"%(xscale)
output += r"thick,"
output += r"black,"
output += r"axis lines=center,"
output += r"domain=%f:%f,"%(LowerX,UpperX)
output += r"line join=bevel,"
output += r"xmin=%f,xmax=%f,ymin= %f,ymax=%f,"%(LowerX,UpperX,LowerY, UpperY)
#output += r"xticklabels=\empty,"
#output += r"yticklabels=\empty,"
output += r"major tick length=5pt,"
output += r"minor tick length=0pt,"
output += r"major x tick style={black,very thick},"
output += r"major y tick style={black,very thick},"
output += r"minor x tick style={black,thin},"
output += r"minor y tick style={black,thin},"
#output += r"xtick=\empty,"
#output += r"ytick=\empty"
output += r"]"
##FUNCTION 1
from sage.functions.other import gamma1
P = plot(1/gamma1(x),(x,-4.25,4.25),ymin=-4)
t1 =  var('t1')
x1_coords = srange(LowerX,UpperX,step)
y1_coords = [(1/gamma1(t1)).n(digits=6) for t1 in x1_coords]
output += r"\addplot[thin, NavyBlue, unbounded coords=jump] coordinates {"
for i in range(0,len(x1_coords)):
    if (y1_coords[i])<LowerY or (y1_coords[i])>UpperY:
        output += r"(%f,inf) "%(x1_coords[i])
    else:
        output += r"(%f,%f) "%(x1_coords[i],y1_coords[i])
output += r"};"
output += r"\addlegendentry{$\frac{1}{\Gamma(x)}$}"
##### COMMENT OUT A LINE OF SAGESILENT BY STARTING WITH #
output += r"\end{axis}"
output += r"\end{tikzpicture}"
\end{sagesilent}
\begin{center}
\sagestr{output}
\end{center}
\end{document}

Which gives this output in Sagemath Cloud: enter image description here Note that the first plot (using Sage and sagetex) is created by the code in the first sagesilent environment. The gamma function is part of Sage code. The documentation is here.

3
5

Asymptote version:

// gammaplot.asy:
//
settings.tex="pdflatex";
import graph;
size(9cm,7cm);
import fontsize;defaultpen(fontsize(9pt));
texpreamble("\usepackage{lmodern}");
pen linePen=darkblue+0.9bp;
arrowbar arr=Arrow(HookHead,size=2);
real xmin=-4,xmax=4.4;
real ymin=-1.4,ymax=4.4;
xaxis(xmin,xmax,RightTicks(Step=1,step=0.5,OmitTick(0)),arr);
yaxis(ymin,ymax,LeftTicks(Step=1,step=0.5,OmitTick(0)),arr);
real f(real x){return 1/gamma(x);}
real eps=1e-5; // to avoid Floating point exception
draw(graph(f,xmin+eps,xmax,n=400),linePen,arr);
label("$1/\Gamma(x)$",(3,f(3)),plain.NE);
//
// run `asy gammaplot.asy` to get `gammaplot.pdf`

enter image description here

3

If you have gnuplot installed you can use it with pgfplots:

% arara: pdflatex: { shell: on }
\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
  \begin{axis}[axis lines=middle,xtick={-4,...,4},ytick={-4,...,4}]
    \addplot[domain=-4.1:4,red,samples=100] gnuplot {1/(gamma(x))} ;
    \node at (axis cs:3.4,.75) {$1/\Gamma(x)$};
  \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.