Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.7K Views
|
5 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Why does Sqrt[2] have dimension {2}?

Hi!
I noticed that the Sqrt[2] (or for any other integer number higher then 1) has some strange dimensions and 2 additional numbers with it. If I use Sqrt[2.] or Sqrt[N[2]] then it's again just a number but given in a decimal format. What is going on?

Thank you!

5 Replies

Ah, I see! Thank you very much!

Posted 8 months ago
POSTED BY: Otto Linsuain

I suppose you're wondering about expression structure, for which one might look into some of the Tech Note links in the guide Expression Structure.

An expression in WL has the structure h[a, b,...] where h is called the Head and the number of "arguments" a, b,... is a nonnegative integer. For instance f[], f[x], f[x, y], f[x, y, z], etc.

  1. Parts of expressions. The parts of say h[a, b] are numbered: h is part 0, a is part 1, b is part 2. If k is a nonnegative integer, expr[[k]] returns part k if it exists. So h[a, b][[0]] returns h, h[a, b][[1]] returns a, and h[a, b][[2]] returns b. In the case of Sqrt[2] = Power[2, 1/2], part 0 is Power, part 1 is 2, and part 2 is 1/2.

  2. What Dimensions calculates. Dimensions[h[a, b]] returns {2} because the expression is a list of two arguments with head h. Dimensions[h[h[a, b, c], h[d, e, f]]] returns {2, 3} because the expression is a list of 2 expressions, each having a list of 3 arguments, and all with the same head h as at the top level. Dimensions[h[h[a, b, c], g[d, e, f]]] returns {2} because it is a list of two expressions, but each expression does not have the same head h. Dimensions[h[h[a, b, c], h[d, e]]] returns {2} because it is a list of two expressions, but each expression does not have the same length. Both head and length have to be the same for Dimensions to return a number for the next level.

  3. Numbers and numeric expressions. You were perhaps expecting Sqrt[2] to be a number. It is not, not in WL according to what is defined to be a number: NumberQ[Sqrt[2]] returns False. It is, instead, a numeric expression: NumericQ[Sqrt[2]] returns True. Power[2, 1/2] is an "exact" symbolic expression representing the real number $\sqrt{2}$. When you square it, you get the Integer 2 and not the Real 2. (Integer and Real are two types of numbers in WL, which you can look up.) It can be approximated to arbitrary precision. And generally it is used in computations as if it were the exact $\sqrt{2}$. But Power[2, 1/2] is an expression with parts and not a type of WL number.

POSTED BY: Michael Rogers

True, thank you. But the question is still there... Why does Power[2, 1/2] give 2 additional numbers to the main result?

Thank you

Sqrt[2] evaluates to Power[2, 1/2], which has dimensions {2}. Evaluate FullForm[Sqrt[2]] to see the actual expression.

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard