atan2(0,0) is not undefined (NaN)
    조회 수: 9 (최근 30일)
  
       이전 댓글 표시
    
I'm using MATLAB R2020a Home Edition on a Windows® machine.  I have a need to calculate atan2(0,0) which, if I am correct should result in NaN (undefined).  The answer I get is zero.  Is this not bug in the underline algorithm for computation of atan2()?
Thank you in advance.
댓글 수: 0
채택된 답변
  Star Strider
      
      
 2020년 8월 11일
        The result also isd not completely standardised.  See the section in the Wikipedia article on Atan2 on Realizations of the function in common computer languages.  
댓글 수: 2
  Star Strider
      
      
 2020년 8월 11일
				As always, my pleasure!  
MATLAB began as a FORTRAN implementation, later switching to C.  
추가 답변 (2개)
  hosein Javan
      
 2020년 8월 11일
        it is not a bug. although in analytic math it is undefined, the trigonometric functions are usually calculated by their taylor series expansion on numerical softwares. no doubt it results zero. however when you try very small values, it is still correct:
atan2(1e-301,1e-301)*180/pi
ans =
    45
참고 항목
카테고리
				Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!