|
|
Up |
|
|
  |
Author: Förster vom SilberwaldFö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 |
|
  |
|
Author: Chris RussellChris Russell Date: Oct 3, 2007 11:27
|
| |
|
| | no comments |
|
  |
Author: Szabolcs HorvátSzabolcs 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 |
|
  |
Author: Förster vom SilberwaldFörster vom Silberwald Date: Oct 3, 2007 11:35
On Oct 3, 7:27 pm, Szabolcs Horv
|
| |
| no comments |
|
  |
Author: Szabolcs HorvátSzabolcs 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 |
|
  |
Author: Joachim DurchholzJoachim 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 |
|
  |
Author: Brian HarveyBrian 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 |
|
  |
Author: Ken TiltonKen 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
|
| |
| no comments |
|
  |
Author: Duane RettigDuane 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 |
|
  |
|
|
  |
Author: Frank BussFrank Buss Date: Oct 3, 2007 17:06
Förster vom Silberwald wrote:
> What gives Haskell, OCaml?
|
| |
| no comments |
|
RELATED THREADS |
  |
|
|
|
|
|