Topic: Differentiating mod()


I just realized that graph doesn't differentiate the mod() function. If it is possible to add this function I think it would be very useful. Please correct me if I am wrong, but I think it is actually simple to differentiate: the derivative is simply 1.

When you have something like mod(f(x),m), the mod function just adds a vertical shift to some pieces of the inside function, which doesn't change its derivative, so by chain rule the derivative is 1*f'(x), or simply the derivative of the inside function.

The general case is when you have something like f(mod(g(x),m)) then chain rule gives you f'(mod(g(x),m))*1*g'(x) which I think is the correct derivative. So the derivative of the mod() function is simply 1, and the chain rule takes care of everything else.

I think this would be a very useful thing to implement. Thanks!

Re: Differentiating mod()

I think you are right as long as m is constant. I have now added support for differentiation of the mod function in the beta version of Graph 4.4.