At 01:28 PM 1/26/2003 -0800, Kirby Urner wrote:
The expansion is (1/0! 1/1! 1/2! 1/3! 1/4!...) where these are the coefficients of a polynomial, with x^0, x^1, x^2, x^3... respectively.
Just for comparison and contrast, in the J language, we get Taylor Expansions of many functions, plus polynomials themselves, implemented as primitive "verbs" (the lingo is resolutely linguistic-grammatical -- nouns, verbs, adverbs, conjunctions, and even gerunds, get defined): (NB. means comment = "nota bene") exp =: ^ NB. ^ in front of a noun is like Python's exp(noun) I just renamed a verb to look more like Python. I'm going to ask for the first 10 coefficients of the polynomial expansion of e^x, in rational format ( 1r2 means 1/2 or one half): taylor =: t. rational =: x: NB. make of 'rational type' (coming in Python) range =: i. NB. like i. 10 returns 0 1 2 3...9 like range(10) exp taylor (range rational 10) NB. <-- user, next line is computer 1 1 1r2 1r6 1r24 1r120 1r720 1r5040 1r40320 1r362880 (i.e. 1/0! 1/1! 1/2! 1/3! 1/4! etc.) coeffs =: exp taylor (range rational 30) NB. same, but more terms coeffs p. 3 NB. use polynomial operator to evaluate p(x), x=3 20.0855 ^3 NB. note, same answer 20.0855 And of course: coeffs p. 0j1p1 NB. 0j1p1 means i pi (like Python, J uses j) _1 And even more exact answer than Python's (thanks to internal rounding I guess). Kirby