1

I need to draw the function f(x) = -5/16x^4 + 3/4x^3 + 1, and I have no clue how to do that.

I've done something similar to what I need like this:

\draw[thick,color=blue] plot[samples=50, domain=-1.4:1.8] (\x,{(\x)^3-(\x)^2+1}) node[right] {$f(x) = x^3 - x^2 + 1$};

but it doesn't help to handle the following function. Here is the figure which is plotted by another program.

enter image description here

Speedy
  • 11
  • 1
    Welcome to TeX.SE! Please show us the code you tried so far. – Mensch Jun 13 '17 at 21:58
  • 1
    Have a look at pgfplots (see for example https://tex.stackexchange.com/a/78383/586). And remember that you need to explicitly write the multiplication symbol, e.g. 2*x and not 2x. – Torbjørn T. Jun 13 '17 at 22:07

1 Answers1

1
  • Your function mentioned in code snippet differ from function shown on figure in your question. I MWE below consider the first one, however is not difficult to change it.
  • In my MWE below I use package pgfdplots version v1.14.
  • minimal x value is select so, that the function equation can fit in diagram.

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

\begin{document}
\begin{tikzpicture}
\begin{axis}[
ticklabel style={fill=white, font=\footnotesize},
xmin=-5, xmax=3, xlabel={$x$}, xtick={-5,...,3},
ymin=-5, ymax=3, ylabel={$y$}, ytick={-5,...,3},
grid,
 axis lines=middle
]
\addplot[blue, very thick, samples=50, domain=-2:1.8] {(x)^3 -(x)^2 + 1};
\node[below right, fill=white, text=blue] at (-4,3) {$f(x) = x^3 - x^2 + 1$};
\end{axis}
\end{tikzpicture}
\end{document}

![enter image description here

In case, that you like to have second equation, than adequately change lines \addplot ... and \node .... You also can put axis on the top and enlarge graph width and function domain as follows:

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

\begin{document}
\begin{tikzpicture}
\begin{axis}[
width=88mm,
ticklabel style={fill=white, inner xsep=1pt, font=\footnotesize},
xmin=-5, xmax=4, xlabel={$x$}, xtick={-5,...,4},
ymin=-5, ymax=3, ylabel={$y$}, ytick={-5,...,3},
set layers = axis on top,
axis lines = middle,
grid=both,
]
\addplot[blue, very thick, samples=50, domain=-2:4] {-5*(x^4)/16 + 3*(x^3)/4 + 1};
\node[below right, inner xsep=0pt, fill=white, text=blue] at (-5,3) 
    {$f(x) = -\frac{5}{16}x^4 + \frac{3}{4}x^3 + 1$};
\end{axis}
\end{tikzpicture}
\end{document}

and the graph will become:

![enter image description here

Zarko
  • 296,517