Let $(S,+,\cdot)$ be a semiring; a derivation on $S$ is a map $\partial : S \to S$ that is linear and Leibniz, in the sense that


1. It is a semigroup homomorphismm with respect to $+$;
2. $\partial(a\cdot b)=\partial a\cdot b+a\cdot\partial b$.


Now, assume that $g\in S$ has a multiplicative inverse; what is the derivative of $g^{-1}$, considering that $-\frac{\partial g}{g^2}$ might not exist?



What is the derivative of $1/g$ in a differential semiring?
This is not an answer, but is too long for a comment.


It was already mentioned in the [comments](https://mathoverflow.net/questions/379652/what-is-the-derivative-of-1-g-in-a-differential-semiring#comment963953_379652) under the OP that, if $\partial$ is a derivation on a (commutative or non-commutative) semiring $S$ with $\partial 1\_S = 0\_S$, then the "usual formula" for the derivative of a multiplicative unit $u$ carries over as expected; namely, $\partial u$ is an additive unit and we have $\partial u^{-1} = -u^{-1} \cdot \partial u \cdot u^{-1}$. Otherwise, $\partial 1\_S$ is still an idempotent element of the additive monoid of $S$, which motivates the following observations:


(i) If $\partial$ is a derivation on a commutative semiring $S$ and $e$ is an idempotent of the additive monoid of $S$, then the function $\partial\_e \colon S \to S \colon x \mapsto \partial x + ex$ is also a derivation on $S$. In particular, note that


$$
\partial\_e(xy) = (x\partial y + y \partial x) + (xye + xye) = x (\partial y + ye) + y (\partial x + xe) = x \partial\_e y + y \partial\_e x,
$$
for all $x, y \in S$; that is, $\partial\_e$ is Leibniz.


(ii) Let $S$ be an idempotent commutative semiring ("idempotent" means that $x = x+x$ for every $x \in S$). It is easily seen that the function $\partial\_e \colon S \to S \colon x \mapsto xe$ is a derivation on $S$ for each $e \in S$; this is, in fact, a special case of the construction considered under item (i), with $\partial$ the trivial derivation on $S$. Moreover, $\partial\_e u^{-1} = u^{-1} e = u^{-2} \partial\_e u$ for every multiplicative unit $u \in S$ (this looks similar to the "usual formula" for the derivative of a multiplicative unit: I don't like to have a good explanation for the "coincidence", but I don't). Note, though, that the only unit of $(S, +)$ is $0\_S$.


(iii) For a concrete example, let $S$ be the [min-plus semiring](https://en.wikipedia.org/wiki/Tropical_semiring) $(\mathbf R \cup \{+\infty\}, \oplus, \otimes)$, where the operations are defined by $x \oplus y := \min(x,y)$ and $x \otimes y := x + y$ for all $x, y \in \mathbf R \cup \{+\infty\}$. This is an idempotent commutative semiring whose multiplicative identity is $0$ and whose group of (multiplicative) units is $\mathbf R$. So, the construction considered under item (ii) is not vacuous.


(iv) The set $\mathcal D(S)$ of all derivations on a (commutative or non-commutative) semiring $S$ is naturally made into a left/right $S$-semimodule, by endowing it with the operation of pointwise addition and scalar multiplication induced by $S$ (the additive identity is the trivial derivation). *Loosely speaking*, this means that also the formulas for the derivative of a multiplicative unit of $S$ will form a left/right $S$-semimodule.


(v) One can always extend the operations of a semiring $S$ by adding a "point at infinity" $\infty$ and taking, for every $x \in S \cup \{\infty\}$,
$$
x + \infty = \infty + x := \infty
\quad\mathrm{and}\quad
x \cdot \infty = \infty \cdot x := \left\{
\begin{array}{ll}
0\_S & \mathrm{if } x = 0\_S, \\
\infty & \mathrm{if } x \ne 0\_S.
\end{array}
\right.
$$
It is readily checked that $(S \cup \{\infty\}, +, \cdot\,)$ is a semiring (with the same additive and multiplicative units of $S$) whose additive monoid is annihilated by $\infty$. Moreover, if the only unit of the additive monoid of $S$ is the identity $0\_S$, then the function
$$
\partial \colon S \cup \{\infty\} \to S \cup \{\infty\} \colon x \mapsto 
\left\{
\begin{array}{ll}
0\_S & \mathrm{if } x = 0\_S, \\
\infty & \mathrm{if } x \ne 0\_S
\end{array}
\right.
$$
is a derivation on the extended semiring. On the one hand, I take this as a sign that something is "wrong" from a conceptual point of view: Maybe the condition $\partial 1\_S = 0\_S$ should be part of the definition of a derivation (the condition is implied by Leibniz's law when it comes to rings, since the additive monoid of a ring is a group, hence cancellative). On the other hand, it is curious that $\partial u^{-1} = u^{-2} \partial u$ for every multiplicative unit $u \in S$ (cf. item (ii)), isn't it?


