I'd like to define an custom function f(x).
For example
\f{3}
should println(3) + 3
if the function is set toln(x) + 3
.One should be able change the function:
\setfunc{sin(\x}}
.This should only affect future uses of
\f{...}
And it should be possible to define the first three derivatives..
The commands do not have do be this way. There may be a more elegant/practical way. Warning: It should work in this environment: https://tex.stackexchange.com/a/299720/101053
Edit: Changed derivate to derivative; It's unclear what "define the derivative" should mean. I tried to say that I can simply add other functions (whether derivative or nor).
\func{n}
for the function,\func[1]{n}
for the first or derivative,\func[2]{n}
for the second order derivative, ...\setfunc{}{}{}{}
. I don't see how TeX can be expected to figure out the derivatives automatically. (Unless you restrict the set of possible functions so that they can be handled by an automatic algorithm, say.)