Board index » delphi » power function: looking to improve this one.
Er...@hccgron.idn.nl (Erik Huelsmann)
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT

Er...@hccgron.idn.nl (Erik Huelsmann)
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT
power function: looking to improve this one.I have a power function here, but there is a problem with it. It returns This is the function. I changed the function to this: where sign is a function that returns the sign of t. This is wrong too, since This is wrong too! Erik! _personal_ reactions preferrably by email. 
Zweitze de Vri
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT
Re:power function: looking to improve this one.In article <544_9604240...@idn.nl>, Er...@hccgron.idn.nl (Erik Huelsmann) says: Quote>I have a power function here, but there is a problem with it. It returns What about (2)^(0.5)? This is equal to Sqrt(2), so no answer is defined, unless you allow the result to be a complex number. When you allow such answers, remember you get multiple answers, eg.: (4)^(0.5) = 2i or 2i; 1^(1/3) = 1, or 0.5 * (1 + i*Sqrt(3)), or 0.5 * (1 + i*Sqrt(3)). Note: This is from top of my hat, it might not be entirely correct. Quote>This is the function. Bye, 
hoxs..
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT
Re:power function: looking to improve this one.In <544_9604240...@idn.nl>, Er...@hccgron.idn.nl (Erik Huelsmann) writes: Quote
Quote>I changed the function to this: MOD operator to check this (you'll hae to test to see if it's a whole number first and convert to integer to use the MOD operator, but this should be done anyway): if (i MOD 2)<>0 then neg:=TRUE else neg:=FALSE;  
Valt
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT
Re:power function: looking to improve this one.QuoteEr...@hccgron.idn.nl (Erik Huelsmann) wrote: x^n = n * ln(x) (x)^n = n * ln(x) can not be performed though, as you may think, Let us try something else....algebraically speaking... (x)^n = (1^n)*(x^n) (using distribution) This is the corect method to represent what you were trying to do You may need to choose another method to do this, or restrict this Glenn Grotzinger 
Timo Sal
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT
Re:power function: looking to improve this one.In article <4lo5h5$...@elektron.et.tudelft.nl>, Quote>I have a power function here, but there is a problem with it. It returns 96535 Mar 30 20:19 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip So many of the problems posted in here have already been solved for All the best, Timo .................................................................... 
Colin Sarsfiel
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT
Re:power function: looking to improve this one.I hope this is what you're looking for. unit Arith; interface uses type function Power(const x, y: Extended): Extended; implementation function Power(const x, y: Extended): Extended; end.  
Dr John Stockto
Delphi Developer 
Wed, 18 Jun 1902 08:00:00 GMT
Re:power function: looking to improve this one.In article <changi0.9m.29ZJht$...@nntp.hoxsiew.ezl.com> in Quotecomp.lang.pascal.borland, hoxs...@ezl.com wrote: or, better, neg := Odd(i) ;  