Page 2 of 2
Posted: Tue Feb 12, 2008 12:49 pm
by Kwai chang caine
I have tested your great code Michael
But i believe your function can't use the float :roll:
Because :
Code: Select all
Debug Pow(2,3)
Debug Round(Pow(8, 1/3), 1)
Result :
And with your code :
Code: Select all
PutNumber(@"2",x)
VNFPow(x,3,z)
Debug Number(z)
PutNumber(@"8",x)
VNFPow(x,1/3,z)
Debug Number(z)
Result:

Posted: Tue Feb 12, 2008 12:58 pm
by pdwyer
Michael Vogel wrote:pdwyer wrote:Apparently you can use Fast Fourier transforms to do this lots quicker.
Except I don't understand Fast Fourier transforms
That said, even if you do it quicker, where to you get the space?
Hi pdwyer, give me a hint, please...
...
what is done quicker?
I'm not going to pretend to understand it but take a look here
http://en.wikipedia.org/wiki/Multiplica ... #Toom-Cook
@Kwaï chang caïne That would work but like I said, my code only supports integers at the moment so 1/5 (1 divided by 5) is a number my code can't currently display. Quite a few people worked at the same time on these, we all ended up with our own but we discussed methods a lot. perhaps you'd like to look through these and add ideas for floating point operations. I have only used middle school math level in mine (as I only ever went to school till about then

) so you should understand it. Please contribute!

Posted: Tue Feb 12, 2008 1:06 pm
by Kwai chang caine
That would work but like I said, my code only supports integers at the moment so 1/5
Excuse me, but I did not understand all you said, because of my poor translation
I understand quickly, but you must explain me a long time
so you should understand it. Please contribute!
Let me help you so much, but with my bad level mathematical, my null level of English, and my programming level not higher.
Here you are with a partner, who really did not have much value

Posted: Tue Feb 12, 2008 1:14 pm
by Michael Vogel
Kwaï chang caïne wrote:I have tested your great code Michael
But i believe your function can't use the float :roll:
Code: Select all
VNFPow(x,1/3,z) :shock:[/quote]
You're right, I just do integer math...
One one hand you can "simulate" floating points by by multiplying your numbers by 10^n on the other hand the function CNFPow only supports an (positive long) integer values for the power parameter.
So my power function is limited, but depending of your aims it could be a help for you...
Michael
Some remarks:
• VNFPow(x,1/3,z) is interpreted like VNFPow(x,0,z) because the parameter b in VNFPow(...,b,...) is an integer type
• maybe you can use the function for iterations, if you are searching 627213431734272 ^ (1/3) for example you can check, if the result of a^3 is higher or lower than 627213431734272 and change a until you find the solution
Posted: Tue Feb 12, 2008 1:25 pm
by pdwyer
maybe you can write a div() function for us that outputs a string float! "3.141592654"
You need junior school math + basic string programming. Once you get something really basic then post it and others will help optimise it or give ideas. Thats how we wrote the last functions. We tend to stop when we have whatever solves our problem at that time. I didn't try div or mod for months after the others. If I need negative I will add those too later.
You need floats so please help by making a start

Posted: Tue Feb 12, 2008 1:39 pm
by Kwai chang caine
You need floats so please help by making a start
I will tried, with no garanty
Thanks for your help that move me a lot

Posted: Tue Feb 12, 2008 2:23 pm
by Michael Vogel
Floats must not be used for most of the commonly used math functions (add, mul, div,...) if you remember the number of ciphers after the floating point:
3.45 x 6.78 = 23.391
can be done with integer functions...
...because 345 x 678 = 233910
...and 2+2 decimal playes makes 4 places:
voilá: 23 . 3910
Posted: Tue Feb 12, 2008 2:30 pm
by pdwyer
interesting.
What happens with 1/3 ? ( can see for non recurring ones how this would work but for 0.3333333333333333. etc ?
Posted: Tue Feb 12, 2008 8:48 pm
by Michael Vogel
pdwyer wrote:interesting.
What happens with 1/3 ? ( can see for non recurring ones how this would work but for 0.3333333333333333. etc ?
You are right, of course (again one more reason, why I still haven't done a div routine until now

)
But doing calculation with floats is also a kind of allowing to be a liitle bit generous
Numbers like 0.1 and 0.2 are also rounded in their binary representation, so 1/3 would also be a situation to cut the precision after a specific number of digits.
Posted: Wed Feb 13, 2008 12:40 am
by pdwyer
You've given me some ideas (again

) I might have a play with this tonight.
For testing:
fdiv1()
that can only accept string floats as input and INTs them to div() them, drop the remainder and give the dec places it's got from there (so 1/3 will just come out as 0.3 etc) and do what is in your example above
fdiv2()
that can accept ints but gets the remainder from the mod and generates to x decimal places in a loop.
From there try to merge them into fdiv() which can accept floats and generate the extra decimal places.
Considering it's going to be using my integer div and mod functions it's going to be kind of slow.
See if I can beat you to generating pi to 1000 decimal places

(a long way off yet)
(this won't really be the answer to sqr() though. )