login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for Computing with Vectors revision 4 of 4

1 2 3 4
Editor: test1
Time: 2015/05/08 16:20:50 GMT+0
Note:

changed:
-v.2
v(2)

changed:
-v.3 := 99
v(3) := 99

How to multiply two vectors??

Multiplication element by element:

Vanuxem Gregory replies:

Try

fricas
(1) -> a:= vector [1,2,3,5,6]

\label{eq1}\left[ 1, \: 2, \: 3, \: 5, \: 6 \right](1)
Type: Vector(PositiveInteger?)
fricas
map(*,a,a)

\label{eq2}\left[ 1, \: 4, \: 9, \:{25}, \:{36}\right](2)
Type: Vector(PositiveInteger?)

otherwise use Matrix:

fricas
a:= matrix [[1,2,3,4,5,6]]

\label{eq3}\left[ 
\begin{array}{cccccc}
1 & 2 & 3 & 4 & 5 & 6 
(3)
Type: Matrix(Integer)
fricas
a * transpose a

\label{eq4}\left[ 
\begin{array}{c}
{91}
(4)
Type: Matrix(Integer)

Tim Daly replies:

make three vectors

fricas
)clear all
All user variables and function definitions have been cleared. u : VECTOR INT := new(5,12)

\label{eq5}\left[{12}, \:{12}, \:{12}, \:{12}, \:{12}\right](5)
Type: Vector(Integer)
fricas
v : VECTOR INT := vector([1,2,3])

\label{eq6}\left[ 1, \: 2, \: 3 \right](6)
Type: Vector(Integer)
fricas
w : VECTOR INT := vector([2,3,4])

\label{eq7}\left[ 2, \: 3, \: 4 \right](7)
Type: Vector(Integer)

multiply them

fricas
cross(v,w)

\label{eq8}\left[ - 1, \: 2, \: - 1 \right](8)
Type: Vector(Integer)

dot product

fricas
dot(v,w)

\label{eq9}20(9)
Type: PositiveInteger?

ask for the length

fricas
#(v)

\label{eq10}3(10)
Type: PositiveInteger?

access an element

fricas
v(2)

\label{eq11}2(11)
Type: PositiveInteger?

set an element

fricas
v(3) := 99

\label{eq12}99(12)
Type: PositiveInteger?

show the vector

fricas
v

\label{eq13}\left[ 1, \: 2, \:{99}\right](13)
Type: Vector(Integer)

multiply by a constant on either side

fricas
5 * v

\label{eq14}\left[ 5, \:{10}, \:{495}\right](14)
Type: Vector(Integer)
fricas
v * 7

\label{eq15}\left[ 7, \:{14}, \:{693}\right](15)
Type: Vector(Integer)

add them

fricas
v + w

\label{eq16}\left[ 3, \: 5, \:{103}\right](16)
Type: Vector(Integer)

substract them

fricas
v - w

\label{eq17}\left[ - 1, \: - 1, \:{95}\right](17)
Type: Vector(Integer)

display all possible functions

fricas
)show Vector(Integer)
Vector(Integer) is a domain constructor. Abbreviation for Vector is VECTOR This constructor is exposed in this frame. 74 Names for 99 Operations in this Domain. ------------------------------- Operations --------------------------------
#? : % -> NonNegativeInteger ?*? : (Integer, %) -> % ?*? : (%, Integer) -> % ?+? : (%, %) -> % ?-? : (%, %) -> % -? : % -> % ?<? : (%, %) -> Boolean ?<=? : (%, %) -> Boolean ?=? : (%, %) -> Boolean ?>? : (%, %) -> Boolean ?>=? : (%, %) -> Boolean coerce : % -> OutputForm concat : (Integer, %) -> % concat : List(%) -> % concat : (%, Integer) -> % concat : (%, %) -> % construct : List(Integer) -> % convert : % -> InputForm copy : % -> % cross : (%, %) -> % delete : (%, Integer) -> % dot : (%, %) -> Integer elt : (%, Integer) -> Integer empty : () -> % empty? : % -> Boolean entries : % -> List(Integer) entry? : (Integer, %) -> Boolean eq? : (%, %) -> Boolean fill! : (%, Integer) -> % first : % -> Integer hash : % -> SingleInteger index? : (Integer, %) -> Boolean indices : % -> List(Integer) insert : (%, %, Integer) -> % latex : % -> String leftTrim : (%, Integer) -> % max : % -> Integer max : (%, %) -> % maxIndex : % -> Integer member? : (Integer, %) -> Boolean members : % -> List(Integer) merge : (%, %) -> % min : % -> Integer min : (%, %) -> % minIndex : % -> Integer parts : % -> List(Integer) qelt : (%, Integer) -> Integer remove : (Integer, %) -> % removeDuplicates : % -> % reverse : % -> % reverse! : % -> % rightTrim : (%, Integer) -> % sample : () -> % smaller? : (%, %) -> Boolean sort : % -> % sort! : % -> % sorted? : % -> Boolean trim : (%, Integer) -> % vector : List(Integer) -> % zero : NonNegativeInteger -> % zero? : % -> Boolean ?~=? : (%, %) -> Boolean any? : ((Integer -> Boolean), %) -> Boolean copyInto! : (%, %, Integer) -> % count : (Integer, %) -> NonNegativeInteger count : ((Integer -> Boolean), %) -> NonNegativeInteger delete : (%, UniversalSegment(Integer)) -> % elt : (%, Integer, Integer) -> Integer elt : (%, UniversalSegment(Integer)) -> % every? : ((Integer -> Boolean), %) -> Boolean find : ((Integer -> Boolean), %) -> Union(Integer,"failed") first : (%, NonNegativeInteger) -> % hashUpdate! : (HashState, %) -> HashState insert : (Integer, %, Integer) -> % less? : (%, NonNegativeInteger) -> Boolean map : (((Integer, Integer) -> Integer), %, %) -> % map : ((Integer -> Integer), %) -> % map! : ((Integer -> Integer), %) -> % max : (((Integer, Integer) -> Boolean), %) -> Integer merge : (((Integer, Integer) -> Boolean), %, %) -> % more? : (%, NonNegativeInteger) -> Boolean new : (NonNegativeInteger, Integer) -> % outerProduct : (%, %) -> Matrix(Integer) position : (Integer, %, Integer) -> Integer position : (Integer, %) -> Integer position : ((Integer -> Boolean), %) -> Integer qsetelt! : (%, Integer, Integer) -> Integer reduce : (((Integer, Integer) -> Integer), %, Integer, Integer) -> Integer reduce : (((Integer, Integer) -> Integer), %, Integer) -> Integer reduce : (((Integer, Integer) -> Integer), %) -> Integer remove : ((Integer -> Boolean), %) -> % select : ((Integer -> Boolean), %) -> % setelt! : (%, Integer, Integer) -> Integer setelt! : (%, UniversalSegment(Integer), Integer) -> Integer size? : (%, NonNegativeInteger) -> Boolean sort : (((Integer, Integer) -> Boolean), %) -> % sort! : (((Integer, Integer) -> Boolean), %) -> % sorted? : (((Integer, Integer) -> Boolean), %) -> Boolean swap! : (%, Integer, Integer) -> Void