## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ pgfplots | Arcsine Function Graph

Information and discussion about graphics, figures & tables in LaTeX documents.
sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am

### pgfplots | Arcsine Function Graph

Hi,

I am unable to get the output from the presented code and it is showing some error.
\documentclass[10pt,a4paper]{article}\usepackage{tikz}\usepackage{pgfplots} \begin{document} y = sin^{-1}x \begin{tikzpicture}     \begin{axis}[       xmin=-6,       xmax=6,       xlabel={$x$},       ymin=-2,       ymax=2,       ylabel={$y$},       axis x line=middle,       axis y line=middle,       axis line style=<->     ]       \addplot[no marks,blue,<->] expression[samples=100]{sin^{-1}(deg(x))};       \addlegendentry{$y=\csc(x)$};     \end{axis}   \end{tikzpicture}\end{document}

Please guide whether it is correct code to draw inverse trigonometric function graphs .

Regards,
Sachin Sharma

Tags:

localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany
There are two mistakes in your code.

1. For in-line math expressions you need to use the corresponding math mode.
$y = \sin^{-1}x$

But this is usually written with the respective math operator as $y=\arcsin(x)$.
2. The corresponding expression for plotting is asin(x) in the actual plot command.

The corrected example.
\documentclass[11pt]{standalone}\usepackage{pgfplots} \begin{document}   \begin{tikzpicture}     \begin{axis}[       xmin=-2,       xmax=2,       xlabel={$x$},       ymin=-3,       ymax=3,       ylabel={$y$},       axis x line=middle,       axis y line=middle,       axis line style=<->     ]       \addplot[domain=-1:1,no marks,blue,<->] gnuplot[samples=100] {asin(x)};       \addlegendentry{$y=\arcsin(x)$};     \end{axis}   \end{tikzpicture}\end{document}

Notes:

• Since pgfplots is not exact enough here, let Gnuplot do the job of calculating the arcsine function (see above).
• The domain has to be restricted to [-1,1] (see above).

Remarks:

• Please get used to dropping irrelevant erroneous code because it distracts from the actual problem (see point #1 above).

• The PGF manual (regarding allowed mathematical expressions and functions)

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am
Hi,

It is still showing the following error :
! Missing number, treated as zero.<to be read again>                     \pgfmath@acos@5000 l.19 ...lue,<->] expression[samples=100]{asin(x)};

Sachin Sharma

localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany
You should run the example I provided and replace expression by gnuplot.
LaTeX Community Moderator

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

sachinrajsharma
Posts: 35
Joined: Sun Apr 08, 2012 5:48 am
Hi,
Thanks for your guidance , however i am still not getting the output. Could you please tell me any source wherein I can get the detail study material on drawing arctrigo function.

Thanks on this.

Regards,

Sachin

localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany
sachinrajsharma wrote:[…] Could you please tell me any source wherein I can get the detail study material on drawing arctrigo function. […]