3

Is it possible to define new functions in tkz-fct and use them to plot using \tkzFct?

student
  • 29,003
  • Sorry but my english is not very fine, you want define new functions or new macros ? If you want new mathematic functions, you need to create them like with tikz. In the cvs version of Tikz I create some new functions for arithmetics integers. If you can complete your question, I give you a more complete answer. – Alain Matthes May 24 '11 at 17:56
  • Yes I want new mathematical functions – student May 24 '11 at 18:21
  • What kind of functions ? – Alain Matthes May 24 '11 at 21:11

2 Answers2

4

You can define new functions using \pgfmathdeclarefunction. For example, the following defines a gaussian function that can be used in TikZ:

\documentclass{article}
\usepackage{tikz}

\pgfmathdeclarefunction{gauss}{3}{%
      \pgfmathparse{1/(#3*sqrt(2*pi))*exp(-((#1-#2)^2)/(2*#3^2))}%
    }

\begin{document}
\begin{tikzpicture}
\draw [help lines] (-2,0) grid [step=0.5] (2,1);
\draw plot [domain=-2:2,samples=40] (\x,{gauss(\x,0,0.5)});
\end{tikzpicture}
\end{document}

gaussian function

Jake
  • 232,450
1

You need to read the pgfmanual. 66 Customizing the Mathematical Engine

You can also read the code of pgf . For example, I contribute for pgfmathfunctions.integerarithmetics.code.tex and the code is not very complex .

Alain Matthes
  • 95,075