Satisfying an equation using random numbers
이전 댓글 표시
I have chosen ten random values for theta using theta = pi*(1/2 - 1*rand(1,10)).
Now I want to prove that for these 10 randomly chosen numbers,
sqrt((1-sin(theta)) / (1+sin(theta))) = (1-tan(theta/2)) / (1+tan(theta/2))
I set the left hand side equal to the variable lhs and the right hand side equal to the variable rhs, however they are giving me different values!
How would you go about proving lhs = rhs with these 10 random values?
답변 (1개)
KALYAN ACHARJYA
2019년 3월 26일
편집: KALYAN ACHARJYA
2019년 3월 26일
theta=pi*(1/2-1*rand(1,10));
LHS=sqrt((1-sin(theta))./(1+sin(theta)));
RHS=(1-tan(theta/2))./(1+tan(theta/2));
If your check the values
>> LHS
LHS =
4.1859 1.2110 9.0071 1.9375 1.3009 3.3514 5.1984 57.4074 0.0008 4.6604
>> RHS
RHS =
4.1859 1.2110 9.0071 1.9375 1.3009 3.3514 5.1984 57.4074 0.0008 4.6604
>> LHS-RHS
ans =
1.0e-12 *
0.0009 0.0002 0.0036 0.0002 0 -0.0004 -0.0018 0.9237 -0.0064 -0.0018
Please note the difference is not equal zero.
>> isequal(LHS,RHS)
ans =
0
Logic Zero That menas not equal in Matlab, Please read about limit of floating point representation or look here
Other case
>> A=[1 2 3];
>> B=[1 2 3];
>> isequal(A,B)
ans =
1
Hope it helps!
카테고리
도움말 센터 및 File Exchange에서 Univariate Discrete Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!