Adjoint matrix (my function): ok with numbers but not symbolics - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Adjoint matrix (my function): ok with numbers but not symbolics (/thread-9469.html) |
Adjoint matrix (my function): ok with numbers but not symbolics - salvomic - 11-10-2017 04:04 PM hi, in the code in this program the function adj(m) works well with numbers like Code: adj([1,2],[3,4]) Code: adj([a,b],[c,d]) Why? The need to have this function is because the new adjoint_matrix() in the CAS is, as it must be, more detailed, and it returns characteristic polynomial of A and the comatrix o A-xI, i.e. Code:
Code: [[d, -b],[-c,a]] Any help, please, using (or not) the new adjoint_matrix()? Salvo RE: Adjoint matrix (my function): ok with numbers but not symbolics - Carlos295pz - 11-10-2017 04:38 PM It is true! was there a change in interactivity HP PPL - CAS? RE: Adjoint matrix (my function): ok with numbers but not symbolics - Tim Wessman - 11-10-2017 04:41 PM There should not have been, so this is interesting and exactly why we wanted a more public beta to test a wider range of user programs. To be clear, you are calling your function in the CAS where previously it worked fine? Or are you calling it from Home? Please provide exact steps that DID work in prior versions and now no longer work. Thank you! RE: Adjoint matrix (my function): ok with numbers but not symbolics - salvomic - 11-10-2017 04:57 PM (11-10-2017 04:41 PM)Tim Wessman Wrote: There should not have been, so this is interesting and exactly why we wanted a more public beta to test a wider range of user programs. I called my adj() in CAS with this code: Code: adj([[a,b],[c,d]]) \[ \begin{Vmatrix} d & -b \\ -c & a \end{Vmatrix} \] and instead return an error. If I try Code: adj([[1,2],[4,3]]) \[ \begin{Vmatrix} 3 & -2 \\ -4 & 1 \end{Vmatrix} \] In my program adj(m) recall the internal cofactors(m) that use MAKEMAT and an internal function, minor(mat, r,c) that simply use delrows() and delcols() to delete row r and col c and pass the argument, and so on. A simple code that, if I well remember worked well with numbers and with letters first (however I can be wrong, I don't remember if in older version it worked also with letters, I would like to understand why the littoral matrix is taken as it wouldn't a matrix and why then there is the "bad argument type")... Also in iOS app I get the error. So I wonder: maybe it's not a real bug but only a problem with types of vars? Simply, I thought that passing a matrix (m) it were indifferent if the matrix had numbers or letters (for symbolic calc) in its elements... EDIT: also with adj([[1, SIN(x)],[2,3]]) I get "Error: Bad argument type" \[ \begin{Vmatrix} 1 & sin(x) \\ 2 & 3 \end{Vmatrix} \] RE: Adjoint matrix (my function): ok with numbers but not symbolics - salvomic - 11-10-2017 05:05 PM Here there is the code, if someone would like to collaborate to find the error in it, that prevent the use of a letters instead of numbers in the matrix: Code:
The problem is in input, I suppose: type([1,2],[4,3]) -> DOM_LIST TYPE([1,2],[4,3]) -> 4 (matrix) but type([1,sin(x)],[2,3]) -> DOM_LIST TYPE([1,sin(x)],[2,3]) -> 6 (list) ... RE: Adjoint matrix (my function): ok with numbers but not symbolics - Tim Wessman - 11-10-2017 06:47 PM (11-10-2017 04:57 PM)salvomic Wrote: I called my adj() in CAS with this code: Well, that is the issue. Did it work previously and something has changed? Or is this just new code not working like you'd want. One is a bug and one is an enhancement/feature request. RE: Adjoint matrix (my function): ok with numbers but not symbolics - salvomic - 11-10-2017 06:53 PM (11-10-2017 06:47 PM)Tim Wessman Wrote: Well, that is the issue. Did it work previously and something has changed? Or is this just new code not working like you'd want. Tim, I'm not requesting an enhancement, hi :-) I made the code in 2015 and then it worked, I believe also with the symbolic matrices... Now that code (I haven't changed nothing) distinguishes between matrices and lists and refuses to treat the second ones. I do *hope* it isn't a bug RE: Adjoint matrix (my function): ok with numbers but not symbolics - parisse - 11-10-2017 06:55 PM When you compute the det of a minor, it will return a symbolic expression, can you really store that in a Home local variable? Why don't you write a CAS program ? What about defining adj(m):=adjoint_matrix(m)[2,size(m)]? RE: Adjoint matrix (my function): ok with numbers but not symbolics - salvomic - 11-10-2017 07:07 PM (11-10-2017 06:55 PM)parisse Wrote: When you compute the det of a minor, it will return a symbolic expression, can you really store that in a Home local variable?you are right, I didn't think it when I wrote the program. Quote:Why don't you write a CAS program ? oh, well (it is not a bug, Tim) In 2015 we hadn't adjoint_matrix()... Thank you! Now is more and more simple. I'm rewriting the program as you suggest. Only a little difference: adjoint_matrix([[1,2],[4,3]])[2,2] returns [[-3,2],[4,-1]] and my adj([[1,2],[4,3]]) returns [[3,-2],[-4,1]], that's the first result multiplied by -1 ... Also with [[a,b],[c,d]] I get the difference * -1... RE: Adjoint matrix (my function): ok with numbers but not symbolics - parisse - 11-10-2017 07:09 PM Then adj(m):=adjoint_matrix(m)[2,size(m)]*(-1)^(size(m)-1) should do the job. RE: Adjoint matrix (my function): ok with numbers but not symbolics - salvomic - 11-10-2017 07:12 PM (11-10-2017 07:09 PM)parisse Wrote: Then adj(m):=adjoint_matrix(m)[2,size(m)]*(-1)^(size(m)-1) should do the job. ok! I'll rewrite the whole program for the new FW as a CAS function... EDIT This code is all CAS and works after the beta 2017 November 8. adj(m) Adjoint matrix cofactors(m) Cofactors matrix -> TRN(adj(m)) minor(m, r, c) a minor of the matrix m, suppressing row r and col c Code:
|