www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why 2 ^^ 1 ^^ 2 = 2?

reply Ilya Yaroshenko <ilyayaroshenko gmail.com> writes:
.. i thought it should be (2 ^^ 1) ^^ 2 = 4
Oct 22
next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 22.10.2017 16:20, Ilya Yaroshenko wrote:
 .. i thought it should be (2 ^^ 1) ^^ 2 = 4
2 ^^ (1 ^^ 2) == 2 It is standard for ^/**/^^ to be right-associative. (This is also the standard convention in mathematics.)
Oct 22
next sibling parent kinbelle <1307838578 qq.com> writes:
On Sunday, 22 October 2017 at 14:44:04 UTC, Timon Gehr wrote:
 On 22.10.2017 16:20, Ilya Yaroshenko wrote:
 .. i thought it should be (2 ^^ 1) ^^ 2 = 4
2 ^^ (1 ^^ 2) == 2 It is standard for ^/**/^^ to be right-associative. (This is also the standard convention in mathematics.)
true
Oct 22
prev sibling parent reply Ivan Kazmenko <gassa mail.ru> writes:
On Sunday, 22 October 2017 at 14:44:04 UTC, Timon Gehr wrote:
 On 22.10.2017 16:20, Ilya Yaroshenko wrote:
 .. i thought it should be (2 ^^ 1) ^^ 2 = 4
2 ^^ (1 ^^ 2) == 2 It is standard for ^/**/^^ to be right-associative. (This is also the standard convention in mathematics.)
Yeah, and a height-3 tower $a^{b^c}$ (TEX notation) actually means "a to the power of (b to the power of c)", not the other way around. Otherwise, it can be written as $a^{b \cdot c}$, which is only a height-2 tower. The convention also makes at least the following sense. An expression like (((a ^^ b) ^^ c) ^^ d) ^^ e already has an almost bracket-free notation as a ^^ (b * c * d * e). So it is useful to have a bracket-free way to write the other-way-associative variant, a ^^ (b ^^ (c ^^ (d ^^ e))). Ivan Kazmenko.
Oct 22
next sibling parent Kagamin <spam here.lot> writes:
On Sunday, 22 October 2017 at 22:28:48 UTC, Ivan Kazmenko wrote:
 Yeah, and a height-3 tower $a^{b^c}$ (TEX notation) actually 
 means "a to the power of (b to the power of c)", not the other 
 way around.
Because you have explicit braces there. Math doesn't have precedence for exponentiation operator because it's written as a superscript, which is always unambiguous.
Oct 26
prev sibling parent reply Kagamin <spam here.lot> writes:
On Sunday, 22 October 2017 at 22:28:48 UTC, Ivan Kazmenko wrote:
 Yeah, and a height-3 tower $a^{b^c}$ (TEX notation)
Is $a^{b^c}$ the same as ${a^b}^c$ ? They are drawn slightly differently, so I suppose it's ambiguous indeed.
Oct 26
parent reply Ivan Kazmenko <gassa mail.ru> writes:
On Thursday, 26 October 2017 at 10:02:54 UTC, Kagamin wrote:
 On Sunday, 22 October 2017 at 22:28:48 UTC, Ivan Kazmenko wrote:
 Yeah, and a height-3 tower $a^{b^c}$ (TEX notation)
Is $a^{b^c}$ the same as ${a^b}^c$ ? They are drawn slightly differently, so I suppose it's ambiguous indeed.
Surely not the same. "3 to the power of (3 to the power of 3)" is "3 to the power of 27", or 7,625,597,484,987. "(3 to the power of 3) to the power of 3" is "27 to the power of 3", or 2187. For an argument, the TEX command "^" accepts either a single character or a bracket-enclosed string of arbitrary length. So $3^3^3$ indeed transforms to ${3^3}^3$, but not for some deeper reason this time. Ivan Kazmenko.
Oct 27
parent Q. Schroll <qs.il.paperinik gmail.com> writes:
On Saturday, 28 October 2017 at 00:14:15 UTC, Ivan Kazmenko wrote:
 For an argument, the TEX command "^" accepts either a single 
 character or a bracket-enclosed string of arbitrary length.  So 
 $3^3^3$ indeed transforms to ${3^3}^3$, but not for some deeper 
 reason this time.
On my TeX compiler, $3^3^3$ makes it give a warning/error.
Nov 01
prev sibling parent Igor Shirkalin <mathsoft inbox.ru> writes:
On Sunday, 22 October 2017 at 14:20:20 UTC, Ilya Yaroshenko wrote:
 .. i thought it should be (2 ^^ 1) ^^ 2 = 4
Imagine 2^^10^^10^^7. It's a big number, isn't? (up-up-and up) Where would you start from?
Nov 01