My question is essentially the same as this one:

[Simplifying a very long symbolic expression by automatically introducing temporal variables or in any other way](https://stackoverflow.com/q/9057905/2466623)

However, I don't have Mathematica and the question was not answered for Matlab, further, this is 2 years old and maybe people have had some ideas since then.

Like Andrey, I have an extremely large equation (about 13000 characters) as a result of a multiple-chain-rule derivate of an already long function. The derivate contains numerous instances of the subfunctions in the original equation and their derivates. I believe it's possible to compress the function to at least a 10th with suitable replacements. I am wondering if there is a way to have Matlab make these replacements automatically for me.

This is also relevant from a performance standpoint, because I have thens of these equations that are evaluated for a Jacobi matrix to solve a complicated system of nonlinear equations.

Thank you for your time.