In calculus, the derivative of a mathematical function defines the rate at which it changes. The derivative of a function
f(x) can be marked as
f'(x), and these can sometimes be abbreviated to
The derivative of the product of two functions
f'g + g'f. The derivative of three
f'gh + fg'h + fgh'. In general, the derivative of a product of any number of functions is the sum of the product of all but one, multiplied by the derivative of the remaining one, for each individual function.
Your challenge is to take a string of distinct alphabetical characters and transform it into its derivative. No spacing or simplification is required, and terms separated by
+ may be in any order. The string will contain at least two characters.
This is code-golf, so the shortest code wins!
abc -> a'bc+ab'c+abc' de -> d'e+de' longabcdef -> l'ongabcdef+lo'ngabcdef+lon'gabcdef+long'abcdef+longa'bcdef+longab'cdef+longabc'def+longabcd'ef+longabcde'f+longabcdef' short -> s'hort+sh'ort+sho'rt+shor't+short'