1

I 'm trying to draw the plot of f(x)=sin(1/x) with pgfplot, but I get an error message:

! TeX capacity exceeded, sorry [main memory size=3000000].

I realized that when I delete one of the packages marked with %!!! in my code, everything is all right. This is the log-file.

What is going wrong?

\documentclass[a4paper,11pt,twoside]{book}
\usepackage[a4paper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage[english,greek]{babel}
\usepackage[utf8]{inputenc}

\usepackage{siunitx}%!!!
\usepackage{mathtools}%!!!
\usepackage{subcaption}%!!!
\usepackage[most]{tcolorbox}%!!!
\usepackage{fancybox}%!!!
\usepackage{wasysym}%!!!    

\usepackage{pgfplots}
\pgfplotsset{compat=1.16}   

\usepackage{tikz}
\usetikzlibrary{shapes,snakes}%!!!
\usetikzlibrary{shadows.blur}%!!!
\usetikzlibrary{decorations.text}%!!!
\usetikzlibrary{calc,patterns,angles,quotes,decorations.pathreplacing}%!!!
\usetikzlibrary{spy}%!!!
\usetikzlibrary{positioning,shapes,fit,arrows}%!!!

\begin{document}

\begin{center}
    \begin{tikzpicture}[>=latex]
    \begin{axis}[
    axis x line=center,
    axis y line=center,
    xlabel={$x$},
    ylabel={$y$},
    xlabel style={below right},
    ylabel style={above left},
    xmin=-1.5,
    xmax=1.5,
    ymin=-1.2,
    ymax=1.2,
    ticks=none,
    height=0.3\textwidth,
    width=0.6\textwidth,]
    \addplot[domain=0.01:1.5, thin,samples=5000] {sin(deg(1/(x)))};
    \addplot[domain=-1.5:-0.01, thin,samples=5000] {sin(deg(1/(x)))};
    \node at (axis cs:1.4,0.8) {$C_f$} ;
        \end{axis}
        \end{tikzpicture}   
\end{center}

\end{document}

Thanks in advanced!!!

  • For me it works fine, with no errors. I could create the bi-directional chirp-like signal without any issues. My TeX distribution is This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6880 64-bit) (preloaded format=pdflatex 2018.12.6) 14 MAR 2019 11:55. Please add your TeX distribution. Please see here: https://imgur.com/a/2PioUke – Raaja_is_at_topanswers.xyz Mar 14 '19 at 10:57
  • @Raaja thank's for your answer! My TeX distribution is This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.6960 64-bit) (preloaded format=pdflatex 2019.2.10) 14 MAR 2019 11:30 – Kώστας Κούδας Mar 14 '19 at 11:01
  • 2
    For me it also compiles using TeX Live 2018 frozen. Are you sure all packages are up to date? both as user and admin? – daleif Mar 14 '19 at 11:04
  • @daleif you are almost right about the updating. I just update miktex's packages (with miktex console, so there wasn't any option for admin or user) and the code is OK. But, when 1) I change 0.6\textwidth to 0.8\textwidth or 2) I use this code to the book that I write, I have the same problem... – Kώστας Κούδας Mar 14 '19 at 11:25
  • 2
    MikTeX console can update as both user and admin, see https://miktex.org/howto/miktex-console under "Operation Mode", you need to update both, as the user part (the default) only updates the packages you installed – daleif Mar 14 '19 at 11:30
  • 1
    It is a common problem that plots with too many points (or where too many things need to be calculated) can cause TeX to run out of memory. You could switch to LuaTeX, which has dynamic memory allocation and should not run out of memory that quickly (of course memory is still limited by your hardware), you could think about externalising the picture (cf. https://tex.stackexchange.com/q/398753/35864, if it compiles in a smaller document at all) or just produce the graph with an external application. Of course you could also choose a smaller samples value: 5000 is a lot. – moewe Mar 14 '19 at 11:30
  • 2
    The document compiles for me, but it uses 2999187 words of memory. If your miktex has only 3000000 reserved that's quite near the exhaustion point. You should enlarge the memory. – Ulrike Fischer Mar 14 '19 at 12:43
  • @daleif , I can't find how to change "Operation Mode". At the place that is writing "Operation Mode" in miktex console is also writing "you have installed miktex for your private use". – Kώστας Κούδας Mar 14 '19 at 22:46
  • @UlrikeFischer I 'm sorry, but I have no idea how to enlarge the memory, and I didn't manage to understand from the sites that I visited. Have you got a link with a simple example? – Kώστας Κούδας Mar 14 '19 at 22:51
  • @moewe 1) Do you mean "LuaLaTeX"? I have problems for now for this switching. 2) Smaller samples make the plot clearly not correct. 3) I have no idea how to externalising the picture, and I didn't manage to understand from pgfplot-manual. Have you got a link with a simple example? – Kώστας Κούδας Mar 14 '19 at 22:56
  • 2
    See https://tex.stackexchange.com/a/438911/2388. Exchange all occurences of xelatex by pdflatex. – Ulrike Fischer Mar 15 '19 at 08:22

0 Answers0