Message Boards Message Boards

[✓] Simplify 1.w? (w is any vector)

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
4 months 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
4 months 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
4 months ago

Group Abstract Group Abstract