Message Boards Message Boards

0
|
1663 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Testing for vector equivalence

Posted 1 year ago

Testing to see if a vector and matrix/vector product are equivalent does not yield true/false. I have the following:

v1={u,v,w}
M={{a,a},{b,b},{-c,c}}

and

v2={x,y}

the equation

v1=M.v2

is true. When testing using

v1==M.v2

it simply returns a result and not True/False

what it actually returns in my case is

{{{(\[Alpha] + \[Beta])/Sqrt[2]}}, {(\[Alpha] - \[Beta])/
       2}, {(\[Alpha] - \[Beta])/2}} == {{(\[Alpha] + \[Beta])/Sqrt[
       2]}, {(\[Alpha] - \[Beta])/2}, {(\[Alpha] - \[Beta])/2}}

which are clearly equivalent.

Why does it not return true?

POSTED BY: Ted Bartlett
6 Replies
Posted 1 year ago

The == is the infix form of Equal (http://reference.wolfram.com/language/ref/Equal.html). It only returns True or False if it can definitely determine the equality. If the terms have undefined values, the equality cannot be definitively determined. So, for example, a==b will not resolve and will just return unchanged (assuming you haven't defined a and b).

SameQ will always return either True or False. Its infix form is ===. So, a===b will return False (again assuming that the variables are undefined). If you had previously set a=1 and b=1, then a===b will return True. SameQ is basically looking for whether the two expressions are completely identical.

POSTED BY: Eric Rimbey
Posted 1 year ago

Thanks for the comments. It comes down to how Mathematica treats the solution.

bs1 = 1/Sqrt[2] ( {
    {1, 1},
    {1, -1}
   } )
state = ( {
   {\[Alpha]},
   {\[Beta]}
  } )

By introducing Flatten when evaluating u, it solves the problem.

\[ScriptU] = Simplify[First[Flatten[bs1.state]]]

works, but

\[ScriptU] = Simplify[First[bs1.state]]

does not, as it leaves the curly brackets around the answer, and as Eric pointed out, that carries through to my final solution. One further question - if the terms are NOT equivalent, why does Mathematica not return False?

POSTED BY: Ted Bartlett
Posted 1 year ago

The actual vectors/matrices that I am using are defined as:

state = ( {
   {\[Alpha]},
   {\[Beta]}
  } )

\[ScriptCapitalM]3 = ( {
   {1/Sqrt[2], 1/Sqrt[2]},
   {I/2, -(I/2)},
   {I/2, -(I/2)}
  } )

and

({(\[Alpha]+\[Beta])/Sqrt[2]}
(\[Alpha]-\[Beta])/2
(\[Alpha]-\[Beta])/2

)

the solution

{{{(\[Alpha] + \[Beta])/Sqrt[2]}}, {(\[Alpha] - \[Beta])/
   2}, {(\[Alpha] - \[Beta])/2}} == {{(\[Alpha] + \[Beta])/Sqrt[
   2]}, {(\[Alpha] - \[Beta])/2}, {(\[Alpha] - \[Beta])/2}}

or in a more readable format: enter image description here shows equivalence yet returns the above and not True.

POSTED BY: Ted Bartlett
Posted 1 year ago

Maybe just post all of the code. I don't know how you got "the solution". I don't know how you got the left hand side of the equality. I don't know how you got the right hand side of the equality. But again, what you posted actually shows that they are NOT equivalent. Look at the first terms.

POSTED BY: Eric Rimbey

What is \[ScriptCapitalM]3 for, is not used anywhere? As Eric suggested, please post complete code that can be evaluated to reproduce your results.

POSTED BY: Rohit Namjoshi
Posted 1 year ago

You need to be more clear. None of v1, v2, or M have any alpha or beta in them, so I can't tell how you got that result.

As for "clearly equivalent", no they are clearly NOT equivalent. There is an extra List layer in the first element of the left hand side.

If I follow your definition, I get this:

v1 = {u, v, w};
v2 = {x, y};
M = {{a, a}, {b, b}, {-c, c}};
v1 == M . v2

{u, v, w} == {a x + a y, b x + b y, -c x + c y}

So, there is no way it can determine equality.

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

Group Abstract Group Abstract