News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Exponentiation

Started by JK, July 31, 2022, 06:18:09 AM

Previous topic - Next topic

avcaballero

z = a^(b/c)

If a < 0, z is a real number <=> c is an odd number. Hence  (-2.4)^3.999 = 33.148 must not be true since we have already seen that this number is not real (sqr(1000)(-2.4) is not real), so it must be something like z = a + bi, where b <> 0


NoCforMe

Does this page help?

One thing from there:

Quote
If a fraction has a negative exponent, then we take the reciprocal of the fraction to make the exponent positive, i.e., (a/b)^-m = (b/a)^m
Assembly language programming should be fun. That's why I do it.

FORTRANS

Quote from: caballero on August 01, 2022, 06:30:10 AM
> Arbitrary fractions as an exponent rarely works that way with negative numbers

Maybe not so, there are infinite numerable odd numbers.

   A countable infinity.  Irrational numbers are a larger infinity.
Rational numbers are therefore "rare".
Quote

a^(b/(2n+1)) where n is a natural number, 2n+1 is always odd.

    Not sure what you are trying to say here.  For n = 1, you get 3.
But (-5)^(1/3) is complex.  Actually (-5)^I/3) for integer I is
complex.


Regards,

Steve N.

Edit.
   That last part is wrong.  Sorry.

SRN

JK

QuoteSo what is the test of which exponents yield a valid (i.e., real) result and which don't? Or is it not so simple?
Yes, that´s the problem, i have no idea how to do that (make a fraction out of a real number, shorten it as far as possible and then look, if the denominator is even [=result undefined] or not even [=result in real range]). 

Well, i could make my life easier and round exponents to an integer, if the number is negative. This guarantees a valid result in real range (avoiding cases where complex numbers come into play). But the result might not always be, what you would expect. Or could go the "just don´t do that" route and declare exponentiation of negative numbers (regardless of the exponent) as "forbidden" (invalid input/whatever)...

JK

jj2007

Quote from: NoCforMe on August 01, 2022, 05:54:53 AM
Quote from: jj2007 on August 01, 2022, 05:36:32 AM
Quote from: NoCforMe on August 01, 2022, 05:07:16 AMa complex number is defined by i = sqrt (-1). Since we're not taking the square root of negative numbers, no complex numbers.

Sure? i = (-1)^0.5 :cool:

Yes I'm sure; that's just a restatement of "square root" (the 1/2 power).

Indeed :biggrin:

But the whole thread talks about (-a)^b, and that includes (-1)^0.5 alias i = sqrt (-1)...

avcaballero

> (-5)^(1/3) is complex

Let's say (-8)^(1/3) = -2 (real), because (-2)*(-2)*(-2) = -8

I use -8 because is a more comfortable number than -5

jack

sorry caballero but you are wrong, the answer is 1 + sqrt(3) * I

FORTRANS

Hi,

   Actually as a qube root, there are three roots.  -2, 1+(3^0.5)i,
and 1-(3^0.5)i.  Equally spaced around the origin in the complex
plane.

Cheers,

Steve N.

jack

yes you are right, sorry caballero  :smiley:

FORTRANS

Hi,

Quote from: FORTRANS on August 01, 2022, 06:57:40 AM
Quote from: caballero on August 01, 2022, 06:30:10 AM
a^(b/(2n+1)) where n is a natural number, 2n+1 is always odd.

    Not sure what you are trying to say here.  For n = 1, you get 3.
But (-5)^(1/3) is complex.

   Okay, if I look at Reply #50 and Reply #52 I can now see what
you were saying.  It can take awhile to figure things out.  So,
thanks to caballero, it kind of makes sense now.

Regards,

Steve

daydreamer

Quote from: HSE on August 01, 2022, 04:31:47 AM
Quote from: daydreamer on August 01, 2022, 01:22:34 AM

.data
align 16
numbers real4 -2.4,-2.3,-2.1,-2.5
result real4 0.0,0.0,0.0,0.0
.code
mov ecx,1000000/4 ;1/4 for packed loop,1/1 for scalar loop
@@L1:
movaps xmm0,numbers
movaps xmm1,xmm0

mulps xmm0,xmm1;x^2
mulps xmm0,xmm1;x^3
mulps xmm0,xmm1;x^4
movaps result,xmm0
sub ecx,1
jne @@L1


      33.18      27.98      19.45      39.06

Press any key to continue...


:thumbsup:


Now -2.4^3.99  :biggrin:
like this SSE exp2 proc?:
  exp2 :2.71828 (^1.0)
exp2 2.0 : 4(^2.0) 8(^3.0) 16(^4.0) 15.9889(^3.999)

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

HSE

Quote from: daydreamer on August 06, 2022, 04:16:33 AM
like this SSE exp2 proc?:
  exp2 :2.71828 (^1.0)
exp2 2.0 : 4(^2.0) 8(^3.0) 16(^4.0) 15.9889(^3.999)


:thumbsup: I think that it's the idea: to use a Taylor serie (your notation is a mistery, I assume you used a serie accord to previous post).

To check I'm using the Complex Number Zlib by Raymond Filiatreault.
[ 2.0000e+000 0.0000e+000i] ^ [ 3.9900e+000 0.0000e+000i]  =  [ 1.5889e+001 0.0000e+000i]
[ -2.4000e+000 0.0000e+000i] ^ [ 3.9900e+000 0.0000e+000i]  =  [ 3.2872e+001 -1.0330e+000i]

Equations in Assembly: SmplMath

daydreamer

this is my SSE2 natural e^x exponent code,together with fakultet x! and reciprocal 1/x! calculation
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

HSE

Equations in Assembly: SmplMath

daydreamer

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding