       Re: Matrices, TraditionalForm and Two Equal Signs

• To: mathgroup at smc.vnet.net
• Subject: [mg100921] Re: Matrices, TraditionalForm and Two Equal Signs
• From: pfalloon <pfalloon at gmail.com>
• Date: Thu, 18 Jun 2009 04:53:39 -0400 (EDT)
• References: <h19i25\$p00\$1@smc.vnet.net>

```On Jun 17, 11:48 am, C Rose <uk.org.micros... at googlemail.com> wrote:
> Hi all
>
> I'm trying to display a matrix-vector multiplication in
> TraditionalForm. Let A and B be undefined, and let a and b be 2x2 and
> 2x1 matrices respectively. If I do:
>
> A B == a.b == N[a.b] // TraditionalForm
>
> then I get the product AB, followed by an equality sign, followed by
> the resulting 2x1 matrix, but I don't get the following equality sign
> and numerical approximation of the dot product.
>
> If I do:
>
> A B == N[a.b] // TraditionalForm
>
> then I do get to see the numerical approximation.
>
> If x and y are undefined and z is set to 1/2, and I do:
>
>
> then I get what I would expect: "x=y=0.333333".
>
> I imagine a call to Hold or similar is the answer, but I'm failing to
> find a solution. I'd be very grateful if someone could explain why the
> same notation applied to matrices leaves off the rightmost part of the
> equation.
>
> Best regards
>
> Chris

It looks like what's happening is that the equality is being
simplified: Mathematica recognizes that a.b == N[a.b] is True, and so
drops the last part.

As you say, one way around this would be to use a Hold construct. It's
a bit fiddly because you need the a.b and N[a.b] to evaluate before
applying the Hold. The following is one way to do this (there is
probably a neater way):

HoldForm[#1 == #2 == #3] &[A B, a.b, N[a.b]] // TraditionalForm

By using this anonymous function construct, the three arguments to
Equal are first evaluated, then the HoldForm prevents further
evaluation.

Another, possibly simpler, solution would be to use a Row construct:

Row[{A B, " \[Equal] ", a.b, " \[Equal] ", N[a.b]}] // TraditionalForm

The downside here is that this can no longer be evaluated (whereas in
the previous case you could use ReleaseHold) -- though this is
probably not an issue.

```

• Prev by Date: Re: Re: Combined Set, SetDelayed
• Next by Date: Re: erroneous result when adding reals