How to linearize a system. Below is the code I have developed for this purpose.