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

Edit detail for Computing with Vectors revision 3 of 4

1 2 3 4
Editor: 127.0.0.1
Time: 2007/11/15 20:30:18 GMT-8
Note: transferred from axiom-developer

changed:
-Multiplication element by element:
-
-*Vanuxem Grégory replies:*
  Multiplication element by element:

**Vanuxem Gregory replies:**

changed:
-*Tim Daly replies:*
**Tim Daly replies:**

How to multiply two vectors??

Multiplication element by element:

Vanuxem Gregory replies:

Try

fricas
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. ------------------------------- Operations --------------------------------
#? : % -> NonNegativeInteger ?*? : (Integer,%) -> % ?*? : (%,Integer) -> % ?+? : (%,%) -> % ?-? : (%,%) -> % -? : % -> % ?<? : (%,%) -> Boolean ?<=? : (%,%) -> Boolean ?=? : (%,%) -> Boolean ?>? : (%,%) -> Boolean ?>=? : (%,%) -> Boolean coerce : % -> OutputForm concat : (Integer,%) -> % concat : List(%) -> % concat : (%,Integer) -> % concat : (%,%) -> % construct : List(Integer) -> % convert : % -> InputForm copy : % -> % copyInto! : (%,%,Integer) -> % cross : (%,%) -> % delete : (%,Integer) -> % dot : (%,%) -> Integer ?.? : (%,Integer) -> Integer empty : () -> % empty? : % -> Boolean entries : % -> List(Integer) entry? : (Integer,%) -> Boolean eq? : (%,%) -> Boolean eval : (%,Integer,Integer) -> % fill! : (%,Integer) -> % first : % -> Integer hash : % -> SingleInteger index? : (Integer,%) -> Boolean indices : % -> List(Integer) insert : (%,%,Integer) -> % latex : % -> String length : % -> Integer magnitude : % -> Integer max : (%,%) -> % maxIndex : % -> Integer member? : (Integer,%) -> Boolean members : % -> List(Integer) merge : (%,%) -> % min : (%,%) -> % minIndex : % -> Integer parts : % -> List(Integer) position : (Integer,%) -> Integer qelt : (%,Integer) -> Integer remove : (Integer,%) -> % removeDuplicates : % -> % reverse : % -> % reverse! : % -> % sample : () -> % smaller? : (%,%) -> Boolean sort : % -> % sort! : % -> % sorted? : % -> Boolean vector : List(Integer) -> % zero : NonNegativeInteger -> % zero? : % -> Boolean ?~=? : (%,%) -> Boolean any? : ((Integer -> Boolean),%) -> Boolean count : (Integer,%) -> NonNegativeInteger count : ((Integer -> Boolean),%) -> NonNegativeInteger delete : (%,UniversalSegment(Integer)) -> % elt : (%,Integer,Integer) -> Integer ?.? : (%,UniversalSegment(Integer)) -> % eval : (%,Equation(Integer)) -> % eval : (%,List(Equation(Integer))) -> % eval : (%,List(Integer),List(Integer)) -> % every? : ((Integer -> Boolean),%) -> Boolean find : ((Integer -> Boolean),%) -> Union(Integer,"failed") hashUpdate! : (HashState,%) -> HashState insert : (Integer,%,Integer) -> % less? : (%,NonNegativeInteger) -> Boolean map : (((Integer,Integer) -> Integer),%,%) -> % map : ((Integer -> Integer),%) -> % map! : ((Integer -> Integer),%) -> % merge : (((Integer,Integer) -> Boolean),%,%) -> % more? : (%,NonNegativeInteger) -> Boolean new : (NonNegativeInteger,Integer) -> % outerProduct : (%,%) -> Matrix(Integer) position : (Integer,%,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