POV-Ray : Newsgroups : povray.general : Re: Probably been asked... Why no power operator? Server Time
5 Aug 2024 12:21:20 EDT (-0400)
  Re: Probably been asked... Why no power operator? (Message 21 to 30 of 37)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 7 Messages >>>
From: Greg M  Johnson
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:20:57
Message: <3dd421c9$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3dd4073d@news.povray.org...
> Jellby <jel### [at] m-yahoocom> wrote:
> > Wouldn't it be possible to have *both* 3^-2 and -3^2 generate an error
>
>   That would be illogical.
>

warning then mon.


Post a reply to this message

From: Alan Kong
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:24:59
Message: <hr78tu0f6n273u6b5hrb8prkdr58iijtga@4ax.com>
On Thu, 14 Nov 2002 16:54:54 -0500 "Greg M. Johnson"
<gregj:-)565### [at] aolcom> wrote:

>How is this off-topic?

  Greg, it's off-topic when people argue a point for the argument's
sake. It's not a real discussion, as the same points are brought up
again and again. It's a request to conserve server resources, but people
are free to post as they see fit. Let me know when a consensus is
reached in this thread, okay? ;)

  Please remember that the number of participants on this news server
make up only a small percentage of people who download and use POV-Ray.
When a feature is implemented and a debate results, both the TAG and
POV-Team may have to answer support questions by e-mail, which is much
more time consuming than responses to news server queries. Frankly, if
problems with the use of the power operator in the 3.5 beta were to
generate a proportional response from the outside POV-Ray community, we
wouldn't have the time to deal with it.

  I personally *liked* using the hat operator, but I could easily see
the problems it caused early on for some.

-- 
Alan
ako### [at] povrayorg
a k o n g <at> p o v r a y <dot> o r g


Post a reply to this message

From: Slime
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:29:35
Message: <3dd423cf$1@news.povray.org>
> Um, no. In algebra, there is no precedence, the exponent is in
> superscript, so there is no ambiguity. A plain text programming language
> doesn't have this, an operator has to be used, so it has to pick a
> precedence. I don't know what you were taught...


I was taught that

-(3^2) = -3^2

and that

(-3)^2 != -3^2

Of course, when it was written on a chalkboard, instead of "^2", the teacher
wrote a superscripted 2. But the meaning is identical. Just because we omit
the operator itself when we write it with pencil and paper doesn't mean that
the *operation* doesn't exist. The importance is in the order of operations,
and those go:

1. exponentiation
2. multiplication/division
3. addition/subtraction

Unary negation exists in the 3rd group. The only problem is when you have
something like

2*-3

because then you have two operators in a row. For convenience, this is
assumed to be 2*(-3), since that's the only possible meaning that can be
derived from it.

Similarly, 3^-2 should be considered 3^(-2), since that's the only possible
interpretation.

The debate is over what happens in this case:

-a(operator)b

In the case of multiplication, the order doesn't matter; the result is the
same either way. But in the case of exponentiation, the order *does* matter,
and the negation should happen second.

What could be said is that the negation happens second in the case of
multiplication, also, but since the result is the same, no one knows the
difference. And the only reason it happens first in the case of
a(operator)-b is because that's nothing more than a shortcut for
a(operator)(-b), as there is no other interpretation of the expression.

So that's my argument for why unary negation should happen along with
addition/subtraction, except in the cases where parenthesis are being
dropped.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Johannes Dahlstrom
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:38:50
Message: <3dd425f9@news.povray.org>
Timothy R. Cook wrote:

> Doesn't 3^(-2) translate to sqrt(3)?
> 

Nope, 3^(-2) == 1/(3^2). 3^(1/2) == sqrt(3).


Post a reply to this message

From: TinCanMan
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:52:14
Message: <3dd4291e$1@news.povray.org>
"Slime" <slm### [at] slimelandcom> wrote in message
news:3dd423cf$1@news.povray.org...
> the *operation* doesn't exist. The importance is in the order of
operations,
> and those go:
>
> 1. exponentiation
> 2. multiplication/division
> 3. addition/subtraction
>

don't forget brackets supercede everything: hence 'BEDMAS'

Brackets
Exponents
Divison*
Multiplication*
Addition**
Subtraction**

D&M,A&S are interchangeable of course, they are just in that order fo the
mnemonic.

-tgq


Post a reply to this message

From: Jellby
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 18:25:44
Message: <3dd430f8@news.povray.org>
Jerry wrote:

> But all of them give 13 as the answer to 22-3^2 :*)

You are lucky. I once had a pocket calculator that said:

2[cubic-root-sign]8 = 2

:P

-- 
Ignacio Fernández Galván
Linux User #289967 (counter.li.org)
PGP Pub Key ID: 0x01A95F99 (pgp.escomplinux.org)


Post a reply to this message

From: Slime
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 19:01:50
Message: <3dd4396e$1@news.povray.org>
> don't forget brackets supercede everything: hence 'BEDMAS'


Of course. I left that out along with 30 or so other operators =) (although
the POV-Ray SDL doesn't really support that many).

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 20:00:07
Message: <web.3dd4440dc24ffac838149fba0@news.povray.org>
Christopher James Huff wrote:
>In article <3dd3cb3c$1[at]news.povray.org>, "Slime" <slm### [at] slimelandcom>
>wrote:
.....
>> Besides, I would think that since we're adding ^ as a new operator, we could
>> give it whatever precedence we wanted, and it just seems more logical to me
>> to make it work the way we've been taught it should work than to allow the
>> 2^-3 syntax just for convenience.
>
>Not for convenience, for self consistency. There isn't an existing rule,
>so the one that was most logical and consistent was chosen.

How about just requiring that the hat
operator should always be preceeded
by a pair of parantesis.

Like this:   ( )^

E.g.:   (3)^-3 or (-4)^2


Tor Olav


Post a reply to this message

From: AC
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 23:18:11
Message: <3dd47583@news.povray.org>
"Greg M. Johnson" <gregj:-)565### [at] aolcom> wrote in message
news:3dd42187$3@news.povray.org...
> "AC" <amb### [at] teliacom> wrote in message news:3dd3e7b2@news.povray.org...
> >
> > My vote would be on -3^2=9
> >
>
>
> The problem is that you're more likely to have   4^2-3^2.
>
>
>
>
good point... looking at it this way  think I will have to change my mind...
Ambis


Post a reply to this message

From: gilroy
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 23:20:05
Message: <web.3dd46f2ec24ffac8749cd9ce0@news.povray.org>
Christopher James Huff wrote:
>In article <3dd3cb3c$1[at]news.povray.org>, "Slime" <slm### [at] slimelandcom>
>wrote:
>
>> Well, to say there's no mathematical reason doesn't seem entirely correct.
>> Most everyone is taught that exponentiation comes before negation in an
>> early algebra class. It's the way we've been taught to think.
>
>Um, no. In algebra, there is no precedence, the exponent is in
>superscript, so there is no ambiguity. A plain text programming language
>doesn't have this, an operator has to be used, so it has to pick a
>precedence. I don't know what you were taught...

I'm not sure I understand.  If I read - 2 sup 3, I would interpret it as -(2
sup 3) = -8, just like 4 - x^3 would mean "four minus the cube of x" and
not "four plus the cube of minus x".  And I am not symbolic expert but I've
done my fair share of heavy lifting in mathematics.  I'm pretty sure many,
if not most, people would read it the same way.

On the other hand, if the issue is the parsing of 2^-3, I can see a problem.
 Since in algebra it's a real superscript, it's clear this would be "two to
the power of minus 3", but to a computer parsing plaintext, it's awkward.
Does - bind more tightly than ^?  I can see the issue.  But I'm not sure I
agree with the "solution".

The simplest way out would seem, to my eye, to disallow 2^-3 -- make it a
syntax error for ^ to be followed by anything but a number, an identifier,
or a parenthesis.  It would be annoying, when one used "2^-3" to have to
check the documentation and to have to learn a "different" way of seeing
things.  But that's much preferable to stripping out a useful operator and
cluttering up lines and lines of scene code.  If it's a little harder for
the computer, or a little harder for humans, shouldn't the humans win?

>
>
>> Besides, I would think that since we're adding ^ as a new operator, we could
>> give it whatever precedence we wanted, and it just seems more logical to me
>> to make it work the way we've been taught it should work than to allow the
>> 2^-3 syntax just for convenience.
>
>Not for convenience, for self consistency. There isn't an existing rule,
>so the one that was most logical and consistent was chosen.
>
>Christopher James Huff <cja### [at] earthlinknet>
>http://home.earthlink.net/~cjameshuff/
>POV-Ray TAG: chr### [at] tagpovrayorg
>http://tag.povray.org/
>


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 7 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.