#
# canola - canon canola 1614p emulator
# Copyright (C) 2011 Peter Miller
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see .
#
; ---------- Card-Pocket-Begin -------------------------------------------
; Title: MS-11: exp(x)
; Color: green
; Style: blank
; ---------- Card-Pocket-End ---------------------------------------------
;
; http://en.wikipedia.org/wiki/Exponential_function
;
; exp(x) = sigma((x**n)/(n!))
; = 1 + x + (x**2)/2 + (x**3)/6 + (x**4)/24 + ...
;
SFJ $211
/ ; series converses faster when x is closer to 0
16
+=
SM13 ; previous series term
SM12 ; x
SM14 ; series sum
1
M14 ; series sum, now 1 + x
SM11 ; factorial numerator
FJ $308
1 ; bump factorial denominator
M11
RM13 ; previous term
*
RM12 ; x
/
RM11 ; factorial denominator
+=
SM13 ; save term
M14 ; series sum
MJ $308
CS
MJ $308
RM14 ; answer**16, compensating for x/16, above
*
+=
*
+=
*
+=
*
+=
SRJ