OK i was in the wrong. Sorry (thought i apologized already?)

RAdlanor you said (You just don't use trigonometry for square roots.)

This is DeMoivres theorom which can be used to find the square, cubic, or any power roots of any real or complex number.

[(any number) ^ (1/n)] = [(cosA +k *360 + sinB +k*360)/n]

That looks like trig to me. The problem is that you still have to find the square root of the radius vector. (i.e. [(any number) ^ (1/n)] )

This thread has got me thinking of trying to find one unique formula for finding roots of members of infinite sequences that uses only squares and normal math operations. I spent most of yesterday working on the sequence ( 2,4,8,16,32.....)

Maybe such formula already exist. I dunno

Gonna work on it anyway.

:alright:

RAdlanor you said (You just don't use trigonometry for square roots.)

This is DeMoivres theorom which can be used to find the square, cubic, or any power roots of any real or complex number.

[(any number) ^ (1/n)] = [(cosA +k *360 + sinB +k*360)/n]

That looks like trig to me. The problem is that you still have to find the square root of the radius vector. (i.e. [(any number) ^ (1/n)] )

This thread has got me thinking of trying to find one unique formula for finding roots of members of infinite sequences that uses only squares and normal math operations. I spent most of yesterday working on the sequence ( 2,4,8,16,32.....)

Maybe such formula already exist. I dunno

Gonna work on it anyway.

:alright:

I haven't used DeMoivre's theorem since grade 11... but if I remember correctly it's really only good for complex numbers. For real numbers the sin componenet disappears and cos goes to one, because your angle is 0.

So, even if you were being serious about solving it this way... you'd be stuck with your original problem...

However, for complex numbers, it's great.

Personally, I don't see anything wrong with Newton's method for square roots... it should work well enough and you could probably code up an integer version easily

Take care

--Chorus

PS. shouldn't the formula be:

p=x+yi

r^2=x^2+y^2

k=angle (in radians) between abscissa and p

p^(1/n) = r^(1/n)

So, even if you were being serious about solving it this way... you'd be stuck with your original problem...

However, for complex numbers, it's great.

Personally, I don't see anything wrong with Newton's method for square roots... it should work well enough and you could probably code up an integer version easily

Take care

--Chorus

PS. shouldn't the formula be:

p=x+yi

r^2=x^2+y^2

k=angle (in radians) between abscissa and p

p^(1/n) = r^(1/n)

Yep chorus your right about the formula. I get typing and don't watch my brackets and stuff.

Here i have uncovered the formula for finding the roots of the members of the infinite sequence {2,4,8,16....} obviously the easiest sequence to use when basing the formula on the square root of 2.

It Is:

Sqr root of N = ((N^2)/ 2) / (1.4142135)^(1+3*n)

Where N is the number you want the root of.

Where n is position of the number in the infinite sequence. (i.e. 2 = position 0, 4 = position 1, 8 = position 2)

1.4142135 is the root of 2

That was an obviously easy sequence.

I am going to try this one next still based on the the root of 2.

{3,6,9,12...}

:alright:

Here i have uncovered the formula for finding the roots of the members of the infinite sequence {2,4,8,16....} obviously the easiest sequence to use when basing the formula on the square root of 2.

It Is:

Sqr root of N = ((N^2)/ 2) / (1.4142135)^(1+3*n)

Where N is the number you want the root of.

Where n is position of the number in the infinite sequence. (i.e. 2 = position 0, 4 = position 1, 8 = position 2)

1.4142135 is the root of 2

That was an obviously easy sequence.

I am going to try this one next still based on the the root of 2.

{3,6,9,12...}

:alright:

What's wrong with

sqrt (2^n) == 2^(n/2)

which is a lot easier to calculate than (1.414..)^(1+3n)

or if you wanna be fancy, you can use lns

sqrt(2^n) == e^(ln (2)/2)

The sequence {3,6,9,12} is simply 3*{1,2,3,4,...} for which the solution for the square root of the nth number is sqrt(3)*sqrt(n) where sqrt (3) ~= 1.73.

--Chorus

sqrt (2^n) == 2^(n/2)

which is a lot easier to calculate than (1.414..)^(1+3n)

or if you wanna be fancy, you can use lns

sqrt(2^n) == e^(ln (2)/2)

The sequence {3,6,9,12} is simply 3*{1,2,3,4,...} for which the solution for the square root of the nth number is sqrt(3)*sqrt(n) where sqrt (3) ~= 1.73.

--Chorus

Yep that is very nice chorus for the first sequence {2,4,8,...}

sqrt (2^n) == 2^(n/2)

However your solution to finding the roots of the sequence {3,6,9,12...} requires that you find individual roots.

sqrt(3)*sqrt(n)

Here you have a constant sqrt (3) but you then have to calculate the root sqrt(n) for all integer values.

My goal is to find a formula for the series similar to your posted sqrt (2^n) == 2^(n/2) which uses powers. This "is" better than mine.

And of course if the series were {3,9,27,81....} you could use

sqrt(3^n)==3^(n/2)

But the series is { 3,6,9,12 } so you see my point i hope.

Any ideas please reply.

thanx

:alright: :alright:

sqrt (2^n) == 2^(n/2)

However your solution to finding the roots of the sequence {3,6,9,12...} requires that you find individual roots.

sqrt(3)*sqrt(n)

Here you have a constant sqrt (3) but you then have to calculate the root sqrt(n) for all integer values.

My goal is to find a formula for the series similar to your posted sqrt (2^n) == 2^(n/2) which uses powers. This "is" better than mine.

And of course if the series were {3,9,27,81....} you could use

sqrt(3^n)==3^(n/2)

But the series is { 3,6,9,12 } so you see my point i hope.

Any ideas please reply.

thanx

:alright: :alright:

IwasTitan,

my point about {3,6,9,12} is that if there were a nice solution then you would implicitly have a solution for the square root of integers because they are identical problems.

There are a number of solutions, but none as simple as for the specific case of Sqrt (2^n). You can use a Taylor series expansion, for example, which is what Newton's method is based on.

The problem you will find is that most square roots are non-constructable. That is, they, are transcendental and do not boil down to finite algebraic sequences. You pretty much have to define them in terms of other transcendental numbers.

Regards

--Chorus

my point about {3,6,9,12} is that if there were a nice solution then you would implicitly have a solution for the square root of integers because they are identical problems.

There are a number of solutions, but none as simple as for the specific case of Sqrt (2^n). You can use a Taylor series expansion, for example, which is what Newton's method is based on.

The problem you will find is that most square roots are non-constructable. That is, they, are transcendental and do not boil down to finite algebraic sequences. You pretty much have to define them in terms of other transcendental numbers.

Regards

--Chorus

Well that is certainly food for thought chorus. You appear to have a good understanding of number theory.

Maybe you could help me with something. I once had taken a calculas course in which the following equation was stated as being impossible to integrate.

(x^2 + 5) ^ 2 . dx

Any idea why?

:alright:

Maybe you could help me with something. I once had taken a calculas course in which the following equation was stated as being impossible to integrate.

(x^2 + 5) ^ 2 . dx

Any idea why?

:alright:

No idea...

f(x)dx == (x^2 + 5) ^ 2 . dx == x^4+ 10x^2+25

Integeral f(x) dx == (x^5)/5 + 10(x^3)/3 + 25x + C1

Seems perfectly integrable (?) to me...

However, there are many equations for which an algebraic solution of an integral is not possible. Every polynomial is though.

--Chorus

f(x)dx == (x^2 + 5) ^ 2 . dx == x^4+ 10x^2+25

Integeral f(x) dx == (x^5)/5 + 10(x^3)/3 + 25x + C1

Seems perfectly integrable (?) to me...

However, there are many equations for which an algebraic solution of an integral is not possible. Every polynomial is though.

--Chorus

Hmmmm ...I think what the course may have been implying is that if the X value is at a power greater than 1 ..then you would have to expand just as you did. Expansion isn't necessary for the equation below.

(3x+4)^5.dy/dx = 15 (3x+4)^4

and so

15(3X +4) ^4. dx == 15(3X+4)^5 /(3*5)

Imagine how simple it woul'd become if you didn't have to expand this:

(x^7 + 11) ^ 25

If i remember correctly now their words were:

"There is presently no method" ....which does not mean there is no solution.

With modern computing power would a method that did not require expansion really count for much? i dunno. Maybe they were implying something else.

:alright:

(3x+4)^5.dy/dx = 15 (3x+4)^4

and so

15(3X +4) ^4. dx == 15(3X+4)^5 /(3*5)

Imagine how simple it woul'd become if you didn't have to expand this:

(x^7 + 11) ^ 25

If i remember correctly now their words were:

"There is presently no method" ....which does not mean there is no solution.

With modern computing power would a method that did not require expansion really count for much? i dunno. Maybe they were implying something else.

:alright:

something like this would do it

```
SquareRoot PROC Number:DWORD
```

mov ecx, 1

@@: inc ecx

mov eax, ecx

mul ecx

cmp eax, Number

jb @b

ja @f

mov eax, ecx

ret

@@: xor eax, eax

ret

SquareRoot ENDP

This just gives 0's if it's not 9 or 4

I got it to work, it's pretty cool code!

*Originally posted by andy981*

AnyOne have a FPU version of a SqRoot routine

```
```

...

_dq DQ 0

...

push 10

fild DWORD PTR [esp]

fsqrt

fstp _dq

pop eax ;Rebalance stack

_dq contains the squareroot of 10. You can eliminate push 10 ... pop eax if you want to compute directly from a "variable". Then use the FloatToStr from the masm32 library to convert FPU to string. :)*Originally posted by stryker*

.data

Number dd ?

.code

mov eax,25

push eax

call SquareRoot

SquareRoot:

mov Number,eax

mov ecx, 1

@@: inc ecx

mov eax, ecx

mul ecx

cmp eax, Number

jb @b

ja @f

mov eax, ecx

ret

@@: xor eax, eax

ret

If you want, can you lay out what you showed me Stryker last night like this

if it can work like that, Thank You for the help so far

Andy981

:stupid:

```
```

...

_dq DQ 0

...

push 10

fild DWORD PTR [esp]

fsqrt

fstp _dq

pop eax ;Rebalance stack

.data

Number dd ?

.code

mov eax,25

push eax

call SquareRoot

SquareRoot:

mov Number,eax

mov ecx, 1

@@: inc ecx

mov eax, ecx

mul ecx

cmp eax, Number

jb @b

ja @f

mov eax, ecx

ret

@@: xor eax, eax

ret

If you want, can you lay out what you showed me Stryker last night like this

if it can work like that, Thank You for the help so far

Andy981

:stupid:

**
**

;maybe this one

;but you should add in the start a check if the number is 0,1 or 2 ( i think)

un tested ..

shr eax,2

mov ecx, eax

@@: inc ecx

mov eax, ecx

mul ecx

cmp , eax,; esp if you push eax, number if not

ja @b

sbb ecx,0

@@:

mov eax, ecx ;add esp,4

ret 4 ; or do ret 4

bye

eko

;but you should add in the start a check if the number is 0,1 or 2 ( i think)

un tested ..

shr eax,2

mov ecx, eax

@@: inc ecx

mov eax, ecx

mul ecx

cmp , eax,; esp if you push eax, number if not

ja @b

sbb ecx,0

@@:

mov eax, ecx ;add esp,4

ret 4 ; or do ret 4

bye

eko

*Originally posted by Andy981*

Don't really know how to make this work, but Thank You StrykerDon't really know how to make this work, but Thank You Stryker

*You mean my code? Or the one you posted. If the latter, I'll check that out later, also haven't tested eko's version yet.*```
.data?
```

_dq DQ ?

bfr DB 20 DUP(?)

.code

start:

push 10 ;TOS == 10

fild DWORD PTR [esp] ;ST(0) == 10

fsqrt ;ST(0) == 3.162278 == sqrt(10))

fstp _dq ;_dq = ST(0)

pop eax

invoke FloatToStr, _dq, OFFSET bfr

invoke MessageBox, NULL, OFFSET bfr, NULL, MB_OK

;or

fld _dq ;ST(0) == 3.162278

fsqrt ;ST(0) == 1.778279 == sqrt(3.162278)

fstp _dq ;_dq = ST(0)

invoke FloatToStr, _dq, OFFSET bfr

invoke MessageBox, NULL, OFFSET bfr, NULL, MB_OK

invoke ExitProcess,NULL

end start

Just include masm32.inc and masm32.lib for the FloatToStr.

*
*Yeah you really come through, Thanks Stryker!

I'd done a little of this floating point several months ago, but never got to this level, as I actually look at it right now,

I remember that fstp is for storing the number.

And by looking up in the Book right now about

DQ is a double, I wondered what

_dq DQ ?

was about

Anyway Thank You Stryker

I made it one complete copy paste for the next person.

And I changed it so 25 is pushed

then Squared to 5

then 5 is Squared

and that last Square is displayed on the Screen

.486

.model flat,stdcall

option casemap:none

includelib \masm32\lib\kernel32.lib

includelib \masm32\lib\user32.lib

includelib \masm32\lib\masm32.lib

include \masm32\include\windows.inc

include \masm32\include\kernel32.inc

include \masm32\include\user32.inc

include \masm32\include\masm32.inc

.data?

_dq DQ ?

bfr DB 20 DUP(?)

.code

start:

push 25 ; You will get 5 ;TOS == 10

fild DWORD PTR ;ST(0) == 10

fsqrt ;ST(0) == 3.162278 == sqrt(10))

fstp _dq ;_dq = ST(0)

pop eax

invoke FloatToStr, _dq, OFFSET bfr

invoke MessageBox, NULL, OFFSET bfr, NULL, MB_OK

;or

fld _dq ;ST(0) == 3.162278

fsqrt ;ST(0) == 1.778279 == sqrt(3.162278)

fstp _dq ;_dq = ST(0)

invoke FloatToStr, _dq, OFFSET bfr

invoke MessageBox, NULL, OFFSET bfr, NULL, MB_OK

invoke StdOut,addr bfr

invoke ExitProcess,NULL

end start

I'd done a little of this floating point several months ago, but never got to this level, as I actually look at it right now,

I remember that fstp is for storing the number.

And by looking up in the Book right now about

DQ is a double, I wondered what

_dq DQ ?

was about

Anyway Thank You Stryker

I made it one complete copy paste for the next person.

And I changed it so 25 is pushed

then Squared to 5

then 5 is Squared

and that last Square is displayed on the Screen

.486

.model flat,stdcall

option casemap:none

includelib \masm32\lib\kernel32.lib

includelib \masm32\lib\user32.lib

includelib \masm32\lib\masm32.lib

include \masm32\include\windows.inc

include \masm32\include\kernel32.inc

include \masm32\include\user32.inc

include \masm32\include\masm32.inc

.data?

_dq DQ ?

bfr DB 20 DUP(?)

.code

start:

push 25 ; You will get 5 ;TOS == 10

fild DWORD PTR ;ST(0) == 10

fsqrt ;ST(0) == 3.162278 == sqrt(10))

fstp _dq ;_dq = ST(0)

pop eax

invoke FloatToStr, _dq, OFFSET bfr

invoke MessageBox, NULL, OFFSET bfr, NULL, MB_OK

;or

fld _dq ;ST(0) == 3.162278

fsqrt ;ST(0) == 1.778279 == sqrt(3.162278)

fstp _dq ;_dq = ST(0)

invoke FloatToStr, _dq, OFFSET bfr

invoke MessageBox, NULL, OFFSET bfr, NULL, MB_OK

invoke StdOut,addr bfr

invoke ExitProcess,NULL

end start

*
*