# # 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-8: a**x ; a => m14 (a > 0) ; x => m13 ; Color: green ; Style: blank ; ---------- Card-Pocket-End --------------------------------------------- ; SFJ $208 RM14 ; by moving "a" closer to 1, we increase rate of convergence SQRT SQRT SQRT SM14 ; ; http://en.wikipedia.org/wiki/Natural_logarithm ; ; ln(x) = ln((1+y)/(1-y)) ; = 2y (1 + (y**2)/3 + (y**4)/5 + (y**6)/7 + (y**8)/9 + ... ) ; ; where y = (x - 1) / (x + 1) ; 1 SM12 M14 ; m14 = x + 1 -= ; x - 1 / RM14 += ; "y" = (x - 1) / (x + 1) SM11 ; series sum * += SM14 ; y**2 FJ $304 RV ; previous term * RM12 * RM14 / 2 M12 RV RM12 * M11 ; series sum += term .1 += MJ $304 CS MJ $304 16 ; 2 * 8 (where 8 is to compensite for the three zert, above, * ; and the 2 is because of series expansion) RM11 ; ln(a) * RM13 ; x (from a**x, above) += ; ; At this point we start calculating e**x using the Taylor series ; ; e**x = sigma((x**n)/(n!)) ; = 1 + x + (x**2)/2 + (x**3)/6 + ... ; ; Strangely, this is a slightly different implementation than MS-9 ; SM14 ; x 1 SM12 ; series sum SM13 ; previous series term CM11 ; factorial denominator FJ $305 1 M11 ; bump factorial denominator RM13 ; previous term * RM14 ; x / RM11 ; factorial denominator += SM13 ; save term M12 ; add to series sum MJ $305 CS MJ $305 RM12 ; series sum SRJ