I want to get cmos non-linear characteristic, I get the right Ids-Vgs, gm-Vgs characteristics but I can't get right gm2-Vgs, gm3-Vgs characteristics . I think I can't accurately express the differential expression (gm2= (1/2!)(d2 Ids /dV2gs)).
Okay, You measure the nonlinear coefficients gm1 , gm2, gm3 etc by setting the operating point of the amplifier and applying on its gate a sinusoidal input voltage say Vi cos wt, then you measure the ac drain current id(t). If you make courier analysis of the drain current waveform, you get the fundamental, the second harmonic, the third harmonic ... etc. From the amplitudes of the harmonics you can calculate the different transconductances.
For full details please see the lecture in the LINk:http://rfic.eecs.berkeley.edu/~niknejad/ee142_fa05lects/pdf/lect7.pdf