Determinant of the Jacobian as a constraint couldn't avoid atan2(x,y) get into negative.
3 views (last 30 days)
Show older comments
I've been trying to avoid singularity using determinant as a constraint. However, some anglar values obtained using atan2 () keep giving me the follwoing error message.
"Error using atan2 Inputs must be real."
while the determinant of the Jacobian is non-zero. This is because one of the input of atan2 is complex . Could this be related to matlab ? What function should I replace it with to scape from this trap? I believe, there is no singularity as long as the Jacobian has non-zero determinant.
Thanks
2 Comments
Matt J
on 12 Apr 2022
Edited: Matt J
on 12 Apr 2022
You have given us no information about the calculations you are doing, but I can say in general that no, a non-zero determinant is not usually a good way to ensure invertibility. For example, this matrix A has a non-zero determinant, but for numerical purposes, it is non-invertible.
A=[1,1;0 1e-20]; b=rand(2,1);
A\b
Also, every singular matrix has a non-singular matrix infinitely close to it,. So, if this is part of an iterative optimization problem, a non-singularity constraint cannot prevent the iterations from getting arbitrarily close to a singular solution.
Accepted Answer
Alan Weiss
on 13 Apr 2022
While I do not know what you are really doing, you should know that nonlinear constraints are not satisfied at intermediate iterations. See Iterations Can Violate Constraints. That means your attempt to satisfy nonsingularity by including a nonlinear constraint is doomed to failure.
Instead, you should modify your objective function to be robust to infeasible points. Have the objective return NaN at these points, instead of getting into a situation where MATLAB throws an error.
Alan Weiss
MATLAB mathematical toolbox documentation
5 Comments
More Answers (0)
See Also
Categories
Find more on Linear Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!