POV-Ray : Newsgroups : povray.general : Re: Probably been asked... Why no power operator? Server Time
5 Aug 2024 12:18:18 EDT (-0400)
  Re: Probably been asked... Why no power operator? (Message 18 to 27 of 37)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Jerry
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:07:54
Message: <jerry-0B1C72.14075314112002@netplex.aussie.org>
In article <3dd3f208@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:
>AC <amb### [at] teliacom> wrote:
>> I don't think it would hurt to ask a math teachers (Highschool, Collage or
>> University)
>
>  One problem is that in math there's no power operator, so there is no
>operator precedence in the same sense. Only in computer languages there
>is a power operator.

Well, not really. You use superscripting to indicate power outside of 
computer languages. The power operator is used because most computer 
languages are typed on terminals that have difficulty accepting 
superscripts. I'd hazard a guess that the 'hat' is used solely because 
it has the effect of 'pointing up', i.e., saying that the next number is 
superscripted.

In my opinion, the power operator should act exactly as superscripting 
does. If

  2
-3

(You will need to be viewing that in a non-proportional font)

is -9, then -3^2 should also be -9; if the above is 9, then -3^2 should 
also be 9.

I'm fairly certain, however, that I remember from algebra that the 
superscripted would result in -9. What is the answer to:

22-3^2

?

I'll note that in the few calculators I have that allow typing in 
freeform, they are split on -3^2:

MoreCalculator:
-3**2
result=-9

bc:
-3^2
9

bwbasic:
bwBASIC: print -3^2
 9

python:
>>> -3**2
-9

perl:
echo print '-3**2, "\n"' | perl
-9

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

Either solution would be better than throwing out the operator, however.

Jerry
-- 
http://www.hoboes.com/jerry/
"Give a man a fish and you feed him for a day. Teach him to fish, and you've
depleted the lake."--It Isn't Murder If They're Yankees
(http://www.hoboes.com/jerry/Murder/)


Post a reply to this message

From: Slime
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:14:34
Message: <3dd4204a$1@news.povray.org>
> Doesn't 3^(-2) translate to sqrt(3)?


No, you're thinking of 3^(1/2). 3^(-2) is the same as 1/(3^2) = 1/9.

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


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Probably been asked... Why no power operator?
Date: 14 Nov 2002 17:19:51
Message: <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.


Post a reply to this message

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

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

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