Sqrt of matrix

04112022, 08:35 AM
Post: #1




Sqrt of matrix
Is there a command for finding a SQRT of all elements in the matrix?
Like if I have a matrix (that varies in size) Like in this Example if I have 3x3 Matrix (M1)> then I run cas.diag(M1) i will get matrix 1,9,16 now Is there a command to automatically find SQRT values of 1,9,16 ? So the answer ends up being a matrix with values 1, 3, 4 ? 

04112022, 12:43 PM
Post: #2




RE: Sqrt of matrix
The cas sqrt(matrix) should help.
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz 

04112022, 01:09 PM
Post: #3




RE: Sqrt of matrix
Code: apply(sqrt,[[4,1],[2,3]],matrix) 

04112022, 01:12 PM
Post: #4




RE: Sqrt of matrix
I think what Amer7 wants is a matrix containing the square root of each element of another matrix. If that's true then here's an example of how to do that:
[[1,2],[3,4]]▶M1 MAKEMAT(√(M1(I,J)),2,2)▶M2 Now M2 contains: [[1,1.41421356237],[1.73205080757,2]] 

04112022, 04:13 PM
Post: #5




RE: Sqrt of matrix
Yes, that's precisely what apply(...) does, sqrt on each element.


04112022, 04:24 PM
(This post was last modified: 04112022 04:26 PM by Amer7.)
Post: #6




RE: Sqrt of matrix
@StephenG1CMZ
This works when In CAS @ parisse @roadrunner It works but I have to know the size of the Matrix. The issue with my programs is when I get an assignment I never hav the same MatrixDimensions. There are a lot of calculations between the Matrices, that's why I have to write these programs. How can I call CAS in normal program. Like if I have: Code: Begin 

04112022, 06:07 PM
Post: #7




RE: Sqrt of matrix
Is this syntax of any help?
[code] EXPORT RT() BEGIN M1:=[1,3,9]; M1:=CAS("sqrt(M1)"); PRINT(M1); END; [\code] Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz 

04112022, 06:24 PM
Post: #8




RE: Sqrt of matrix  
04122022, 12:58 AM
Post: #9




RE: Sqrt of matrix  
04122022, 12:39 PM
Post: #10




RE: Sqrt of matrix
(04112022 08:35 AM)Amer7 Wrote: now Is there a command to automatically find SQRT values of 1,9,16 ? HOME> [[1, 9, 16]] .^ 0.5 → [[1, 3, 4]] This has an advantage by not going thru CAS, which may make sqrt inaccurate. HOME> M1 := [[0.398, 0.571]] HOME> M1 .^ 0.5 [[0.630872411824, 0.755645419493]] HOME> CAS("apply(sqrt, M1)") [[0.630872411823, 0.755645419492]] 

04122022, 01:50 PM
Post: #11




RE: Sqrt of matrix
(04112022 06:24 PM)Amer7 Wrote:(04112022 06:07 PM)StephenG1CMZ Wrote: Is this syntax of any help? Note: Whilst sqrt(matrix) can be useful, it's not the same as applying sqrt to each element. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)