I'm new to both tikz and pgfplots, and I am having trouble getting an image of the functions f(n) = 2n^2 and g(n) = 50*n*log2(n) on the same plot. I want the domain to go from n=1 to n=1000, and I don't care too much about the y-axis, as long as it shows both of the plots. I also would like to mark the coordinate for the point of intersection.

I have been struggling to do this so far, and I keep on getting errors left and right.

This is what I have right now, but even this is giving me a warning.


\begin{axis}[xmax=9,ymax=9, samples=50]
  \addplot[blue, ultra thick] (x,2*x*x);
  \addplot[red,  ultra thick] (x,log2(x));


I know that this isn't much, but I was wondering if someone can please help me with this, or at least guide me in the right direction. I've been just copy and pasting LaTeX code from other TeXSE posts, and I've been trying to modify them to get them to work. But it seems like I can't do that without getting lots of errors.

Thank you

  • could you make your script compilable? – Raaja Sep 6 '19 at 9:06
  • Sure. I think it's the log2(x) part that's messing it up. Let me add everything. – hama Sep 6 '19 at 9:07
  • might help: tex.stackexchange.com/questions/444375/… – Raaja Sep 6 '19 at 9:08
  • 3
    Don't mix tikz and pgfplots syntax. Try: \documentclass[11pt]{scrartcl} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[xmax=9,ymax=9, samples=50] \addplot[blue, ultra thick] {2*x*x}; \addplot[red, ultra thick] {log2(x)}; \end{axis} \end{tikzpicture} \end{document} – Zarko Sep 6 '19 at 10:41
  • How can I get the intersections marked? – hama Sep 6 '19 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.