Doing series in Maple with specific order value, the number of terms generated ofcourse
depends on the function. I had need to have the series generated always with same number
of terms. I could not find an option in Maple to do that. This function does this. It keeps
finding the series for the function with increasing order until the number terms that comes
out is what requested. There is an upper limit that can be changed if needed to protect
against pathological cases.
restart; get_series_by_terms:=proc(expr,x::symbol,at::numeric,number_terms_needed::posint) local keep_running::boolean:=true; local current_order::integer:=0; local MAX_ORDER_TO_TRY::posint:=100; #change as needed local result; do current_order := current_order+1; result := convert(series(expr,x=at,current_order),polynom); if nops(result) >= number_terms_needed or current_order>MAX_ORDER_TO_TRY then keep_running:=false; fi; until keep_running=false; return result; end proc:
And now
returns