Integral of matrix determinant
5 views (last 30 days)
I found that it seems the
fucntion cannot integrate determinant. For example
does not return a proper result. Of course we can mannually take
but this can be hardly applied to larger matrices. Is there a solution to this problem?
More Answers (2)
John D'Errico on 6 Mar 2023
For this specific problem, I might just suggest that the determinant of an upper triangular matrix is just the product of the diagonal elements.
A = [1 x;0 2]
As such, the use of det or integral is wild overkill here, since the determinant is independent of the value of x.
Why does integral fail? Because it tries to pass in a list of points to evaluate the function at. And det is not vectorized. So this is not a problem of integral in reality, but of the interaction between integral and det. Integral insists on the function being vectorized. Det insists is it NOT vectorized. Failure!
The solution is to evaluate the determinant as a polynomial in symbolic form, and then integrate, or do as @Torsten has shown, to use the 'arrayvalued' option in integral.
And, to be honest, the help does not really state that this is how you can avoid the need for your objective function to be vectorized.
f=@(x) det([1 x;0 2]);