4

I'm trying to make a tikz plot of 4*asin(sin(x)/1.33) - 2*x but I can't get it to work. I have the following:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[xmin=0, xmax=1.8, ymin=0, ymax=0.8, axis lines*=middle]
        \addplot[samples=500, smooth] {4*asin(sin(x)/1.33) - 2*x};
    \end{axis}
\end{tikzpicture}
\end{document}

I have read about including r as a paramater for some of these, or using sin(deg(x)) but everything I try isn't working, and all I'm getting a line shooting through my window but it isn't what it should look like.

3
  • Welcome to TEX.SE. Please add a complete Minimal Working Example (documentclass and used packages as well as \begin{document} and \end{document}) that we can copy and test.
    – Unknown
    Commented May 28, 2022 at 23:02
  • Right, I added those. Sorry about that.
    – Box
    Commented May 28, 2022 at 23:10
  • a line shooting through my window, you mean the output PDF? Commented May 29, 2022 at 12:38

3 Answers 3

7

In radians:

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\begin{document}
    \begin{tikzpicture}
\begin{axis}[
    trig format=rad, % <------
    %
    grid,
    axis equal image,
    x=12mm,
    xmin=0, xmax=2*pi,
    %
    domain=0:2*pi,
    xtick={0,pi/4,pi/2,3*pi/4,pi,5*pi/4,3*pi/2,7*pi/4,2*pi},
    xticklabels={0, $\frac{\pi}{4}$,$\frac{\pi}{2}$,$\frac{3\pi}{4}$,$\pi$,
                    $\frac{5\pi}{4}$,$\frac{3\pi}{2}$,$\frac{7\pi}{4}$,$2\pi$},
    tick label style={inner sep=2pt, font=\scriptsize,
                      text height=1.5ex, text depth=0.5ex},
    samples=101,
    no marks
    ]
\addplot +[thick] {4*asin(sin(x)/1.33) - 2*x};
\end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

6

I think your x and y range is too small:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
    \begin{axis}
        \addplot[domain=0:360, smooth] {4*asin(sin(x)/1.33) - 2*x};
    \end{axis}
\end{tikzpicture}
\end{document}

Output

2
  • I wanted it in radians originally, but I'm realizing I probably shouldn't do it that was (just for the proof). So this is probably what I'll use, thank you!
    – Box
    Commented May 28, 2022 at 23:18
  • 1
    @Box If you want radians, please look at Zarko's answer and accept his answer.
    – Unknown
    Commented May 29, 2022 at 1:39
3

Try this:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
        \begin{axis} [axis lines=center,
        xlabel=$x$,
        ylabel=$y$,
        xtick={
            1.5708, 3.14159, 4.7123889, 6.28318
        },
        xticklabels={
            $\pi/2$,$\pi$, $3\pi/2$, $2\pi$
        }]
            \addplot[cyan] [domain=0:2*pi, smooth, line width=2pt] { 4*asin(sin(x*180/pi)/1.33)-2*x*180/pi};
        \end{axis}
    \end{tikzpicture}
\end{document}

Output:

enter image description here

ADD: All units in ratiants and with grids. Code:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
    \begin{tikzpicture}
        \begin{axis} [axis lines=center,
        xlabel=$x$,
        ylabel=$y$,
        ymin=-15.4, ymax=1,
        grid=both,
        grid style={line width=.1pt, draw=gray!15},
        major grid style={line width=.3pt,draw=brown!50},
        minor tick num=5,
        axis line style={-latex},
        ticklabel style={font=\tiny,fill=white},
        ]
        \addplot[cyan] [domain=0:2*pi, smooth, line width=2pt] { pi*(4*asin(sin(x*180/pi)/1.33))/180-2*x};
        \end{axis}
    \end{tikzpicture}
\end{document}

Output:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .