LaTeX forum ⇒ Graphics, Figures & Tablespgfplots | 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

Postby sachinrajsharma » Sat Nov 24, 2012 5:46 pm

Hi,

I am unable to get the output from the presented code and it is showing some error.
  1. \documentclass[10pt,a4paper]{article}
  2. \usepackage{tikz}
  3. \usepackage{pgfplots}
  4.  
  5. \begin{document}
  6.  
  7. y = sin^{-1}x
  8.  
  9. \begin{tikzpicture}
  10. \begin{axis}[
  11. xmin=-6,
  12. xmax=6,
  13. xlabel={$x$},
  14. ymin=-2,
  15. ymax=2,
  16. ylabel={$y$},
  17. axis x line=middle,
  18. axis y line=middle,
  19. axis line style=<->
  20. ]
  21. \addplot[no marks,blue,<->] expression[samples=100]{sin^{-1}(deg(x))};
  22. \addlegendentry{$y=\csc(x)$};
  23. \end{axis}
  24. \end{tikzpicture}
  25. \end{document}

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


Regards,
Sachin Sharma

Tags:

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Sat Nov 24, 2012 9:02 pm

There are two mistakes in your code.

  1. For in-line math expressions you need to use the corresponding math mode.
    1. $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.
  1. \documentclass[11pt]{standalone}
  2. \usepackage{pgfplots}
  3.  
  4. \begin{document}
  5. \begin{tikzpicture}
  6. \begin{axis}[
  7. xmin=-2,
  8. xmax=2,
  9. xlabel={$x$},
  10. ymin=-3,
  11. ymax=3,
  12. ylabel={$y$},
  13. axis x line=middle,
  14. axis y line=middle,
  15. axis line style=<->
  16. ]
  17. \addplot[domain=-1:1,no marks,blue,<->] gnuplot[samples=100] {asin(x)};
  18. \addlegendentry{$y=\arcsin(x)$};
  19. \end{axis}
  20. \end{tikzpicture}
  21. \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).

Further reading:

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


Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby sachinrajsharma » Sun Nov 25, 2012 4:56 am

Hi,

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

Please help.


Sachin Sharma

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Sun Nov 25, 2012 11:30 am

You should run the example I provided and replace expression by gnuplot.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ 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

Postby sachinrajsharma » Mon Nov 26, 2012 8:16 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

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Mon Nov 26, 2012 10:18 am

sachinrajsharma wrote:[…] Could you please tell me any source wherein I can get the detail study material on drawing arctrigo function. […]

I have done so in my first reply under "Further reading".
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: Bing [Bot] and 7 guests