Seite 1 von 1

Anwendung QTikz-Ubuntu

Verfasst: Do 22. Aug 2013, 21:24
von germes
Hallo,

ich bin gerade dabei ein wenig mit QTikz zu probieren. Irgendwie schaffe ich es aber nicht Funktionen wie x^1/3 oder x^-3 zu plotten. Funktioniert das bei QTiks generell nicht oder liegt der Fehler bei mir?
\documentclass[a4paper,draft]{scrartcl}
\usepackage[utf8]{inputenc} 
\usepackage{tikz}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\begin{document}
    
\begin{tikzpicture}
   
 \draw[step=.5cm, very thin, black!20] (-6,-3) grid (10,13);
 \draw[->, thick] (-5,0) -- (7,0) node[right] {$x$};
 \draw[->, thick] (0,0) -- (0,11) node[above] {$f(x)$};

    \foreach \x in {-4,...,-1}
    \draw[] (\x,0) -- (\x,-0.1) node[below] {\x};

    \foreach \x in {7,...,1}
    \draw[] (\x,0) -- (\x,-0.1) node[below] {\x};

    \foreach \y in {10,...,1}
    \draw[] (0,\y) -- (-0.1,\y) node[left] {\y};

\draw[smooth,domain=-3:3] plot(\x,{\x*\x}) node[right] {$f(x)=x^2$}; 
 
\draw[smooth,domain=0:6,samples=150] plot(\x,{sqrt(\x)}) node[right] {$f(x)=\sqrt x =x^\frac{1}{2}$}; 

%\draw[smooth,domain=0:2,samples=150] plot(\x,{pow(\x,0.5)}) node[right] {$f(x)=x^\frac{1}{2}$}; 

\draw[red,dashed] (1,0) -- (1,1) -- (0,1);
\draw[red,dashed] (2,0) -- (2,4) -- (0,4);
\draw[red,dashed] (3,0) -- (3,9) -- (0,9);

\end{tikzpicture}
\end{document}
Gruß germes

Verfasst: Fr 23. Aug 2013, 07:23
von Johannes_B
QTikZ ruft auch nur pdflatex auf, daran kann es also nicht liegen. Der "Fehler" hat einen mathematischen Hintergrund.
In der Dokumentation von tikz/pgf wird für pow beschrieben:
pow(x,y)
\pgfmathpow{x}{y}
Raises x to the power of y. For greatest accuracy y should be an integer. If it is not an integer the actual calculation will be an approximation of $\exp ^{y \ln (x)}$.

pgfMath sagt dir: I cannot calculate the logarithm of `0' ...

Dass sich pgfMath da schwer tut ist sicherlich leicht verständlich. Um diesen Fehler zu umgehen, musst du also lediglich die Domain ein wenig anpassen. Plotte zum Beispiel erst ab 0.1 x.


Beste Grüße
Johannes

Verfasst: So 25. Aug 2013, 21:44
von germes
Hallo Johannes,

vielen Dank für die Antwort.