Page 2 of 3

Re: operator ^ for power

Posted: Thu Sep 24, 2015 9:19 am
by Lord
I think that math rules have been "bowed" by programmers of math parser. :D
x=-9^0.5 hasn't to be handeled like x=0-9^0.5

You have to use paranthesis to make clear what really is meant:
x=-9^0.5 = i*3
or
x=-(9^0.5)=-3

Re: operator ^ for power

Posted: Thu Sep 24, 2015 10:24 pm
by jack
Little John is right, however if you write your own expression evaluator then you can make it do whatever you want

Re: operator ^ for power

Posted: Fri Sep 25, 2015 5:58 am
by said
Lord wrote:I think that math rules have been "bowed" by programmers of math parser. :D
Sadly enough, this is very true :x
One cannot accurately talk about ‘math rules’ here … (these are operator precedence rules not math rules) and it is all about conventions, by definition a convention is never right or wrong and anyone is free to use whatever convention he finds suitable. This issue was introduced by programming languages in the first place … to my knowledge, the only convention that is widely accepted and adhered to by the math community is the use of brackets, the remaining is just a matter of choice (many times those conventions have simply created very confusing situations)

and yes the common math interpretation of
-9^0.5 is i*3 not -3 :!:

As for the original feature request, it is surely more consistent to use ^ than Pow(), but regarding the operators precedence overall, i would suggest to stick to a much simpler and flat rule (left to right or right to left) and ignore various priorities ... my 2 cents!

Re: operator ^ for power

Posted: Fri Sep 25, 2015 8:13 am
by Little John
said wrote:
Lord wrote:I think that math rules have been "bowed" by programmers of math parser. :D
Sadly enough, this is very true :x
Only someone who doesn't have sufficient knowledge in this field can write something like that.
said wrote:One cannot accurately talk about ‘math rules’ here … (these are operator precedence rules not math rules)
Maybe it's new to you, but there are actually operator precedence rules in mathematics. That's what I was talking about all the time here. Read this, please. If you can't understand it, feel free to read a good textbook of your choice, or ask a math teacher.
said wrote:and it is all about conventions, by definition a convention is never right or wrong and anyone is free to use whatever convention he finds suitable.

Oh well, tell your math teacher that you find the convention "2+2 = 5" suitable ... :D
said wrote:and yes the common math interpretation of
-9^0.5 is i*3 not -3 :!:
Interesting, you know what the "common" interpretation of this expression is?
Did you perform a survey in a representative sample, or what :?: :?:

I asked all mathematicians that I know, and in this group, the "common interpretation" is that
-9^0.5 = -(9^0.5) = -3

So once again: My parser works according to the established math rules, regardless whether any layman does know them or not.

Of course, everyone else is free to write her/his own parser that does whatever s/he wants.

Re: operator ^ for power

Posted: Fri Sep 25, 2015 8:41 am
by Lord
I think, it was a wise choice by Fred not to implement "^" instead of Pow().
With Pow() you have to know what is meant and what you have to do when you want to evaluate -9^0.5.
Thank you Fred! :D

Re: operator ^ for power

Posted: Fri Sep 25, 2015 3:14 pm
by jwrjrjwrjr
Lord wrote:I think, it was a wise choice by Fred not to implement "^" instead of Pow().
With Pow() you have to know what is meant and what you have to do when you want to evaluate -9^0.5.
Thank you Fred! :D
On the other hand you can make "^" do anything you want it to by judicious use of ()!

Re: operator ^ for power

Posted: Fri Sep 25, 2015 10:37 pm
by said
Little John wrote:
said wrote:
Lord wrote:I think that math rules have been "bowed" by programmers of math parser. :D
Sadly enough, this is very true :x
Only someone who doesn't have sufficient knowledge in this field can write something like that.
said wrote:One cannot accurately talk about ‘math rules’ here … (these are operator precedence rules not math rules)
Maybe it's new to you, but there are actually operator precedence rules in mathematics. That's what I was talking about all the time here. Read this, please. If you can't understand it, feel free to read a good textbook of your choice, or ask a math teacher.
said wrote:and it is all about conventions, by definition a convention is never right or wrong and anyone is free to use whatever convention he finds suitable.

Oh well, tell your math teacher that you find the convention "2+2 = 5" suitable ... :D
said wrote:and yes the common math interpretation of
-9^0.5 is i*3 not -3 :!:
Interesting, you know what the "common" interpretation of this expression is?
Did you perform a survey in a representative sample, or what :?: :?:

I asked all mathematicians that I know, and in this group, the "common interpretation" is that
-9^0.5 = -(9^0.5) = -3

So once again: My parser works according to the established math rules, regardless whether any layman does know them or not.

Of course, everyone else is free to write her/his own parser that does whatever s/he wants.
I am very confident about every single word I wrote … there is nothing new in this subject, the first works on this started back in 1550! Anyone can consult a good math text book or check with some math prof

LJ, obviously your knowledge in math is very basic since you don’t seem to know the difference between a math rule and a convention, there is no point in extending this discussion, bye :)

Re: operator ^ for power

Posted: Sat Sep 26, 2015 6:18 am
by Little John
I am very confident about every single word I wrote …
So you are still missing the point, and didn't understand what I wrote in this thread.
LJ, obviously your knowledge in math is very basic
Of course, this is "obvious" to you.

Image
there is no point in extending this discussion
Yes, you have demonstrated this.
bye
So you will stop attacking the work by other people that you do not understand? Fine.

Re: operator ^ for power

Posted: Sat Sep 26, 2015 6:26 am
by Little John
Back to topic
jwrjrjwrjr wrote:On the other hand you can make "^" do anything you want it to by judicious use of ()!
Yep, just like we can do with the already existing operators in PB.

Re: operator ^ for power

Posted: Sat Sep 26, 2015 11:22 am
by Lord
Help wrote: Priority Level | Operators
---------------+---------------------
8 (high) | ~, - <--- look for this minus sign
7 | <<, >>, %, !
6 | |, &
5 | *, /
4 | +, -
3 | >, >=, <, <=, =, <>
2 | Not
1 (low) | And, Or, XOr
Why has the above minus sign the highest priority?
Because "-9^0.5" is not the same as "-(9^0.5)".
Again, math rules are something different than programming rules.
A programmer can make everything he wants.
But when a mathematician gives a programmer "-9^0.5" you have
to evaluate according to mathematic rules and not according to
programmers rules or conventions (if you are not writing a parser
only for programmes :mrgreen: ).

Re: operator ^ for power

Posted: Sat Sep 26, 2015 11:46 am
by Little John
Lord wrote:when a mathematician gives a programmer "-9^0.5" you have
to evaluate according to mathematic rules
That's what my parser does, as I wrote here repeatedly.
And the mathematical result of this expression clearly is nothing else but -(9^0.5) = -3
(there is already a lot of information about this in this thread).

Re: operator ^ for power

Posted: Sat Sep 26, 2015 12:45 pm
by Lord
Little John wrote:
Lord wrote:when a mathematician gives a programmer "-9^0.5" you have
to evaluate according to mathematic rules
...
And the mathematical result of this expression clearly is nothing else but -(9^0.5) = -3
....
Sorry, but still this is not true.
-9^0.5 = i*3 is the only correct answer.
But forget it, as I'm not in need for an parser from you.

Re: operator ^ for power

Posted: Sat Sep 26, 2015 1:02 pm
by Little John
Lord wrote:-9^0.5 = i*3 is the only correct answer.
This statement will not become true, regardless how often you will repeat it.
Lord wrote:But forget it, as I'm not in need for an parser from you.
Since your are not in need of a parser from me, and since I certainly did not write it for people like you,
then why don't you just forget my parser, and stop posting nonsense about it?

Re: operator ^ for power

Posted: Sat Sep 26, 2015 3:33 pm
by GPI
https://en.wikipedia.org/wiki/Dunning%E ... ger_effect

:)

@lord the Prio-list you post is from PB - and it doesn't involke a power-operator. And normaly you don't have a seperate operator for a sign.

other examples of the power-operator
http://www.berkhan.com/basic/manual_7/m ... Operatoren
My perfered basic on the good old Atari ST
Example: PRINT -3^2, (-3)^2, 3*1 SHL 2, (3*1) SHL 2
Result: -9 9 12 12

Visual Basic:
https://msdn.microsoft.com/de-de/library/zh100ckf.aspx
exp4 = -5 ^ 4 würde z. B. – (5) vierten Potenz berechnet, die -625 führen würde

It seems that a minus at the beginning must be interpreted as "0-". The Problem is, that the only operator whitch this is important is the power operator.

Also in Wikipedia:
https://en.wikipedia.org/wiki/Exponentiation
The always write : (−1)n = 1

I think this rule come from Variables: - a ^ b = -(a^b)
nobody would say that the minus is a sign because there is no numeric!
So - 2 ^ 3 must be -(2^3) otherwise -a ^b would be a forbidden sentence.

Please give me a example of -2^3 is (-2)^3. A link to serious web side which that that it is common.

Re: operator ^ for power

Posted: Sun Sep 27, 2015 1:27 am
by said
GPI wrote:Please give me a example of -2^3 is (-2)^3. A link to serious web side which that that it is common.
In Microsoft Excel, just type the following as is

Code: Select all

=-9^2
the example -2^3 is not well chosen because it will lead to -8 in all cases!