The Normal function is supposed to truncate the output of the Series function to a normal expression. But when I try to use that expression to define another function it fails: seems to keep some series attrfibutes. So I have to copy the expression and paste it to the right side of the new function definition. Here is an example from a Mathematica notebook:
In[242]:= (*Let's try the Series function with variable exponent k.
Want to truncate with the Normal function, then use the resulting \
expression as input to define a new function. But the output of \
Normal does not behave like a normal expression. Have to copy and \
paste instead.*)
In[209]:= xpand[k_, r_, n_] := Series[(1 + r)^(1/k), {r, 0, n}]
In[223]:= xpand[k, r, 5]
Out[223]= SeriesData[r, 0, {
1, k^(-1),
Rational[1, 2] ((-1 + k^(-1))/k), ((Rational[1, 6] (-1 + k))
k^(-3)) (-1 + 2 k), (((Rational[-1, 24] (-1 + k))
k^(-4)) (-1 + 2 k)) (-1 + 3 k), ((((Rational[1, 120] (-1 + k))
k^(-5)) (-1 + 2 k)) (-1 + 3 k)) (-1 + 4 k)}, 0, 6, 1]
In[227]:= xpandN5[k_, r_] := Normal[xpand[k, r, 5]]
In[230]:= xpandN5[2, r]
Out[230]= 1 + r/2 - r^2/8 + r^3/16 - (5 r^4)/128 + (7 r^5)/256
In[234]:= pand[r_] := xpandN5[2, r]
In[235]:= pand[r]
Out[235]= 1 + r/2 - r^2/8 + r^3/16 - (5 r^4)/128 + (7 r^5)/256
In[236]:= pand[.2]
During evaluation of In[236]:= General::ivar: 0.2` is not a valid variable.
During evaluation of In[236]:= General::ivar: 0.2` is not a valid variable.
Out[236]= Series[1.09545, {0.2, 0, 5}]
(*Failed. Can't get rid of some of the series attributes, so that the \
alleged normal expression could be used as the righthand side in \
function definitions. So try it with copy and paste instead.*)
In[238]:=
pand1[r_] := 1 + r/2 - r^2/8 + r^3/16 - (5 r^4)/128 + (7 r^5)/256
In[239]:= pand1[r]
Out[239]= 1 + r/2 - r^2/8 + r^3/16 - (5 r^4)/128 + (7 r^5)/256
In[240]:= pand1[.2]
Out[240]= 1.09545
In[241]:= (*So after I copy and paste the displayed output of Normal, \
I can use it to define a new function. But this is cumbersome when \
the expression is very long.*)