Message Boards Message Boards

How to simplify 1.w?

GROUPS:

How to simplify 1.w? w is any vector example: {1, 2, 3} 1 is a scalar, result of 1.w is 1.{1, 2, 3}, I want it to be {1, 2, 3}

POSTED BY: David Nova
Answer
17 days ago

. refers to the contraction (dot product) of two general tensors (array, list, matrix, vector). For example:

a.b

This will contract the last index of a with the first index of b. Scalar multiplication, what you want, can be written in (at least) 3 ways:

1{1,2,3}
1*{1,2,3}
Times[1,{1,2,3}]
POSTED BY: Sander Huisman
Answer
17 days ago
w = {1, 2, 3};

1. is an approximate real number. Multiplying an approximate real number times a list or array of exact numbers will produce a list or array of approximate real numbers.

1. w

(*  {1., 2., 3.}  *)

If you want exact numbers, use Rationalize

1. w // Rationalize

(*  {1, 2, 3}  *)
POSTED BY: Robert Hanlon
Answer
16 days ago

Group Abstract Group Abstract