[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [SCICOMP] algoritme til pow(float, float);



Umiddelbart tror jeg ikke at du kan finde en rækkeudvikling der kan gøre
det særlig godt, men følgende er egentligt sikkert også hurtiger (men
kan vist umiddelbart kun bruges for heltallige n):

Du ønsker at finde x=a^(1/n). Det svarer til at finde nulpunkt for
f(x)=x^n-a. Vi får at f'(x)=nx^(n-1). Newtons metode giver så: 

x_i+1=x_i-(x_i^n-a)/(nx_i^(n-1))

Iterér indtil konvergens.

Jeg har ikke selv prøvet det, men så hut jeg visker at det vist sådan at
f.eks. lommeregnere beregner kvadratrødder.

MVH PMB

Mikael Rasmussen wrote:
> 
> Hejsa Sci-Slugger
> 
> Til nogle beregninger på en hjemmeside har jeg
> brug for at beregne pow(float x, float y), altså
> x^y hvor y = 0.8
> Det flotteste ville være en algoritme der kunne
> beregne for alle y (større end 0), men da
> x^0.8 = x / x^(1/5) kan jeg godt nøjes med
> en simpel algoritme der kan beregne x^(1/5).
> Dette åbner nemlig for flg. muligheder der senere kunne
> blive nødvendige.
> ..
> x^0.4 = x / (x^(1/5))^3
> x^0.6 = x / (x^(1/5))^2
> x^0.8 = x / x^(1/5)
> ..
> Beregningerne foregår i JavaScript og jeg har kun adgang
> til gængse regneregler (+-*/). Har prøvet at fremstille
> forskellige iterationer men det er ikke lykkedes mig at
> ramme "rigtigt", da x kan svinge fra 100 til 100000.
> Er der en her på listen der lige kan slynge et eller
> andet smart ud ville jeg blive meget glad ;-)
> 
> Hilsen
>        Mikael
> 
> Btw: Sorry, jeg sender fra MS-Hotmail
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> Share information about yourself, create your own public profile at
> http://profiles.msn.com.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:34 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *