Can't compute with dot product

Can't compute with dot product - Сообщения

#1 Опубликовано: 17.02.2011 12:46:32
cneily

cneily

0 сообщений из 5 понравились пользователям.

Группа: User

I have a calculation which involves dividing an expression which is the dot product of two 2-D column vectors (arrays) by another expression of the same kind. This quotient expression directly displays a correct result; however, if I try to store the quotient expression into a new variable it does not work, and displays the error message "Matrix must be square". I'm running version .89 (Build 8). This type of calculation is extremely common in mechanics problems so this is a serious issue.
#2 Опубликовано: 17.02.2011 14:31:59
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Hello,

I hope I understood you well. Here is an example:
[MATH=eng]A←mat(1,2,3,3,1)[/MATH][MATH=eng]B←mat(6,5,6,3,1)[/MATH][MATH=eng]C←mat(6,7,5,3,1)[/MATH][MATH=eng]D←mat(6,1,-2,3,1)[/MATH]
This gives you the result:
[MATH=eng]{A*B}/{C*D}=1.03[/MATH]
This will give an arror of "Matrix must be square" if you do not supress Symbolic optimization:
[MATH=eng]C←{A*B}/{C*D}[/MATH]
If you right click on it and choose Optimization|Numeric or None you will have the numerical result:
[MATH=eng]C=1.03[/MATH]

Symbolic engine of SMath is going to interpred the dividing of two arrays A/B as A*inverse( B ). Therefore the array B must be a square matrix. You can avoid this by suppressing the Symbolic optimization. I hope I am right about it.

Regards,
Radovan


When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Опубликовано: 19.02.2011 13:46:40
Edward Ulle

Edward Ulle

20 сообщений из 182 понравились пользователям.

Группа: Moderator

Subtle SMath difference in the multiplication of two vectors.

For two column vectors A and B, A*B is the dot product, and equal 34 in the example above.

More rigorously AT*B ( A transpose times B ) is the dot product.

If A were a row vector A*B would return a matrix (34) using the values for A and B above.

Doesn't solve the problem but interesting.
Ed
#4 Опубликовано: 19.02.2011 14:32:38
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Thank you Ed for the comment
Wrote


For two column vectors A and B, A*B is the dot product, and equal 34 in the example above.

More rigorously AT*B ( A transpose times B ) is the dot product.

If A were a row vector A*B would return a matrix (34) using the values for A and B above.


It seems you are right:
[MATH=eng]A*B=34[/MATH]
[MATH=eng]transpose(A)*B=mat(34,1,1)[/MATH]
I am in doubt now, as well as you are, that these two expressions should be the same and both should give a scalar. I am not quite sure about it. One explanation could be that the dot product is defined as the product of two vectors (column matrix). The second one might be ragarded as a matrix operation giving a matrix. However, I am also puzzled here:
[MATH=eng]{transpose(A)*B}/{transpose(C)*D}=1.03[/MATH]
I think this should be considered as a matrix expression and to give a matrix - but, surprisingly, it gives a scalar ???

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#5 Опубликовано: 19.02.2011 17:39:08
cneily

cneily

0 сообщений из 5 понравились пользователям.

Группа: User

Fala mnogu Radovan. Your first post solved my problem. Clark N.
#6 Опубликовано: 20.02.2011 03:56:58
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: Moderator

Wrote

Fala mnogu Radovan. Your first post solved my problem. Clark N.


You are welcome Clark
Just do not hesitate to ask whatever you need. Someone will help you here.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#7 Опубликовано: 22.12.2015 12:56:19
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

if I try to store the quotient expression into a new variable it does not work, and displays the error message "Matrix must be square".



_________________ Few more ... "Matrix must be square" __________________

You can try using "Local variable definition"

I have 3 examples of compulsory "Local var def"
1. De Boor spline
2. Quadratic spline coeficients
3. Cubic l_p_c_splinecoefficients

Work sheet would help.

Jean

  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений