The right answer of -1^2 is?
  Home FAQ Contact Sign in
comp.lang.functional only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.functional Profile…
 Up
The right answer of -1^2 is?         


Author: Förster vom Silberwald
Date: Oct 3, 2007 11:13

Hello:

Please do not get worked out over my crossposting to lang.lisp,
lang.scheme, and lang.functionl.

There has been a discussion on heise.de about the following:

What is the correct answer of the following: -1^2

I had thought it is +1. My Bigloo Scheme gives: (expt -1 2) --> 1

However, the R language tailored to statistical calculations gives the
following: print(-1^2)
--> -1

Some have argued on heise.de that -1 is mathematically speaking the
right answer.

Thanks, for any some more insights into a not so easy problem I guess.
63 Comments
Re: The right answer of -1^2 is?         


Author: Chris Russell
Date: Oct 3, 2007 11:27

On 3 Oct, 19:13, F
no comments
Re: The right answer of -1^2 is?         


Author: Szabolcs Horvát
Date: Oct 3, 2007 11:27

Förster vom Silberwald wrote:
> Hello:
>
> Please do not get worked out over my crossposting to lang.lisp,
> lang.scheme, and lang.functionl.
>
> There has been a discussion on heise.de about the following:
>
> What is the correct answer of the following: -1^2
>
> I had thought it is +1. My Bigloo Scheme gives: (expt -1 2) --> 1
>
> However, the R language tailored to statistical calculations gives the
> following: print(-1^2) --> -1
>
> Some have argued on heise.de that -1 is mathematically speaking the
> right answer.
>
> Thanks, for any some more insights into a not so easy problem I guess.
Show full article (0.95Kb)
no comments
Re: The right answer of -1^2 is?         


Author: Förster vom Silberwald
Date: Oct 3, 2007 11:35

On Oct 3, 7:27 pm, Szabolcs Horv
no comments
Re: The right answer of -1^2 is?         


Author: Szabolcs Horvát
Date: Oct 3, 2007 11:58

Förster vom Silberwald wrote:
> After 300 meassges on heise.de I gave up on reading because it turned
> out there are two camps: -1 and +1.
>
> I also thought +1 would be the right answer and the sign belongs to
> the number.

There is no right answer, only conventions. Different languages use
different conventions. If you're writing mathematics, then it's better
to use parenthesis to avoid confusion.
> They were arguing the opposite then for a=1: 0 - a^2 = -1
>
> I would have been interested how functional languages (though it is
> not necessarily related to functional programming) treat such a
> problem.
>
> What gives Haskell, OCaml?

It seems that in OCaml the negation operator is more tightly binding
than the power.

-.1.**2. gives 1.
Show full article (0.78Kb)
no comments
Re: The right answer of -1^2 is?         


Author: Joachim Durchholz
Date: Oct 3, 2007 12:32

Förster vom Silberwald schrieb:
> There has been a discussion on heise.de about the following:
>
> What is the correct answer of the following: -1^2

Mathematically, since ^ binds more tightly than */, which in turn binds
more tightly than +-, it's -(1^2).

Regards,
Jo
no comments
Re: The right answer of -1^2 is?         


Author: Brian Harvey
Date: Oct 3, 2007 13:04

Joachim Durchholz durchholz.org> writes:
>Mathematically, since ^ binds more tightly than */, which in turn binds
>more tightly than +-, it's -(1^2).

Sure is a good thing, isn't it, that in God's programming language we don't
have infix operators!
no comments
Re: The right answer of -1^2 is?         


Author: Ken Tilton
Date: Oct 3, 2007 14:25

Joachim Durchholz wrote:
> Förster vom Silberwald schrieb:
>
>> There has been a discussion on heise.de about the following:
>>
>> What is the correct answer of the following: -1^2
>
>
> Mathematically, since ^ binds more tightly than */, which in turn binds
> more tightly than +-, it's -(1^2).

Thats a - of a different color.

kt

--
http://www.theoryyalgebra.com/

"We are what we pretend to be." -Kurt Vonnegut
no comments
Re: The right answer of -1^2 is?         


Author: Duane Rettig
Date: Oct 3, 2007 16:56

Förster vom Silberwald hotmail.com> writes:
> Hello:
>
> Please do not get worked out over my crossposting to lang.lisp,
> lang.scheme, and lang.functionl.
>
> There has been a discussion on heise.de about the following:
>
> What is the correct answer of the following: -1^2
>
> I had thought it is +1. My Bigloo Scheme gives: (expt -1 2) --> 1
>
> However, the R language tailored to statistical calculations gives the
> following: print(-1^2) --> -1
>
> Some have argued on heise.de that -1 is mathematically speaking the
> right answer.
>
> Thanks, for any some more insights into a not so easy problem I guess.
Show full article (1.19Kb)
no comments
Re: The right answer of -1^2 is?         


Author: Frank Buss
Date: Oct 3, 2007 17:06

Förster vom Silberwald wrote:
> What gives Haskell, OCaml?

Haskell:

Prelude> -1^2
-1

Mathematica returns the same: http://www.mathe-online.at/Mathematica/

--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
no comments

RELATED THREADS
SubjectArticles qty Group
PASS Geo-Geotude-1.0 amd64-freebsd 6.2-releaseperl.cpan.testers ·
PASS Net-Twitter-1.04 i686-linux-thread-multi-64int-ld 2.6.16.38perl.cpan.testers ·
PASS IPC-SysV-1.99_02 alpha-netbsd 2.1.0_stableperl.cpan.testers ·
PASS WWW-Search-2.497 i686-linux-64int 2.6.22-1-k7perl.cpan.testers ·
PASS Games-RolePlay-MapGen-1.2.20 i386-netbsd-thread-multi-64int 3.1perl.cpan.testers ·
PASS HTML-SuperForm-1.04 i686-linux 2.6.22-14-genericperl.cpan.testers ·
PASS Tree-BPTree-1.08 i386-freebsd-thread-multi-64int 6.2-releaseperl.cpan.testers ·
PASS SOAP-WSDL-2.00_33 i686-linux-64int 2.6.22-1-k7perl.cpan.testers ·
Smoke [5.11.0] 33949 PASS linux 2.4.25-fl1.1 [debian] (i686/1 cpu)perl.dailybuild.reports ·
PASS Net-SSH-Expect-1.04 amd64-freebsd 6.2-prereleaseperl.cpan.testers ·
1 2 3 4 5 6 7