Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Why the square of a negative number is still negative
From
Austin Nichols <[email protected]>
To
[email protected]
Subject
Re: st: Why the square of a negative number is still negative
Date
Fri, 16 Dec 2011 11:37:19 -0500
Tiago V. Pereira <[email protected]>:
Just order of operations; `x'^2 or -2^2 is the negative of 2 squared
or -4, and if you want (-2)^2 you have to wrap your local in
parentheses.
On Fri, Dec 16, 2011 at 11:31 AM, Tiago V. Pereira
<[email protected]> wrote:
> Dear statalisters,
>
> Can someone explain why is this happening?:
>
> local x = -2
> */Approach A:
> dis (`x'^2)*(5)
> */Approach B:
> dis (`x'*`x')*(5)
> */Approach C:
> dis ((`x')^2)*(5)
>
>
> My output is:
>
> . dis (`x'^2)*(5)
> -20
>
> . */Approach B:
>
> . dis (`x'*`x')*(5)
> 20
>
> . */Approach C:
>
> . dis ((`x')^2)*(5)
> 20
>
>
> Do I need vacations? (Am I forgetting something very simple from
> mathematics?)
>
> All the best,
>
> Tiago
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/