Thanks, that helped. On Oct 23, 12:38 pm, Ralf Hemmecke <[email protected]> wrote: > > series(n +-> 1^n / factorial(n), x = 0) > > Note that with this input your output type will be > UnivariatePuiseuxSeries(Expression(Integer),x,0). > > Not bad, but you can have more control over the result type if you like. > Then, however, you have have to make sure that the interpreter does not > need to guess what you actually mean. > > I demonstrate this now for > > > series(n +-> %i^n / factorial(n), x = 0) > > (1) -> Z==>Integer;Q==>Fraction Z;C==>Complex Q;S==>Stream C > Type: > Void > (2) -> n:=1 > > (2) 1 > Type: > PositiveInteger > (3) -> nextCoefficient(c: C): C == (r:C := imaginary()*c/n; n:=n+1; r) > Function declaration nextCoefficient : Complex(Fraction(Integer)) > -> Complex(Fraction(Integer)) has been added to workspace. > Type: > Void > (4) -> s: S := generate(nextCoefficient, 1$C) > Compiling function nextCoefficient with type Complex(Fraction( > Integer)) -> Complex(Fraction(Integer)) > > 1 1 1 1 1 1 1 1 > (4) [1,%i,- -,- - %i,--,--- %i,- ---,- ---- %i,-----,------ %i,...] > 2 6 24 120 720 5040 40320 362880 > Type: > Stream(Complex(Fraction(Integer))) > (5) -> series(s)$UnivariateTaylorSeries(C, x, 0) > > (5) > 1 2 1 3 1 4 1 5 1 6 1 7 > 1 + %i x - - x - - %i x + -- x + --- %i x - --- x - ---- %i x > 2 6 24 120 720 5040 > + > 1 8 1 9 1 10 11 > ----- x + ------ %i x - ------- x + O(x ) > 40320 362880 3628800 > Type: > UnivariateTaylorSeries(Complex(Fraction(Integer)),x,0) > > UnivariateTaylorSeries does not itself allow a construction from a > coefficient function co: Z -> C. > > But look > athttps://github.com/hemmecke/fricas-svn/blob/master/src/algebra/genups... > and in particular the auxiliary stream that is constructed there. > > It should be possible to call "taylor" from there like > > (20) -> taylor((n:Integer):Expression(Complex Integer) +-> %i^n / > factorial(n), x = 0) > > (20) > 1 2 %i 3 1 4 %i 5 1 6 %i 7 1 8 > 1 + %i x - - x - -- x + -- x + --- x - --- x - ---- x + ----- x > 2 6 24 120 720 5040 40320 > + > %i 9 1 10 11 > ------ x - ------- x + O(x ) > 362880 3628800 > Type: > UnivariateTaylorSeries(Expression(Complex(Integer)),x,0) > > or even > > (21) -> series((n:Integer):Expression(Complex Integer) +-> %i^n / > factorial(n), x = 0) > > (21) > 1 2 %i 3 1 4 %i 5 1 6 %i 7 1 8 > 1 + %i x - - x - -- x + -- x + --- x - --- x - ---- x + ----- x > 2 6 24 120 720 5040 40320 > + > %i 9 1 10 11 > ------ x - ------- x + O(x ) > 362880 3628800 > Type: > UnivariatePuiseuxSeries(Expression(Complex(Integer)),x,0) > > However, look in particular at the result type, because it might not > exactly be that what you want for doing further computation. > > Hope that helps. > > Ralf
-- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
