TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It is easy to plot arctan and arccot, but got inverse sec and csc functions, It seems difficult. Can anyone do it?

share|improve this question

migrated from math.stackexchange.com Jul 30 '14 at 4:47

This question came from our site for people studying math at any level and professionals in related fields.

Welcome to TeX.SX! Please show us the complete but minimal code of how you are plotting an arctan-function. Like this we will know, what packages you are using and we do not have to type everything in order to add one function. Thanks. – LaRiFaRi Jul 30 '14 at 6:37

Using the pgfplots package, which makes plotting with TikZ easy, something as simple as

  \begin{axis}[domain = -1:1, samples = 500]
    \addplot[color = red]  {asin(x)};
    \addplot[color = blue] {acos(x)};

works nicely

enter image description here

Notice that you need to restrict the domain of the function to something sensible ([-1,1]) and to get a smooth curve to have enough samples (points calculated in the range used). Also notice that the PGF maths engine works in degrees: you could of course convert the y-axis to radians if required (the question does not specify this).

For e.g. inverse secant the obvious apporach is to use standard identities (see for example http://en.wikipedia.org/wiki/Arcsecant) and to again pick appropriate domains but in 'parts'. For example

  \begin{axis}[samples = 500]
    \addplot[domain = -10:-1, color = red] {acos(1/x)};
    \addplot[domain = 1:10, color = red]   {acos(1/x)};


enter image description here

which is a plot of the inverse secant function over a hopefully-useful range.

share|improve this answer
Thank you! Just hope one day we can plot directly by using tikz... – user145722 Jul 30 '14 at 10:05
@user145722 It's not unique to PGF that the end user is expected to use some identities to use more 'advanced' trigonometric functions based on more 'basic' ones (for example, my calculator will handle sine/cosine/tangent happily but not secant!). – Joseph Wright Jul 30 '14 at 11:44
We do have asec and acsc in LaTeX3's l3fp, since it wasn't too hard to add. – Bruno Le Floch Jul 31 '14 at 7:17
@BrunoLeFloch I'm sure we do :-) My point was that it's not anything like as much as a necessity as cos/sin/tan and the inverses. – Joseph Wright Jul 31 '14 at 7:19

This answer was prepared for you long time ago.



\FPeval\XOL{0-1/3} % of DeltaX
\FPeval\XOR{1/3} % of DeltaX
\FPeval\YOB{0-1/3} % of DeltaY
\FPeval\YOT{1/3} % of DeltaY







    \color{NavyBlue}\rule{12pt}{1pt} & \color{NavyBlue} $y=\sec^{-1} x$\\
    \color{Red}\rule{12pt}{1pt} & \color{Red} $y=\cos^{-1} x$
        ticksize=-3pt 3pt,
        xticksize=\YMin\space \YMax,
        yticksize=\XMin\space \XMax,

enter image description here


enter image description here

No need to load pst-math as pst-plot has defined the following functions.

  • sin, cos, tan, acos, asin are in radians
  • log, ln
  • ceiling, floor, truncate, round
  • sqrt (square root)
  • abs (absolute value)
  • fact (factorial)
  • Sum
  • IfTE (case structure)
share|improve this answer
XOR, XOL, YOT, YOB are offsets which are multiple of DeltaX and DeltaY, respectively. They are important to make the axes look more exotic (IMHO). – kiss my armpit Jul 30 '14 at 14:49
Please, never use \sec^{-1} and \cos^{-1} since there are no inverses of these functions. As a mathematician, my heart is missing a beat every time I see something like that. You should use \arcsec and \arccos instead. Sorry for nitpicking, but I'm caring for my health ... ;-) – Thomas F. Sturm Jul 31 '14 at 6:36
@ThomasF.Sturm: But if we restrict its domain then the inverse is available. As a layman, I have no idea what \arcsec (and arccos) differs from \sec^{-1} (and \cos^{-1}), could you elaborate more? In my mind, they are just different in notation. Probably you are talking about reciprocal rather than inverse. :-) – kiss my armpit Jul 31 '14 at 6:42
Yes, if we restrict the domain, then there is an inverse. But restricting the inverse means creating a new function which differs from the old function by its domain of definition. That's why it's called arccos because it's defined as inverse of the restricted cos (not of cos defined on the set of real numbers which is the usual domain). I use to torture my students with that difference ;-) – Thomas F. Sturm Jul 31 '14 at 8:28
By chance, somebody stumbled over this point today, i.e. that sin has no inverse. See my answer tex.stackexchange.com/questions/194204/… – Thomas F. Sturm Aug 1 '14 at 6:47

Needs an up-to-date pst-math.pro (TL 2014) or replace ASEC(x) with ACOS(1/x) and ACSC(x) with ASIN(1/x)




Run it with xelatex or latex->dvips->ps2pdf

enter image description here

share|improve this answer
Thanks, actually I am trying to not use dvips->ps2pdf, just use PDFLatex. Eps figures driving me crazy. So that why I am trying to use PDFLatex for everything. Tikz works well with PDFLatex – user145722 Jul 30 '14 at 10:12
As I already mentioned use xelatex it has some more advantages than pdflatex – Herbert Jul 30 '14 at 10:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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