3

How to write y=(x/6)‎^{3/‎7} in TikZ format to plot its graph in the following code?

‎\documentclass{article}‎
‎‎\usepackage{tikz‎}‎ 
‎\begin{document}‎‎
‎‎\begin{tikzpicture}‎
‎\draw ‎[‎smooth,‎samples=100‎,domain=0:‎‎2‎‎] ‎plot(\x,‎‎‎‎‎‎‎{(\x)‎‎‎‎‎‎‎‎‎‎‎‎‎});‎
‎\end{tikzpicture}‎‎
‎\end{document}

5 Answers 5

3

Try the $\exp(\ln(x))$ form:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \draw [smooth,samples=100,domain=0.01:10] plot(\x,{exp(3*ln(\x/6)/7)});
\end{tikzpicture}
\end{document}

Doesn't work in 0, of course...

11

This answer is more of a "did you possibly mean a plot together with its axis?"-answer.

If so, you might be interested in pgfplots; a package built on top of tikz. It can sample with higher accuracy and a considerably higher data range, accepts a very similar syntax as tikz, scales the plot to some prescribed width/height, automatically computes ticks, comes with interfaces like xlabel=the x axis, and is highly customable.

Here is your example with pgfplots:

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\begin{document}
\begin{tikzpicture}
\begin{axis}
    \addplot [smooth,samples=100,domain=0:10] {(x/6)^(3/7)};
% same as:
%\addplot [smooth,samples=100,domain=0:10] plot(x,{(x/6)^(3/7)});
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

1
  • Note that my solution suffers from a bug in TikZ: 0^(3/7) should be 0. I have just fixed it in pgf cvs, will become part of the next stable. The current solution excludes it because it computed 0^x = nan. Aug 24, 2013 at 11:37
7

With tkz-fct or with Tikz + gnuplot the syntaxes are different. gnuplot needs strange notations.

 1) exp(3*log(x/6)/7 log signifies ln
 2) (x/6)**(3./7) ** is used for ^ and 3./7 is used to divide with real numbers

The results are the same in each case.

\documentclass[11pt]{scrartcl} 
\usepackage[utf8]{inputenc}     
\usepackage{tkz-fct}
 \begin{document}  

     \begin{tikzpicture}
      \tkzInit[xmin=0,xmax=10,ymin=0,ymax=2] 
      \tkzGrid 
      \tkzAxeXY 
   %  \tkzFct[color=red,thick,domain=0.001:10,samples=500]{exp(3*log(x/6)/7)}
      \tkzFct[color=red,thick,domain=0:10,samples=200]{(x/6)**(3./7)}
     \end{tikzpicture}  
\end{document} 

with Tikz and gnuplot :

  \draw[color=red,domain=0:10,samples=200]    plot[id=x]   function{(x/6)**(3./7)} ;

enter image description here

6

(I changed domain a bit)

\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \draw [smooth,samples=100,domain=0.01:10] plot(\x,{(\x/6)^(3/7)});
\end{tikzpicture}
\end{document}
3
  • @lohann: Thanks for your answer, but why isn't y=0, when x=0?
    – Sisabe
    Mar 27, 2013 at 16:06
  • This looks like a bug in the pow function for numbers between 0 and 1. Probably the same bug as tex.stackexchange.com/q/31775/15925 Mar 27, 2013 at 16:45
  • Yeah, looks like a bug... :(
    – Iohann
    Mar 27, 2013 at 16:51
3

With PSTricks.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\psset{algebraic,unit=0.5cm,labelFontSize=\scriptscriptstyle,labelsep=2pt,plotpoints=100}
\begin{document}
\begin{pspicture}(-1,-1)(11,2)
    \psparametricplot{0}{10}{t|(t/6)^(3/7)}
    \psaxes{->}(0,0)(-1,-1)(11,2)[$x$,0][$y$,90]
\end{pspicture}
\end{document}
5
  • Thanks PSTricks, I don't need to use \ in the expression. Mar 27, 2013 at 16:45
  • Could you please tell me why the two solutions above (using TikZ and pstricks) are different? In other words, by using TikZ, why isn't y=0, when x=0?
    – Sisabe
    Mar 27, 2013 at 17:15
  • @Sisabe: Because there might be a bug in TikZ (for this case). Mar 27, 2013 at 18:09
  • 1
    @PSTikZ good observation. I have fixed the bug in TikZ CVS; will become part of the next stable. Aug 24, 2013 at 11:36
  • @ChristianFeuersänger: OK. Thanks for fixing it. Aug 24, 2013 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .