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?

2 Kommentare

Daniel Porter
Daniel Porter am 26 Mär. 2019
The question that i am doing says that these two sides are equal.
Also when I put any value between -pi/2 and pi/2 into both these sides, they give out the sasme answer. This is in my calculator however, not in MatLab.
I want to see how this can be accomplished in Matlab.
Cheers
I see. You're just missing the period before the division.
./
see KALYAN ACHARJYA's answer below.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KALYAN ACHARJYA
KALYAN ACHARJYA am 26 Mär. 2019
Bearbeitet: KALYAN ACHARJYA am 26 Mär. 2019

0 Stimmen

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!

Gefragt:

am 26 Mär. 2019

Kommentiert:

am 26 Mär. 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by