Dropping higher order terms in polynomials.

Dear all,

could you please let me know how to write a code? I just get started with the SAGE and met a trouble. When I put the followings

f=e^x; f

then the output is a polynomial function with 16th order. But I wanted to drop the higher order terms and just take 3 tems. However I have no idea how to do it. It seems the truncate() or power_series(ZZ) don't work for the exponential function. Could anyone give me the solution?

thank you.

edit retag close merge delete

Sort by ยป oldest newest most voted

When I open Sage and type

 sage: f = e^x
sage: f


I get this output:

e^x


To get the Taylor series expansion of e^x at 0 to the order 5, do:

sage: f.taylor(x,0,5)
1/120*x^5 + 1/24*x^4 + 1/6*x^3 + 1/2*x^2 + x + 1


Is that what you wanted? Did you have more code before f=e^x; f which made it produce a different output?

more

Thank you so much. It was just what you said. Actually I used sage on web server and I put several codes in different lines. There might be some problem in the codes that I wrote at same time. I could solved the problem with your help.

( 2015-02-09 09:45:36 -0500 )edit

@Nownuri - if so, please accept this answer so that other people coming to this question know it was answered! Thanks.

( 2015-02-09 10:04:15 -0500 )edit