Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!rpi!bu.edu!mirror!frog!cpoint!crackers!m2c!umvlsi!dime!smectos!eli From: eli@smectos.gang.umass.edu (Eli Brandt) Newsgroups: comp.lang.pascal Subject: Re: TP: Exponentiation? Message-ID: <17410@dime.cs.umass.edu> Date: 25 Jul 90 22:05:00 GMT References: <950036@hpclapd.HP.COM> <2041@bimacs.BITNET> Sender: news@dime.cs.umass.edu Reply-To: eli@smectos.CS.UMASS.EDU (Eli Brandt) Organization: University of Massachusetts, Amherst Lines: 17 In article <2041@bimacs.BITNET> ehrlich@bimacs.biu.ac.il.UUCP (Gideon Ehrlich) writes: > >Very easy. Either use x**y = exp(y*ln(x)) > or write your own function ,using Tailor sequence. The power function is fine, but you should really never use a Taylor sequence for *anything* other than maybe prototyping. If you write your own power function, you should consider these modifications: 1) Check for negatives and 0^0, obviously. 2) A significant fraction of calls will probably involve integer powers. The way to handle this is to use a simple for loop for low powers and a repeated squaring loop for higher powers. The crossover point depends on the machine and compiler but is usually around 5 to 10. 3) If you have a power y which is i+r, where i is floor(y), you can use your integer-power routine and multiply the result by the output of a power routine optimized for its fixed domain. I didn't get any significant speedup with this, though.