How to compute arccos for a matrix?

I would like to compute the arccos for a matrix. I know when I want to find log(), exp(), and sqrt () for a matrix , we use logm(A), expm(A) and sqrtm(A) where A is a matrix.
I want to find the following:
x=acos(sqrtm(A)\eye(n))
so, Is it correct to compute it like this ? Or we need to use arccosm(sqrtm(A)\eye(n))? Thank you.

2 Comments

There are no trig matrix functions in MATLAB, except the ones that work element by element.
So, is it correct to compute the following?
x=acos(sqrtm(A)\eye(n))

Sign in to comment.

Answers (1)

It depends what you are trying to calculate.
And so we could potentially generalize that for matrices, there might be some meaning to
arccosm = @(z) 1i * logm(z + sqrtm(z^2 - 1))
I am having difficulty thinking of a context in which there could be physical meaning for this.
If we substitute in 1/sqrtm(A) then
1i*logm(sqrtm(A\eye(n) - 1) + sqrtm(A)\eye(m))
But is there a meaning for this??

11 Comments

I could not understand why do we need to use that formula from wikipedia. In Matlab we can use function acos(). I was confused If we have a matrix then how can we compute that.
Do do want the arccos of each individual element? Or do you need it in some matrix sense?
For example do you definitely need sqrtm() or would sqrt() be appropriate for you?
We use sqrtm(), when we want to compute the square root of a matrix, how about when we have arccos(sqrt(x)), where x is a matrix not element?
Yes, but the question is, do you need to compute a matrix acos? Or do you really want to compute the element-wise operation, which is what is already offered in MATLAB.
I am in agreement with Walter, as I have never seen this as being useful. Conversely, tools like expm(A) and sqrtm both have significant utility. For example, expm is a useful tool to solve differntial equations systems. And sqrtm is a useful tool in linear algebra.
So, while I could happily agree that an extension for other functions into the domain of matrix arguments might be of minor mathematical interest, is there some real use you have for such a tool?
I want to obtain the exact solution of the following matrix function
A=full(gallary('tridiag',10,1,2,1));
v=ones(10,1);
w=v/norm(v);
f(A)=acos(1/sqrtm(A))/sqrtm(A); %is it correct to write f(A) as I did?
sol=w'*f(A)*w
f(A)=arccos(1/sqrtm(A))/sqrtm(A); %is it correct to write f(A) as I did?
No. In any respect, in MATLAB, the answer is no.
Omar B.
Omar B. on 6 Jul 2020
Edited: Omar B. on 6 Jul 2020
I made a mistake in writing f(A).
f(A) was not your only mistake. If all you were thinking of is:
f_A = acos(1./sqrtm(A))/sqrtm(A);
thus an element-wise acos, then that is correct, as an element-wise acos. But you are asking about a matrix form of the acos, which is something completely different, as much different as sqrt(A) would be compared to sqrtm(A).
Your second mistake was that you wrote 1/sqrtm(A). This is not correct at all in MATLAB, and will generate an error for a matrix A.
I assume that you just wanted to compute the inverse of the elements of sqrtm(A)? Or are you asking to compute the MATRIX inverse of the equare root of the MATRIX A? Again, these are totally different things.
Thus point is, what is the actual formula you are trying to write here? It is impossible to know how to correct this expression when written incorrectly, since it is becoming ambiguous as to what formula you want to compute.
Can we assume that you do need to compute the matrix square root there? Or is that the square root of the elements of A? You used sqrtm, but did you mean to use it? Or did you not appreciate the dirrerence there?
Then you wrote 1/sqrtm(A). This makes the entire question ambiguous, because I cannot know if you intended to form the inverse of the elements or the inverse of the matrix.
And that leads me to question if you are really asking for the acos of the elements or the acos of the matrix.
f = acos(inv(sqrtm(A))/sqrtm(A));
Maybe.
I really appreciate your help. I am really confused about that. I want to evaluat matrix A at the following function
f(x)=arccos(1/sqrt(x))/sqrt(x)
f1 = @(x) acos(sqrtm(x)^(-1)) * sqrtm(x)^(-1);
f2 = @(x) acos(sqrtm(x)/eye(size(x,1))) / sqrtm(x);
f3 = @(x) acos(1./sqrt(x)) ./ sqrt(x);
f1(A)
f2(A)
f3(A)
Try them all and decide which one is the right solution for you.

Sign in to comment.

Categories

Tags

Asked:

on 4 Jul 2020

Commented:

on 7 Jul 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!