Satisfying an equation using random numbers
Mostra commenti meno recenti
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?
Risposte (1)
KALYAN ACHARJYA
il 26 Mar 2019
Modificato: KALYAN ACHARJYA
il 26 Mar 2019
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!
Categorie
Scopri di più su Univariate Discrete Distributions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!