General > General Technical Chat
Raising a number to a non-integer power.
<< < (6/13) > >>
SiliconWizard:

--- Quote from: Nominal Animal on May 28, 2020, 03:25:48 am ---Actually, the form ab = 2b log2 a is useful, as it is something a computer can do in binary directly, and quite efficiently for base-2 floating point numbers. Details.

--- End quote ---

Yep!
Generally speaking, even for integer exponentiation, a binary algorithm is much more efficient than a simple linear algorithm (multiplying the number by itself b times.)
Nominal Animal:
For those interested, the binary integer algorithm calculates ab for integer b>0 with at most 2 log2 b multiplications. In pseudocode,

--- Code: ---Function ipow(a, b):
    Let result = 1
    While b > 0:
        If b is odd:
            result = result × a
            b = (b - 1) / 2
        Else
            b = b / 2
        End If
        a = a × a
    End While
    Return result
End Function

--- End code ---
For negative b, you do 1/ipow(a,-b) or ipow(1/a, -b).  b=0 is mathematically ambiguous case, and usually handled separately.
Programming languages with integer division (dropping the fractional part, or rounding toward zero, or binary shift right by one bit), just do b = b / 2 in both branches of the If clause.
The one extra squaring of a is avoided in practice by moving the end-of-loop test to just after halving b.
RoGeorge:
Op asks what is the intuitive representation of raising a number to a fractional power, gets answers about best numerical algorithms.    ::)

Software devs are the best example for the saying "When you have a hammer, everything looks like a nail".  Not sure if this is their biggest flaw or their biggest power.  And, if that's a power indeed, is it a non-integer one?   ;D
magic:

--- Quote from: RoGeorge on May 29, 2020, 05:37:32 am ---Software devs are the best example for the saying "When you have a hammer, everything looks like a nail".  Not sure if this is their biggest flaw or their biggest power.

--- End quote ---
Look at the software available today, compare with the software available 15 years ago, take a wild guess ::)
aneevuser:

--- Quote from: magic on May 28, 2020, 12:57:38 pm ---
Fair enough, off the top of my head I can't provide a simple algebraic argument why complex exponents should be defined the way they are. That doesn't necessarily mean no such argument exists. I don't know what reasoning originally led to the Euler identity and things like that - perhaps the Taylor series, maybe something more direct and straightforward.

--- End quote ---
You might want to take a look at the first chapter (and others) of "Visual Complex Analysis" by Needham, which gives a couple of suggestive geometric/algebraic arguments for the validity of Euler's formula.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod