# How to create my own function Derivative?

I want to create my own function derivative Derivada. So, I already set some properties like:

Derivada[x_^n_, x_Symbol] := n*x^(n - 1)


How can I make a derivative of a polynomial fuction like:

Derivada[x^2 + 3 x, x]


Or:

Derivada[x^3 + x^2 + 3 x, x]


Another question:

How can I set to zero if I want to derive f[x] with respect to y for example.

And about the Chain Rule? How can I set this? For exemplo: Ho to derive

Exp[3x]


Or

Sqrt[3x+1]


Here are some modified definitions you might find worth understanding

Derivada[x_^n_., x_Symbol] /; FreeQ[n, x] := n*x^(n - 1)
Derivada[f_, x_Symbol] /; FreeQ[f, x] := 0

Derivada[x^3 + x^2 + 3 x, x]
(* 3 + 2 x + 3 x^2 *)

(* 0 *)

• Why there is a dot . after n_ at Derivada[x_^n_., x_Symbol] /; FreeQ[n, x] := n*x^(n - 1)? Aug 30, 2018 at 19:24
• See the help for Optional. It matches x as well as x^n, reducing the number of definitions needed. Aug 30, 2018 at 19:29
• And about the Chain Rule? How can I set this? For exemplo: Ho to derive Exp[3x] or Sqrt[3x+1] Aug 30, 2018 at 20:57

You can approach this is the same kind of way you are trying above:

Derivada[z__ + y__, x_] := Derivada[z, x] + Derivada[y, x];