# Is there a difference between a 1x1 matrix and a scalar?

**URL:** <https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621>\
**Category:** Factual Questions\
**Created:** [September 4, 2012, 6:22am UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621 "2012-09-04T06:22:17Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [September 5, 2012, 1:09am UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/21 "2012-09-05T01:09:48Z")

</div>

> [@](#):
>
> (And in just the same way as your argument, of course, there are programming languages which will not let you multiply integers by complex numbers, or add integers to rationals, or what have you, without inserting an explicit isomorphism…)

I don’t know Haskell, but in C, you can operate integers together with floats, and it’ll give you a warning when you compile, but it’ll probably give you something resembling what you were thinking of, but if you try to use any operation designed for numbers on a matrix of any size, it’ll complain mightily, and if it compiles at all, it’ll give you a result that’s completely unanticipated.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [September 5, 2012, 2:54am UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/22 "2012-09-05T02:54:02Z")

</div>

> [@Chronos](#):
>
> I don’t know Haskell, but in C, you can operate integers together with floats, and it’ll give you a warning when you compile, but it’ll probably give you something resembling what you were thinking of, but if you try to use any operation designed for numbers on a matrix of any size, it’ll complain mightily, and if it compiles at all, it’ll give you a result that’s completely unanticipated.

In C, you have to craft a program out of stone knives, bearskins, and sabres that are sharpened on both ends. I love the language, I do, but some aspects of it are more similar to juggling chainsaws on a freshly-waxed floor while wearing new socks than to what most people imagine as developing software.

OCaml is probably the most extreme example here: Its type system doesn’t allow for any promotion from integer to floating-point; it even has different functions for integer and floating-point arithmetic (e.g.: \* is integer multiplication, \*. (that’s ‘star-dot’) is floating-point multiplication). Haskell has a type system that is, in many ways, even stricter than OCaml’s, but Haskell does auto-promotion and only has one set of basic mathematical functions.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [September 5, 2012, 3:15am UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/23 "2012-09-05T03:15:17Z")

</div>

What kind of auto-promotion does Haskell do? You can’t + an Int and a Float, an Integer and a Float, a Float and a Double, or even an Int and an Integer in Haskell… You can only + two things that are of the same type, though, yes, that type can be any Num type.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [September 5, 2012, 3:23am UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/24 "2012-09-05T03:23:31Z")

</div>

(Where this gets confusing is that you can write, say, “3 + 5.1”. But that’s because 3 has the polymorphic type “Any Num type”, and the 5.1 has the polymorphic type “Any Fractional type”, and these two can be +ed if both are instantiated at the same type, for any type which is both Num and Fractional. But nothing is ever auto-promoted; in this case, the 3 was never of an Integral type. By way of contrast, you can’t write something like “length [1, 2, 3] + 5.1”, because length is defined to return Ints and 5.1 cannot be an Int.)

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [September 5, 2012, 5:51am UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/25 "2012-09-05T05:51:46Z")

</div>

> [@Indistinguishable](#):
>
> What kind of auto-promotion does Haskell do? You can’t + an Int and a Float, an Integer and a Float, a Float and a Double, or even an Int and an Integer in Haskell… You can only + two things that are of the same type, though, yes, that type can be any Num type.

You make a good point; what Haskell does works a lot like auto-promotion but there _are_ some differences, as you pointed out in your inevitable follow-up post.

So, compared to OCaml, Haskell looks like it has auto-promotion. That’s probably what I should have said.

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [September 5, 2012, 2:22pm UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/26 "2012-09-05T14:22:16Z")

</div>

> [@Indistinguishable](#):
>
> This is a bit like asking whether the integer 5 and the complex number 5 are the same. Indeed, it’s exactly like asking that…
> 
> Going along with **leahcim** , category theorists sometimes call asking (or, worse, answering) this sort of thing “evil”; they say you shouldn’t be talking about some ill-defined notion of equality, but about isomorphism instead, where the answer is cut-and-dry (once you specify what structure you consider relevant for the isomorphism).

As a working category theorist I have to go along with this, although I have never used “evil” this way (I’ve seen it though). It all depends on what you mean by “different”. As someone pointed out you cannot multiply a 1 x 1 matrix times an n x m matrix unless n = 1, so there is a difference.

Thinking about it, I would prefer to keep them separate. There is a similar question of whether a one dimensional vector space is the same as the field of scalars. Also whether an n-dimensional vector is the same an n x 1 matrix. It all depends on what you want to do with them. Context always matters.

---

<div class="post-metadata">

**Author:** ![leahcim](https://avatars.discourse-cdn.com/v4/letter/l/b4bc9f/32.png) [@leahcim](https://boards.straightdope.com/u/leahcim)\
**Post date:** [September 5, 2012, 3:22pm UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/27 "2012-09-05T15:22:47Z")

</div>

> [@Hari\_Seldon](#):
>
> Thinking about it, I would prefer to keep them separate. There is a similar question of whether a one dimensional vector space is the same as the field of scalars. Also whether an n-dimensional vector is the same an n x 1 matrix. It all depends on what you want to do with them. Context always matters.

The point is, some of these isomorphisms (like real numbers to complex numbers with imaginary part 0) are so “obvious” that no one even questions treating them as equalities except to make an obscure point about category theory. Others, like the one between complex numbers and a subset of 2x2 matrices are sufficiently obscure that no one would treat it as equality, except to make an obscure point about category theory.

Treating 1x1 matrices as being identical to the underlying field is somewhere in between the two extremes.

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [September 7, 2012, 10:44am UTC](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621/28 "2012-09-07T10:44:52Z")

</div>

> [@Indistinguishable](#):
>
> Sure you can… just as in the first example, use the interpretation of “x” as “The operation which multiplies a scalar by a matrix” rather than as “The operation which multiplies an m by n matrix by an n by r matrix”. Yes, this means there are various operations around named “x”; everyone already acknowledges that there’s various multiplication operations around in this context.
> 
> Also, going back to what **leahcim** remarked upon, is that there’s nothing special about 1-by-1 matrices, as such. The real question is whether we should identify “1” with “identity matrix”, which we might do for any particular size of matrix we care about. And some people are happy to do this in some contexts (surely we’ve all seen it…), and some people are not.

How is that isomorphism if one produces an answer and the other doesn’t? What’s the point of even calling it multiplication unless you are shooting for the same answer?

All this talk seems to go the route of saying that any symbol can have any interpretation, but that negates all of math. You need prescriptivism to make sense of it all.

[Previous page](https://boards.straightdope.com/t/is-there-a-difference-between-a-1x1-matrix-and-a-scalar/633621.md?page=1)
