HUGE Arithmetic BUG !!!

Everything else that doesn't fall into one of the other PB categories.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

so you think purebasic is handling this the right way..

but again you are probaly right at the 0^0 is indefinate, but after understanding that i still think purebasic puts out the right answer.
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Psychophanta wrote:...and MrMat, never forget that conveniences are always human interests :wink:
Of course :) And if it's taken 100's of years of arguments between far cleverer people than us to agree on what the answer is then what chance do we have? :wink:
Mat
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

Another explanation:

The power is short writing for
x^n = x*x*x*x...,
similar to n*x for x+x+x+x...,
similar to UNION {k from 1 to n} M_k = M_1 union M_2 union M_3 ... union M_k
similar to SECTION {k from 1 to n} M_k = M_1 section M_2 ... section M_k,

What I mean is:
All of them are defined for NONE elements (e.g. the sum from 1 to 0 of elements, or a product of no elements, etc.) to the NEUTRAL element of the according operation.
So the sum from 1 to 0 gives 0 per definition, the UNION from 1 to 0 gives the empty set, the SECTION gives the whole set's universe instead. And so gives x^0 the same as 0^0 = 1 (the neutral element of multiplication), the same for faculty: 0! = 1

This is the explanation for this stuff I heard at university, but I like MrMats explanation, too!
btw PI=3 :)
%1>>1+1*1/1-1!1|1&1<<$1=1
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

PI = 3
:lol:

okay so from your post i see that you agree that pb should act the way it does.

okay, i belive you stop calling me a donkey!!
and psycopanta: you have more important things to do: viewtopic.php?p=88505#88505
:twisted:
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Froggerprogger wrote:x^n = x*x*x*x...,

What I mean is:
All of them are defined for NONE elements (e.g. the sum from 1 to 0 of elements, or a product of no elements, etc.) to the NEUTRAL element of the according operation.
So the sum from 1 to 0 gives 0 per definition, the UNION from 1 to 0 gives the empty set, the SECTION gives the whole set's universe instead. And so gives x^0 the same as 0^0 = 1 (the neutral element of multiplication), the same for faculty: 0! = 1
It's also defined for a zero value x with finite n, in which case 0^n = 0*0*0*0... = 0, which leads us back to the same problem!
thefool wrote:so you think purebasic is handling this the right way..

but again you are probaly right at the 0^0 is indefinate, but after understanding that i still think purebasic puts out the right answer.
I agree it is giving the 'right' (the useful!) answer. If anyone was ever doing limits in PureBasic then they'd have to think carefully about what is going on, but if they were doing limits they'd probably be using a computer algebra package like Mathematica in the first place... So i think we can agree Fred got it right! :lol:
Mat
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Go out, watch TV, meet friends, code something... :twisted:
Good programmers don't comment their code. It was hard to write, should be hard to read.
jack
Addict
Addict
Posts: 1358
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

if 0^0=1 is an error then exp(0)=1 should be an error also. :shock:
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

thefool wrote:okay, i belive you stop calling me a donkey!!
and psycopanta: you have more important things to do: viewtopic.php?p=88505#88505
:twisted:
:lol: Weeelll, okay, i am in a doubt with you, you can insult me once, but please with logical arguments, ehhh!?


jack wrote:if 0^0=1 is an error then exp(0)=1 should be an error also. :shock:
I say 0^0=1 is an error because it is a CONVENIENCE, so it is not a valid math equation, but a concrete interest for a concrete situation. If maths are convenience interests, then science would be idealism. :o

exp(0) ? Whats that?

The best explanation given here is not lim x^0 as x->0+ , neither lim 0^x as x->0+ , but lim x^x as x->0+ that's the more correct and humble answer :!: :D
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Its the fact that the answer (to most people who will see 0^0) is expected to be 1.

Most modern calculators will display 1.

Most textbooks will say, "unknown state, but take the result to be 1" or "can be replaced by 1".

If your so convinced that its incorrect, then check for it beforehand and make the appropriate changes to your code. It is a programming language after all, not a simple calculator - it should be an easy check you you to make. It will make you happy and contented. ;)

I personally check for division by zero (another equation that can have 2 possible answers, neither of them being possible to be represented by PureBasics REAL number system, that itself is inherited from the x86). I'd rather not really on the processor interpreting the result and presenting the user with an error condition because the processor just crashed.

I'd also suggest writing a petition to all the major calculator and processor manufacturers, telling them they much introduce another error condition into their systems if your really that bothered as to continue this thread to 3-4 pages. :twisted:
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Putting apart the whole subject, do you guys realize this is a binary discussion? (0s and 1s :lol: ).
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

A good way to understand why x^0 should always be one is to plot a graph of the following:

Code: Select all

i = 2

For e = -5 To 5 
  Debug Pow(i,e)
Next e
Trying changing i. For whatever value you have the following is true:

i to the power of a positive number will give you a value greater than 1.
i to the power of a negative number will give you a value between 0 and 1.

If you make i to the power of 0, 0, then your graph will not be continuous. It will approach 1, leap to 0, and the leap back up to close to 1.

Like in the following:

Code: Select all

Debug Pow(10, 0.0001)
Debug 0
Debug Pow(10, -0.0001)
Making Pow(i, 0) always 1 will give a continuous graph.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

All of you are making me to repeat it, because it looks like you didn't see.
The best explanation given here is not lim x^0 as x->0+ , neither lim 0^x as x->0+ , but lim x^x as x->0+ that's the more correct and humble answer
i^0 or 0^i are expressions where there is in advance supossed i<>0, and is just here where the confusion (or convention) lies.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Psychophanta wrote:
thefool wrote:okay, i belive you stop calling me a donkey!!
and psycopanta: you have more important things to do: viewtopic.php?p=88505#88505
:twisted:
:lol: Weeelll, okay, i am in a doubt with you, you can insult me once, but please with logical arguments, ehhh!?
i can insult you WITHOUT logical arguements if you want :twisted:

okay i belive that x^0 is only 1 if x>0 .
but i also belive the answer should be 1 in this case.. :)

okay enough discussion,..!
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

thefool wrote:i can insult you WITHOUT logical arguements if you want :twisted:
Yes, but don't forget that in that cases the receptor acts as a mirror :P
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

lim x^x as x->0+
What on earth does that actually mean?

If nobody understands it is better to reiterate rather than repeat.
Post Reply