Linear Independence and change of basis

39 views
Skip to first unread message

Sid Andal

unread,
Dec 12, 2023, 10:18:15 AM12/12/23
to FriCAS - computer algebra system
The function isBasis?() returns with non-trivial linear combination when
applied to linearly independent vectors:

(1) -> F ==> PF 11
(2) -> VF ==> Vector F
(9) -> (v1,v2,v3) : VF

(11) -> v1 := [1,1,2]

   (11)  [1, 1, 2]

(12) -> v2 := [2,1,2]

   (12)  [2, 1, 2]

(13) -> v3 := [1,2,1]

   (13)  [1, 2, 1]

(14) -> M : Matrix F := [v1,v2,v3]

         ┌1  1  2┐
         │           │
         │2  1  2│
         │           │
         └1  2  1┘

(15) -> rank M

   (15)  3

Applying isBasis:

(17) -> isBasis?([v1,v2,v3])

   (17)  isBasis?
                 1, 2, 1

It should've returned 0,0,0.

Now, trying to express a vector, w, in terms of the new basis {v1,v2,v3}
also runs into problem:

(16) -> w : VF := [2,3,10]

   (16)  [2, 3, 10]

(17) -> coordinatesIfCan(w,[v1,v2,v3])
   There are no exposed library operations named coordinatesIfCan but
      there is one unexposed operation with that name. Use HyperDoc
      Browse or issue
                        )display op coordinatesIfCan
      to learn more about the available operation.
 
   Cannot find a definition or applicable library operation named
      coordinatesIfCan with argument type(s)
                           Vector(PrimeField(11))
                        List(Vector(PrimeField(11)))
     
      Perhaps you should use "@" to indicate the required return type,
      or "$" to specify which version of the function you need.

Are the two functions applied the wrong way in the above cases?

Thanks,
SWA

Ralf Hemmecke

unread,
Dec 12, 2023, 11:19:11 AM12/12/23
to fricas...@googlegroups.com
Sometimes it makes sense to say

)type on

in order to see what the interpreter makes out of your input.

Obviously, returning a symbol is not what you want, i.e. the function
selection goes not the way you hope for.

%%% (10) -> isBasis?([v1,v2,v3])

(10) isBasis?
1, 2, 1
Type: Symbol

You can check what the interpreter tries to select via

)set message bottom on

Cllearly, helping the interpreter a little by package calling the right
function, solves your problem.

%%% (11) -> isBasis?([v1,v2,v3])$VectorSpaceBasis(F)

(11) true
Type: Boolean

%%% (14) -> coordinatesIfCan(w,basis [v1,v2,v3])$VectorSpaceBasis(F)

(14) [8, 5, 6]
Type: Union(Vector(PrimeField(11)),...)

Ralf

Prof. Dr. Johannes Grabmeier

unread,
Dec 12, 2023, 11:22:41 AM12/12/23
to fricas...@googlegroups.com

Hi Sid, two points: 

1.VectorSpaceBasis is not exposed, so interpreter cannot find its functions.

2. coordinatesIfCan requires as second argument a basis, i.e. an element of VectorSpaceBasis(F), not just a list of vectors.

Here is the corrected code:

(1) -> )r isBasis
)expose VectorSpaceBasis

   VectorSpaceBasis is already explicitly exposed in frame frame1
F ==> PF 11

                                                                                          Type: Void
VF ==> Vector F

                                                                                          Type: Void
(v1,v2,v3) : VF

                                                                                          Type: Void
v1 := [1,1,2]


   (4)  [1, 1, 2]
                                                                        Type: Vector(PrimeField(11))
v2 := [2,1,2]


   (5)  [2, 1, 2]
                                                                        Type: Vector(PrimeField(11))
v3 := [1,2,1]


   (6)  [1, 2, 1]
                                                                        Type: Vector(PrimeField(11))


M : Matrix F := [v1,v2,v3]


        +1  1  2+
        |       |
   (7)  |2  1  2|
        |       |
        +1  2  1+
                                                                        Type: Matrix(PrimeField(11))
rank M


   (8)  3
                                                                               Type: PositiveInteger
isBasis?([v1,v2,v3])


   (9)  true
                                                                                       Type: Boolean
w : VF := [2,3,10]


   (10)  [2, 3, 10]
                                                                        Type: Vector(PrimeField(11))
b := basis [v1,v2,v3]


   (11)  VectorSpace [[1, 1, 2], [2, 1, 2], [1, 2, 1]]
                                                              Type: VectorSpaceBasis(PrimeField(11))
coordinatesIfCan(w,b)


   (12)  [8, 5, 6]
                                                             Type: Union(Vector(PrimeField(11)),...)




Am 12.12.23 um 16:18 schrieb Sid Andal:
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/eb43990c-c999-476d-b81e-5888a43066dan%40googlegroups.com.
-- 
Mit freundlichen Grüßen

Johannes Grabmeier

Prof. Dr. Johannes Grabmeier, 
Köckstraße 1, D-94469 Deggendorf
Tel. +49-(0)-991-2979584, Tel. +49-(0)-151-681-70756
Fax: +49-(0)-991-2979592

Sid Andal

unread,
Dec 12, 2023, 2:50:57 PM12/12/23
to FriCAS - computer algebra system
Thanks!

Just a question. Are there any guidelines as to what packages/domains, in general, one needs to expose, first in order to run similar routines?
The official documention, book.pdf, does not cover these functions and there were no online examples illustrating the usage.

Prof. Dr. Johannes Grabmeier

unread,
Dec 12, 2023, 4:01:04 PM12/12/23
to fricas...@googlegroups.com

e.g.:

(48) -> )sh VectorSpaceBasis
 VectorSpaceBasis(R: Field) is a domain constructor
 Abbreviation for VectorSpaceBasis is VSBASIS
 This constructor is not exposed in this frame.

Am 12.12.23 um 20:50 schrieb Sid Andal:
Reply all
Reply to author
Forward
0 new messages