The second procedure is obviously more simple than the first procedure, why the running time of the second procedure (i.e. 22s) is much more than the first procedure (i.e. 0.07), and how to improve the second procedure?
Thanks, this approach works, I guess maybe it is the algorithms related to the simplify in mathematica that caused this problem. But I wonder whether there is a instruction that can modify this problem, i.e. the time cost to calculate increases with the number of x[i] increases?