Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am plotting a non-linear function -2/3 x^ 3 + x^2-3x+4/3 in the interval [0,1/2], I tried to change the scales to make it look less linear but still looks like a straight line. Any suggestions?

\usepackage{tikz}
\begin{figure}
\begin{tikzpicture}[xscale=5,yscale=3,domain=0:1,step=.01];
\draw[<->] (0,1.5)--(0,-.3);
\draw[<->] (-.3,0)--(1,0);
\draw[] (1,0) node[right]{\small $x$};
\draw[color=blue]   plot[samples=200] (\x,{ifthenelse(\x <.5,-(2/3)*\x^3+\x^2-3*\x+4/3,(2/3)*\x^3-\x^2+3*\x-4/3))}) node[right] {\small{$b(x)$}};
\draw[color=red] (-.2,0.635) node[right]{$\beta$};
\draw[color=red] (0,0.635)--(1,0.635);
\draw[color=red,dotted,thick](.25,-.3)--(.25,0.635);
\draw[color=red,dotted,thick](.75,-.3)--(.75,0.635);
\draw[color=red](.25,-.3)node[below]{\footnotesize{$\phi_1(\beta)$}};
\draw[color=red](.75,-.3)node[below]{\footnotesize{$\phi_2(\beta)$}};
\end{tikzpicture} 
\end{figure}
share|improve this question
    
Welcome to tex.stackexchange.com. I edited your question by indenting your code by 4 spaces, so that it gets formatted correctly. –  Yori Apr 17 at 15:40
    
@Yori: thanks! I went to other posts to see why my code was muddled but by the time I started editing it, you had already fixed it. –  Sergio Parreiras Apr 17 at 15:41
1  
Also, we usually ask for a minimum working example (MWE) which highlights the core of the problem. Your example (a) does not compile and (b) seems to have a lot of code that is irrelevant for the question. You have a better chance of getting a good answer by removing the irrelevant code. –  Yori Apr 17 at 15:43

2 Answers 2

up vote 2 down vote accepted

PSTricks can help to analyze the graph.

Because in the given interval 0 <= x <= 1/2 the function f(x)=(-2*x^3+3*x^2-9*x+4)/3 is almost identical to the line g(x)=(-8*x+4)/3 passing (0,f(0)) and (1/2,f(1/2)) as shown in the following figure.

\documentclass[pstricks,border=24pt]{standalone}
\usepackage{pst-plot}

\def\f{(-2*x^3+3*x^2-9*x+4)/3}
\def\g{(-8*x+4)/3}
\begin{document}
\begin{pspicture}[algebraic](1,1.5)
    \psaxes{->}(0,0)(0,0)(.75,1.25)[$x$,0][$y$,90]
    \psset{linewidth=.4pt}
    \psplot[linecolor=red]{0}{.5}{\f}
    \psplot[linecolor=blue]{0}{.5}{\g}
    \psplot[linecolor=green]{0}{.5}{abs(\f-\g)}
\end{pspicture}
\end{document}

enter image description here

  • The red is the graph of f(x)=(-2*x^3+3*x^2-9*x+4)/3.
  • The blue is the graph of g(x)=(-8*x+4)/3.
  • The green is the graph of |f(x)-g(x)|.

That is why scaling will not help.

share|improve this answer

I would say you can't because your interval is too small.

See how the plot looks in wolfram alpha using small axis limits.

https://www.wolframalpha.com/input/?i=-2%2F3+x%5E+3+%2B+x%5E2-3x%2B4%2F3+on+interval+0+to+0.5

Image generated from wolframalpha

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.