The below code shows that the graph of function xn is incorrect when n
is even (unless typed as \x*\x
instead of \x^2
). So I'm curious what math formulas are allowed in plot
to make sure that it's correct?
Also I've got an error when trying to use brackets: \draw plot (\x,\x*(1-\x));
.
Package tikz Error: Giving up on this path. Did you forget a semicolon?
What is the syntax for math brackets or it's not allowed at all for plot
function's argument?
The manual pgfmanual v3.1.10 on page 344 gives examples with functions sin(\x) and 0.05*exp(\x). Is there a comprehensive list of math functions, which are valid for latex function plot
? For example, is it possible to draw function (x+1/3)^(1/x)
on interval [1,4]
using plot
(i. e. without using pgfplots
or gnuplot
)?
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[domain=-1:1]
\draw plot (\x,\x*\x);
\draw[red, dashed] plot (\x,\x^2);
\draw[blue] plot (\x,\x*\x*\x*\x);
\draw[green, dashed] plot (\x,\x^4);
\end{tikzpicture}
\end{document}

EDIT.
After reading pgfmanual (p. 1034) I realized that it's safer to use pow(\x,2)
instead of \x^2
(especially for some complicated functions). I mean it might be even safer option than (\x)^2
.
)
in a coordinate expression: You need to protect them. (Similar how you have to protect a]
in an optional argment.) Regarding\x^4
getting into the negative, see another answer. PGFmath is just dumbly expanding\x
before it can be considered a single thing. You will need to use(\x)^4
.