# Calculating successive derivatives of a monomial list using a Do loop

I've got the following monomial list:

monlist={c x^3, x^5, 4};


I need to compute the successive derivatives of that list of monomials such that when the derivative of all elements in the list is zero, the Do loop stops. For a single monomial it is easy to implement the Do loop with the If statement, but for a monomial list I don't understand how to do it.

My goal is to get the following list structure:

{{3 c x^2, 5 x^4, 0}, {6 c x, 20 x^3, 0}, {6 c, 60 x^2, 0}, {0, 120 x,0}, {0, 120, 0}, {0, 0, 0}}


I thank you in advance for any suggestion.

Most@FixedPointList[D[#, x] &, monlist]

{{c x^3, x^5, 4}, {3 c x^2, 5 x^4, 0}, {6 c x, 20 x^3, 0}, {6 c,
60 x^2, 0}, {0, 120 x, 0}, {0, 120, 0}, {0, 0, 0}}


EDIT

Using While and for the sake of comparison with the procedural approach:

monlist = {c x^3, x^5, 4};
dlist = {monlist};
While[Last@dlist =!= {0, 0, 0},
AppendTo[dlist, D[Last@dlist, x]]
]
dlist

• Nice answer, Syed! Feb 13, 2022 at 4:29
• With Rest and Most commands. It's perfect, thanks a lot, Syed! Feb 13, 2022 at 4:33
• Thanks for the accept and the feedback; Best Regards. Try: FixedPointList[D[#, x] &, monlist][[2 ;; -2]] as a variation.
– Syed
Feb 13, 2022 at 4:39

Another possibility

 monlist = {c x^3, x^5, 4};
NestWhileList[D[#, x] &, monlist, Total[#] =!= 0 &]


Edit

And in the spirit of procedural like programming, here is my version

monlist = {c x^3, x^5, 4};
First@Last@Reap@While[True, Sow[monlist = D[monlist, x]];
If[Total[monlist] === 0, Break[]]]


I am sure the NestWhileList will be faster for very long list but I did not do any measurements.